/**
 * LeadLog Admin Dashboard Styles
 */

/* ========================================
   CSS Variables
   ======================================== */
:root {
    /* Brand Colors */
    --primary: #E54B51;
    --primary-light: #eb6f74;
    --primary-dark: #c93a40;
    --secondary: #376F86;
    --secondary-light: #4a8ba6;
    --secondary-dark: #2a5a6d;

    /* Status Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;

    /* UI Colors */
    --white: #FFFFFF;
    --bg-light: #F7F8F9;
    --bg-alt: #F0F4F6;
    --text-primary: #1F2933;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;
    --border-color: #E5E7EB;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Layout */
    --header-height: 60px;
    --sidebar-width: 240px;
    --sidebar-collapsed: 60px;

    /* Transitions */
    --transition: 0.2s ease;
}

/* ========================================
   Reset & Base
   ======================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-light);
    -webkit-font-smoothing: antialiased;
}

img {
    max-width: 100%;
    height: auto;
}

a {
    color: var(--secondary);
    text-decoration: none;
}

ul {
    list-style: none;
}

/* ========================================
   Utilities
   ======================================== */
.hidden {
    display: none !important;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-outline:hover {
    background: var(--bg-alt);
    color: var(--text-primary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-icon:hover {
    background: var(--bg-alt);
    color: var(--text-primary);
}

.btn-icon i {
    font-size: 20px;
}

/* ========================================
   Form Elements
   ======================================== */
.form-input {
    padding: 10px 14px;
    font-family: var(--font-family);
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--white);
    color: var(--text-primary);
    transition: border-color var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--secondary);
}

select.form-input,
select {
    padding: 10px 14px;
    font-family: var(--font-family);
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--white);
    color: var(--text-primary);
    cursor: pointer;
}

textarea {
    padding: 10px 14px;
    font-family: var(--font-family);
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--white);
    color: var(--text-primary);
    resize: vertical;
    width: 100%;
}

textarea:focus {
    outline: none;
    border-color: var(--secondary);
}

/* Toggle Switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    border-radius: 26px;
    transition: var(--transition);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: var(--transition);
}

.toggle input:checked + .toggle-slider {
    background-color: var(--success);
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

/* ========================================
   Auth Screens
   ======================================== */
.auth-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--secondary-dark) 0%, var(--secondary) 100%);
}

.auth-container {
    background: var(--white);
    padding: 48px;
    border-radius: 16px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.auth-logo {
    margin-bottom: 24px;
}

.auth-container h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--secondary);
    margin-bottom: 8px;
}

.auth-container > p {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.auth-container .btn {
    width: 100%;
}

.auth-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    font-size: 36px;
}

.auth-icon.error {
    background: #fef2f2;
    color: var(--error);
}

.auth-email {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.auth-error {
    margin-top: 16px;
    padding: 12px;
    background: #fef2f2;
    color: var(--error);
    border-radius: 8px;
    font-size: 13px;
}

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--secondary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   Admin App Layout
   ======================================== */
.admin-app {
    display: grid;
    grid-template-areas:
        "header header"
        "sidebar main";
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: var(--header-height) 1fr;
    min-height: 100vh;
}

/* Header */
.admin-header {
    grid-area: header;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: var(--white);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-badge {
    padding: 4px 10px;
    background: var(--secondary);
    color: var(--white);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    border-radius: 4px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.admin-info {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Sidebar */
.admin-sidebar {
    grid-area: sidebar;
    background: var(--white);
    border-right: 1px solid var(--border-color);
    padding: 24px 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    border-radius: 8px;
    transition: all var(--transition);
}

.nav-item:hover {
    background: var(--bg-alt);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--secondary);
    color: var(--white);
}

.nav-item i {
    font-size: 18px;
}

/* Main Content */
.admin-main {
    grid-area: main;
    padding: 24px;
    overflow-y: auto;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--secondary);
}

/* ========================================
   Dashboard Stats
   ======================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.stat-icon.users {
    background: #e0f2fe;
    color: #0284c7;
}

.stat-icon.subscribers {
    background: #fef3c7;
    color: #d97706;
}

.stat-icon.free {
    background: #f3e8ff;
    color: #9333ea;
}

.stat-icon.granted {
    background: #dcfce7;
    color: #16a34a;
}

.stat-icon.leads {
    background: #fee2e2;
    color: #dc2626;
}

.stat-icon.today {
    background: #e0e7ff;
    color: #4f46e5;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Dashboard Sections */
.dashboard-section {
    background: var(--white);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.dashboard-section h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.method-stats {
    display: flex;
    gap: 32px;
}

.method-stat {
    display: flex;
    align-items: center;
    gap: 12px;
}

.method-stat i {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-alt);
    color: var(--secondary);
}

.method-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.method-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ========================================
   Users Page
   ======================================== */
.users-toolbar {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

.search-box {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.search-box i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    font-family: var(--font-family);
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--white);
}

.search-box input:focus {
    outline: none;
    border-color: var(--secondary);
}

.filter-group select {
    min-width: 180px;
}

/* Users Table */
.users-table-container {
    background: var(--white);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    margin-bottom: 20px;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
}

.users-table th,
.users-table td {
    padding: 14px 16px;
    text-align: left;
}

.users-table th {
    background: var(--bg-alt);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.users-table td {
    border-bottom: 1px solid var(--border-color);
}

.users-table tr:last-child td {
    border-bottom: none;
}

.users-table tr:hover td {
    background: var(--bg-light);
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar-small {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-alt);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 14px;
}

.user-name {
    font-weight: 500;
    color: var(--text-primary);
}

.user-email {
    font-size: 12px;
    color: var(--text-muted);
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 20px;
}

.status-badge.pro {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.free {
    background: #e0e7ff;
    color: #3730a3;
}

.status-badge.free-access {
    background: #dcfce7;
    color: #166534;
}

.status-badge.cancelled {
    background: #fee2e2;
    color: #991b1b;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

#page-info {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ========================================
   Settings Page
   ======================================== */
.settings-section {
    background: var(--white);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.settings-section h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.settings-section > p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.setting-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.setting-row input[type="number"] {
    width: 80px;
}

/* ========================================
   Modal
   ======================================== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: var(--white);
    border-radius: 16px;
    max-width: 560px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.modal-content.modal-large {
    max-width: 800px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

/* User Detail Modal */
.user-detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.user-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--bg-alt);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 24px;
}

.user-detail-info h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-detail-info p {
    font-size: 14px;
    color: var(--text-secondary);
}

.user-detail-section {
    margin-bottom: 24px;
}

.user-detail-section:last-child {
    margin-bottom: 0;
}

.user-detail-section h4 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.detail-description {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.detail-label {
    font-size: 12px;
    color: var(--text-muted);
}

.detail-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.free-access-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Admin Notes */
.admin-notes-list {
    margin-bottom: 16px;
}

.admin-note {
    padding: 12px;
    background: var(--bg-light);
    border-radius: 8px;
    margin-bottom: 8px;
}

.admin-note:last-child {
    margin-bottom: 0;
}

.admin-note-text {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.admin-note-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.add-note-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.add-note-form textarea {
    flex: 1;
}

/* Workspaces List */
.workspaces-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.workspace-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-light);
    border-radius: 8px;
}

.workspace-item i {
    color: var(--secondary);
}

.workspace-name {
    font-weight: 500;
}

.workspace-role {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: auto;
}

/* Leads List */
.leads-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.lead-item {
    padding: 16px;
    background: var(--bg-light);
    border-radius: 8px;
}

.lead-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.lead-name {
    font-weight: 600;
    color: var(--text-primary);
}

.lead-company {
    font-size: 13px;
    color: var(--text-secondary);
}

.lead-details {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.lead-details i {
    margin-right: 4px;
    color: var(--text-muted);
}

.lead-method {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--bg-alt);
    border-radius: 4px;
    font-size: 11px;
    text-transform: uppercase;
}

/* ========================================
   Toast
   ======================================== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--text-primary);
    color: var(--white);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.toast-icon {
    font-size: 18px;
    color: var(--success);
}

.toast.error .toast-icon {
    color: var(--error);
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 900px) {
    .admin-app {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "main";
    }

    .admin-sidebar {
        position: fixed;
        left: 0;
        top: var(--header-height);
        bottom: 0;
        width: var(--sidebar-width);
        transform: translateX(-100%);
        transition: transform var(--transition);
        z-index: 99;
    }

    .admin-sidebar.open {
        transform: translateX(0);
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .method-stats {
        flex-direction: column;
        gap: 16px;
    }

    .users-toolbar {
        flex-direction: column;
    }

    .search-box {
        max-width: none;
    }
}

@media (max-width: 600px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .modal-content {
        max-height: 100vh;
        border-radius: 0;
    }

    .auth-container {
        padding: 32px 24px;
    }
}
