/* ===============================
   EARNEXA / CASHORA PREMIUM MASTER CSS
   Status: FIXED (Menu & Scroll)
   ================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* --- Colors --- */
    --bg-deep: #020617;
    --glass-bg: rgba(15, 23, 42, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --primary: #3B82F6;
    --primary-dark: #2563EB;
    --primary-glow: rgba(59, 130, 246, 0.4);
    --accent: #8B5CF6;
    
    --text-main: #FFFFFF;
    --text-muted: #94A3B8;
    
    --input-bg: rgba(255, 255, 255, 0.03);
    --input-focus-border: #60A5FA;
    
    /* --- Animations & Shadows --- */
    --ease-elastic: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-card: 0 25px 50px -12px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255,255,255,0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-deep);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    font-size: 14px;
}

/* ===============================
   GLOBAL AMBIENT GLOW
   =============================== */
body::before, body::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
}
body::before {
    top: -20%; left: -10%; width: 800px; height: 800px;
    background: radial-gradient(circle at center, rgba(59, 130, 246, 0.15), transparent 60%);
    animation: pulse 10s infinite alternate;
}
body::after {
    bottom: -20%; right: -10%; width: 600px; height: 600px;
    background: radial-gradient(circle at center, rgba(139, 92, 246, 0.1), transparent 60%);
    animation: pulse 12s infinite alternate-reverse;
}
@keyframes pulse {
    0% { transform: scale(1); opacity: 0.5; }
    100% { transform: scale(1.1); opacity: 0.8; }
}

/* ===============================
   COMPONENTS (Cards, Inputs, Buttons)
   =============================== */

/* Glass Card */
.glass-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 24px;
    box-shadow: var(--shadow-card);
    padding: 40px;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s var(--ease-smooth);
}

/* Inputs */
.input-group { margin-bottom: 20px; position: relative; }
label { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 8px; margin-left: 2px; }
.input-wrapper { position: relative; }

.input-icon {
    position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
    color: #475569; pointer-events: none; z-index: 2; transition: color 0.3s;
}

input, select, textarea {
    width: 100%; padding: 14px 16px 14px 44px;
    background: var(--input-bg); border: 1px solid var(--glass-border);
    border-radius: 14px; color: var(--text-main); font-family: 'Inter', sans-serif;
    font-size: 14px; outline: none; transition: all 0.25s var(--ease-smooth);
}
input:hover { border-color: rgba(255, 255, 255, 0.15); background: rgba(255, 255, 255, 0.05); }
input:focus { border-color: var(--input-focus-border); background: rgba(255, 255, 255, 0.08); box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1); }
input:focus + .input-icon { color: var(--primary); }

/* Buttons */
.btn-primary, button[type="submit"] {
    display: inline-flex; justify-content: center; align-items: center; width: 100%;
    padding: 16px; background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white; font-size: 15px; font-weight: 600; border: none; border-radius: 14px;
    cursor: pointer; transition: all 0.3s var(--ease-smooth); position: relative; overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
.btn-primary:hover, button[type="submit"]:hover { transform: translateY(-2px); box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.3); }
.btn-primary:active { transform: scale(0.98); }

.spinner {
    display: none; width: 20px; height: 20px; border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%; border-top-color: #fff; animation: spin 0.8s linear infinite;
}
.loading .spinner { display: block; }
.loading span { display: none; }

/* ===============================
   LAYOUT SYSTEM
   =============================== */

/* --- 1. Auth Pages --- */
.page-auth {
    display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: 20px;
}
.auth-container { width: 100%; max-width: 460px; animation: slideUp 0.6s var(--ease-smooth); }
.auth-header { text-align: center; margin-bottom: 30px; }
.logo-box {
    width: 50px; height: 50px; background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 12px; margin: 0 auto 16px; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 10px 20px -5px rgba(59, 130, 246, 0.4);
}
.logo-box svg, .logo-box i { color: white; font-size: 24px; }

/* --- 2. Dashboard Layout --- */
.page-dashboard {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden; /* Important: Prevents full page scroll */
}

/* Sidebar Styles */
.sidebar {
    width: 260px;
    height: 100%;
    background: rgba(2, 6, 23, 0.95);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    flex-shrink: 0;
    z-index: 50;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-brand {
    font-size: 20px; font-weight: 700; color: white;
    margin-bottom: 30px; padding: 0 10px;
    display: flex; align-items: center; gap: 12px;
}

.nav-menu {
    list-style: none; display: flex; flex-direction: column; gap: 8px;
    overflow-y: auto; height: 100%;
}

.nav-item a {
    display: flex; align-items: center; gap: 12px; padding: 12px 16px;
    color: var(--text-muted); text-decoration: none; border-radius: 12px;
    transition: all 0.2s var(--ease-smooth); font-size: 14px; font-weight: 500;
}
.nav-item a:hover { background: rgba(255, 255, 255, 0.05); color: white; }
.nav-item a.active {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.15), transparent);
    color: var(--primary); border-left: 3px solid var(--primary);
}
.nav-item a i { width: 20px; text-align: center; }

/* Main Content Area */
.main-content {
    flex: 1;
    height: 100%;
    overflow-y: auto; /* Scroll ONLY here */
    padding: 30px;
    position: relative;
    width: 100%;
}

.top-bar {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px;
}
.page-title { font-size: 24px; font-weight: 600; color: white; }

/* Mobile Menu Toggle (Default Hidden on Desktop) */
.mobile-toggle {
    display: none; /* Desktop */
    background: none; border: none;
    color: white; font-size: 24px; cursor: pointer; padding: 5px;
}

/* --- 3. Profile Dropdown --- */
.user-profile-container { position: relative; }

.profile-dropdown {
    position: absolute;
    top: 50px; right: 0;
    width: 220px;
    background: #0F172A;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 8px;
    box-shadow: 0 20px 50px -10px rgba(0,0,0,0.5);
    opacity: 0; visibility: hidden; transform: translateY(-10px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
}

.profile-dropdown.active {
    opacity: 1; visibility: visible; transform: translateY(0);
}

.dropdown-item {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px;
    color: #94A3B8; text-decoration: none;
    font-size: 13px; font-weight: 500;
    border-radius: 10px;
    transition: 0.2s;
}
.dropdown-item:hover { background: rgba(255,255,255,0.05); color: white; }
.dropdown-item.danger:hover { background: rgba(239, 68, 68, 0.1); color: #F87171; }


/* ===============================
   DASHBOARD WIDGETS
   =============================== */

/* Stats Grid */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px; margin-bottom: 30px;
}
.stat-card {
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    padding: 24px; border-radius: 20px; display: flex; align-items: center; gap: 20px;
    transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-5px); border-color: rgba(255,255,255,0.15); }
.stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    background: rgba(59, 130, 246, 0.1); display: flex; align-items: center; justify-content: center;
    color: var(--primary); font-size: 20px;
}
.stat-info h3 { font-size: 24px; font-weight: 700; margin-bottom: 4px; color: white; }
.stat-info p { font-size: 13px; color: var(--text-muted); }

/* Tables - Mobile Scroll Fixed */
.table-container {
    background: var(--glass-bg); 
    border: 1px solid var(--glass-border);
    border-radius: 20px; 
    overflow-x: auto; /* Required for swipe */
    -webkit-overflow-scrolling: touch; /* Smooth swipe on iPhone */
    padding-bottom: 10px; /* Space for scrollbar */
}
table { 
    width: 100%; 
    border-collapse: collapse; 
    min-width: 700px; /* Forces table to be wide enough to need scrolling on mobile */
}
th {
    text-align: left; padding: 18px 24px; color: var(--text-muted); font-size: 12px;
    font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
    border-bottom: 1px solid var(--glass-border); background: rgba(0,0,0,0.2);
}
td { padding: 16px 24px; border-bottom: 1px solid var(--glass-border); font-size: 14px; color: white; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }

.badge { padding: 6px 12px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge.success { background: rgba(16, 185, 129, 0.2); color: #34D399; }
.badge.warning { background: rgba(245, 158, 11, 0.2); color: #FBBF24; }
.badge.danger { background: rgba(239, 68, 68, 0.2); color: #F87171; }

/* ===============================
   RESPONSIVE (Mobile Fixes)
   =============================== */
@media (max-width: 768px) {
    
    /* 1. Show Menu Button */
    .mobile-toggle { display: block; }

    /* 2. Mobile Sidebar - OFF CANVAS */
    .sidebar {
        position: fixed;
        left: -100%; /* Hide completely */
        top: 0; bottom: 0;
        width: 260px;
        /* Use Solid Color on mobile to prevent blur glitches */
        background: #020617; 
        border-right: 1px solid #1E293B;
        box-shadow: 20px 0 50px rgba(0,0,0,0.5);
        display: flex !important; /* Force display */
    }
    
    .sidebar.active {
        left: 0; /* Slide in */
    }

    .main-content { padding: 20px; width: 100%; }
    .stats-grid { grid-template-columns: 1fr; }
    
    /* Overlay for mobile sidebar */
    .overlay {
        position: fixed; top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
        z-index: 40; display: none;
    }
    .overlay.active { display: block; }
}

/* Utilities */
.toast-container { position: fixed; top: 24px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { background: rgba(15, 23, 42, 0.95); border: 1px solid rgba(255,255,255,0.1); padding: 12px 20px; border-radius: 50px; font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 10px; opacity: 0; transition: 0.4s; }
.toast.show { opacity: 1; }
.toast.error { border-color: #EF4444; } .toast.error svg { color: #EF4444; }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
