/* ============================================
   FXAcademyTools - Customer Portal Dashboard
   Synchronized Design System (Admin Mirror)
   ============================================ */

:root {
    --bg-dark: #0B0F19;
    --bg-card: #141B2D;
    --text-main: #E2E8F0;
    --text-muted: #94A3B8;
    --primary: #3B82F6;
    --primary-hover: #2563EB;
    --secondary: #8B5CF6;
    --accent: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
    --border: #1E293B;
    
    /* Legacy variable mappings for compatibility */
    --bg-primary: var(--bg-dark);
    --bg-secondary: var(--bg-card);
    --text-primary: var(--text-main);
    --text-secondary: var(--text-muted);
    --accent-primary: var(--primary);
    --accent-success: var(--accent);
    --border-color: var(--border);
    --gradient-card: var(--bg-card);
    --radius-lg: 1rem;
    --radius-md: 0.5rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --transition-base: 0.3s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Outfit', sans-serif; }

body { 
    background-color: var(--bg-dark); 
    color: var(--text-main); 
    min-height: 100vh; 
    overflow-x: hidden; 
}

.grid-bg { display: none; }

/* --- Logo & Branding --- */
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    transition: 0.3s;
}

.logo-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.85rem;
    color: #fff;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.25);
}

.logo span {
    color: var(--primary);
}

.logo:hover {
    opacity: 0.9;
}

/* --- Auth Pages --- */
.auth-page {
    background: radial-gradient(circle at top right, #1a233a, #0b0f19);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
}

.auth-wrapper {
    width: 100%;
    max-width: 480px;
    z-index: 10;
}

.auth-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: var(--space-2xl);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.auth-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: var(--space-sm);
    color: #fff;
}

.auth-header h1 span {
    color: var(--primary);
}

.auth-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

.input-with-icon input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 12px 16px 12px 48px;
    color: #fff;
    font-family: inherit;
    transition: 0.3s;
}

.input-with-icon input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
}

.btn-block {
    width: 100%;
}

.auth-footer {
    text-align: center;
    margin-top: var(--space-xl);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.auth-footer a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
}

/* --- Dashboard Layout --- */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
}

/* --- Sidebar --- */
.sidebar {
    width: 260px;
    background-color: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    height: 100dvh;
    z-index: 100;
    transition: 0.3s ease;
}

.sidebar-header {
    padding: 1.5rem 1.5rem;
    display: flex;
    align-items: center;
}

.sidebar-nav {
    flex: 1;
    padding: 0 1rem;
    overflow-y: auto;
}

.nav-menu {
    list-style: none;
}

.nav-item {
    margin-bottom: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 0.5rem;
    transition: 0.3s;
    font-weight: 500;
}

.nav-link i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.nav-link:hover, .nav-link.active {
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--primary);
}

.nav-link.active {
    border-left: 4px solid var(--primary);
    border-radius: 0 0.5rem 0.5rem 0;
}

.sidebar-footer {
    padding: 5.5rem 1.5rem 4.5rem; /* Increased bottom padding to lift content higher */
    border-top: 1px solid var(--border);
}

.user-avatar-sm {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
}

.user-info-sm .user-name {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: #3b82f6;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.page-title h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
}

.page-title p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* --- Widgets & Cards --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.5rem;
}

.stat-details h3 {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #fff;
}

/* --- Table Overrides --- */
.portal-table-container {
    background: var(--bg-card);
    border-radius: 1rem;
    border: 1px solid var(--border);
    overflow: hidden;
}

.portal-table th {
    background-color: rgba(255, 255, 255, 0.02);
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    padding: 1rem 1.5rem;
}

.portal-table td {
    padding: 1rem 1.5rem !important;
    border-bottom: 1px solid var(--border) !important;
}

/* --- Global Alert Styles --- */
.alert {
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: var(--accent);
}

/* --- Buttons & Inputs --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: 0.3s;
    border: none;
    text-decoration: none;
    font-size: 0.875rem;
}

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

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

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.05);
    color: #fff;
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.btn-danger {
    background-color: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background-color: #DC2626;
}

.btn-success {
    background-color: var(--accent);
    color: #fff;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-block {
    width: 100%;
}

.auth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border);
}

.auth-divider:not(:empty)::before {
    margin-right: .5em;
}

.auth-divider:not(:empty)::after {
    margin-left: .5em;
}

.btn-google {
    background-color: #fff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
}

.btn-google:hover {
    background-color: #f9fafb;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.btn-google img {
    width: 18px;
    height: 18px;
}

/* --- Responsive --- */
.account-grid {
    display: grid; 
    grid-template-columns: 1fr 2fr; 
    gap: 2rem;
}

/* Dimming Overlay Style */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

@media (max-width: 992px) {
    body.menu-open {
        overflow: hidden;
    }
    .account-grid {
        grid-template-columns: 1fr;
    }
    .sidebar {
        left: -260px;
        box-shadow: 10px 0 20px rgba(0,0,0,0.5);
    }
    
    .sidebar.open {
        left: 0;
    }

    /* FIX: Force link visibility (Override styles.css conflict) */
    .sidebar .nav-link {
        opacity: 1 !important;
        transform: none !important;
        visibility: visible !important;
        display: flex !important;
        color: var(--text-muted);
    }

    .sidebar .nav-link:hover, 
    .sidebar .nav-link.active {
        color: var(--primary) !important;
    }

    /* Sidebar Close Button Style (Mobile Only) */
    .sidebar-close {
        display: flex;
        position: absolute;
        top: 20px;
        right: 20px;
        width: 36px;
        height: 36px;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid var(--border);
        border-radius: 10px;
        align-items: center;
        justify-content: center;
        color: #fff;
        font-size: 1.2rem;
        cursor: pointer;
        z-index: 101;
        transition: 0.3s;
    }

    .sidebar-close:hover {
        background: rgba(239, 68, 68, 0.1);
        color: var(--danger);
        border-color: rgba(239, 68, 68, 0.2);
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 1.5rem;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .header-actions {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    /* Portal Table Mobile Card View */
    .portal-table thead {
        display: none;
    }
    
    .portal-table, .portal-table tbody, .portal-table tr, .portal-table td {
        display: block;
        width: 100%;
    }
    
    .portal-table tr {
        margin-bottom: 1rem;
        border: 1px solid var(--border);
        border-radius: 0.5rem;
        background: rgba(255,255,255,0.02);
        overflow: hidden;
    }
    
    .portal-table td {
        text-align: right;
        padding: 0.75rem 1rem !important;
        position: relative;
        border-top: 1px solid rgba(255, 255, 255, 0.05) !important;
    }
    
    .portal-table td:first-child {
        border-top: none !important;
        background: rgba(255,255,255,0.03);
    }
    
    .portal-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 1rem;
        width: 45%;
        text-align: left;
        font-weight: 600;
        color: var(--text-muted);
        text-transform: uppercase;
        font-size: 0.7rem;
    }
}

@media (max-width: 576px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .auth-container {
        padding: 1.5rem;
    }
    
    .page-title h1 {
        font-size: 1.25rem;
    }
}
