/* =========================================
   CSS VARIABLES
   ========================================= */
:root {
    --bg-app: #05070a;
    --bg-panel: #0d1117;
    --bg-sidebar: #090c10; /* Slightly darker than panel for depth */
    --border-color: #30363d;
    --text-primary: #ffffff;
    --text-secondary: #8b949e;
    --accent: #0088ff;
    --accent-glow: rgba(0, 136, 255, 0.4);
    --success: #1f58f6;
    --warning: #ffaa00;
    --danger: #ff4444;
}

[data-theme="light"] {
    --bg-app: #f0f2f5;
    --bg-panel: #ffffff;
    --bg-sidebar: #ffffff;
    --border-color: #e4e6eb;
    --text-primary: #050505;
    --text-secondary: #65676b;
}

* { box-sizing: border-box; margin: 0; padding: 0; transition: background-color 0.3s, color 0.3s; }
body { 
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; 
    background-color: var(--bg-app); 
    color: var(--text-primary); 
    height: 100vh; 
    width: 100vw;
    overflow: hidden; /* App-like feel, no body scroll */
}

/* =========================================
   LAYOUT STRUCTURE
   ========================================= */
.app-container { 
    display: flex; 
    height: 100vh; 
    width: 100%;
}

/* SIDEBAR - Fixed Width */
.sidebar { 
    width: 280px; 
    min-width: 280px; /* Forces width */
    background: var(--bg-sidebar); 
    border-right: 1px solid var(--border-color); 
    display: flex; 
    flex-direction: column; 
    padding: 25px; 
    z-index: 50;
    flex-shrink: 0; /* Critical: Prevents sidebar from collapsing */
}

/* MAIN CONTENT - Grow to fill */
.main-content { 
    flex-grow: 1; 
    overflow-y: auto; 
    padding: 40px; 
    position: relative;
    background: var(--bg-app);
}

/* =========================================
   BRANDING: CENTERED & 3D TEXT
   ========================================= */
.brand-header-centered {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    margin-bottom: 45px; padding-top: 10px; position: relative;
}

/* Logo Image Container */
.logo-circle {
    width: 80px; height: 80px;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 15px;
    filter: drop-shadow(0 0 15px rgba(0, 136, 255, 0.2));
}

.brand-logo-img {
    width: 100%; height: 100%; object-fit: contain;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.brand-header-centered:hover .brand-logo-img { transform: scale(1.1) rotate(-5deg); }

/* 3D GRADIENT TEXT */
.brand-name-3d {
    font-size: 2.2rem; font-weight: 900; 
    text-transform: uppercase; letter-spacing: 2px;
    margin: 0 0 10px 0;
    
    /* Gradient Blue Fill */
    background: linear-gradient(180deg, #2af598 0%, #009efd 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    
    /* 3D Drop Shadow Effect */
    filter: drop-shadow(0px 3px 0px rgba(0, 80, 156, 0.8));
    position: relative;
}

.rate-badge-pill {
    background: var(--success); color: #000;
    font-weight: 800; font-size: 0.9rem;
    padding: 6px 18px; border-radius: 20px;
    box-shadow: 0 0 15px rgba(0, 230, 118, 0.3);
    border: 2px solid rgba(255,255,255,0.1);
}

/* =========================================
   NAVIGATION
   ========================================= */
.nav-links { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.nav-item { 
    background: transparent; border: none; color: var(--text-secondary); 
    padding: 14px 18px; text-align: left; font-size: 0.95rem; cursor: pointer; 
    border-radius: 12px; display: flex; align-items: center; gap: 14px; font-weight: 600;
    transition: all 0.2s;
}
.nav-item:hover { background: rgba(0, 136, 255, 0.08); color: var(--accent); }
.nav-item.active { background: rgba(0, 136, 255, 0.15); color: var(--accent); }

.sidebar-footer { border-top: 1px solid var(--border-color); padding-top: 25px; display: flex; align-items: center; justify-content: space-between; }
.user-mini-profile { display: flex; align-items: center; gap: 12px; }
.avatar-circle { width: 40px; height: 40px; background: linear-gradient(135deg, var(--accent), #0055aa); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.user-info { display: flex; flex-direction: column; }
.u-name { font-size: 0.95rem; font-weight: 700; color: var(--text-primary); }
.u-role { font-size: 0.75rem; color: var(--text-secondary); }

/* =========================================
   TOP BAR & BUTTONS
   ========================================= */
.top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.top-left h2 { font-size: 1.8rem; font-weight: 800; letter-spacing: -0.5px; }
.top-actions { display: flex; align-items: center; gap: 15px; }

/* START TASK BUTTON (With Loader) */
.btn-start-task {
    background: var(--success); color: #000; border: none; 
    height: 48px; padding: 0 30px; border-radius: 30px;
    font-weight: 800; cursor: pointer; letter-spacing: 0.5px;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    box-shadow: 0 0 20px rgba(0, 230, 118, 0.3);
    transition: 0.2s; min-width: 170px;
}
.btn-start-task:hover { transform: scale(1.05); box-shadow: 0 0 30px rgba(0, 230, 118, 0.5); }

/* Spinner Animation */
.loader-spinner {
    width: 20px; height: 20px;
    border: 3px solid rgba(0,0,0,0.2); border-top-color: #000;
    border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn { 
    background: var(--bg-panel); border: 1px solid var(--border-color); color: var(--text-secondary); 
    width: 48px; height: 48px; border-radius: 50%; cursor: pointer; 
    display: flex; align-items: center; justify-content: center; transition: 0.2s; position: relative; font-size: 1.1rem;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(0,136,255,0.05); }
.badge { position: absolute; top: -2px; right: -2px; background: var(--danger); color: white; font-size: 0.7rem; padding: 2px 6px; border-radius: 10px; border: 2px solid var(--bg-app); font-weight: bold; }

/* =========================================
   DASHBOARD CARDS
   ========================================= */
.view-section { display: none; animation: fadeIn 0.4s ease; }
.view-section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.welcome-banner { 
    background: linear-gradient(135deg, rgba(0, 136, 255, 0.15) 0%, rgba(5, 7, 10, 0) 100%); 
    border: 1px solid rgba(0,136,255,0.3); border-radius: 20px; padding: 35px; margin-bottom: 35px; 
    position: relative; overflow: hidden;
}
.welcome-banner::before { content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%; background: var(--accent); }
.welcome-text h1 { font-size: 2rem; margin-bottom: 8px; color: var(--text-primary); }
.welcome-text p { color: var(--text-secondary); font-size: 1.05rem; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 25px; margin-bottom: 35px; }
.stat-card { 
    background: var(--bg-panel); border: 1px solid var(--border-color); padding: 25px; 
    border-radius: 16px; display: flex; align-items: center; gap: 20px; 
    transition: transform 0.2s, border-color 0.2s;
}
.stat-card:hover { transform: translateY(-5px); border-color: var(--accent); }
.stat-icon { width: 55px; height: 55px; background: rgba(0, 136, 255, 0.1); color: var(--accent); border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; }
.stat-info .label { font-size: 0.9rem; color: var(--text-secondary); display: block; margin-bottom: 5px; }
.stat-info .value { font-size: 1.6rem; font-weight: 800; color: var(--text-primary); }

.dashboard-split { display: grid; grid-template-columns: 2fr 1.2fr; gap: 25px; }
@media(max-width: 1200px) { .dashboard-split { grid-template-columns: 1fr; } }

.panel { background: var(--bg-panel); border: 1px solid var(--border-color); border-radius: 16px; padding: 30px; }
.panel-head-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.panel h3 { font-size: 1.2rem; color: var(--text-primary); font-weight: 700; margin: 0; }
.chart-container { position: relative; height: 320px; width: 100%; }

.payment-display { display: flex; align-items: center; gap: 15px; background: rgba(255,255,255,0.03); padding: 20px; border-radius: 12px; margin-top: 15px; border: 1px solid var(--border-color); }
.pm-logo-img { height: 40px; width: auto; max-width: 100px; object-fit: contain; } 
.p-details { display: flex; flex-direction: column; flex: 1; }
.p-type { font-weight: 700; font-size: 1rem; color: var(--text-primary); }
.p-addr { font-size: 0.85rem; color: var(--text-secondary); font-family: monospace; }
.status-badge { font-size: 0.75rem; padding: 4px 10px; border-radius: 6px; font-weight: 700; text-transform: uppercase; }
.status-active { background: rgba(0, 230, 118, 0.15); color: var(--success); }

.referral-box { 
    margin-top: 15px; background: #05070a; border: 1px dashed var(--border-color); 
    padding: 20px; border-radius: 12px; position: relative; cursor: pointer; overflow: hidden; 
    display: flex; justify-content: space-between; align-items: center; transition: 0.2s;
}
.referral-box:hover { border-color: var(--accent); }
.blur-overlay { 
    position: absolute; inset: 0; background: rgba(13, 17, 23, 0.95); backdrop-filter: blur(8px); 
    display: flex; align-items: center; justify-content: center; color: var(--text-secondary); 
    font-size: 0.95rem; gap: 10px; transition: 0.3s; z-index: 2; 
}
.referral-box.revealed .blur-overlay { opacity: 0; pointer-events: none; }
.actual-code { font-family: monospace; font-size: 1.2rem; color: var(--accent); letter-spacing: 2px; font-weight: 700; z-index: 1; }

/* Tables */
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; margin-top: 10px; }
.data-table th { text-align: left; color: var(--text-secondary); font-size: 0.85rem; padding: 15px; border-bottom: 1px solid var(--border-color); text-transform: uppercase; font-weight: 700; }
.data-table td { padding: 18px 15px; border-bottom: 1px solid rgba(255,255,255,0.03); font-size: 0.95rem; color: var(--text-primary); }
.data-table tr:hover { background: rgba(255,255,255,0.02); }
.empty-state { padding: 50px; text-align: center; color: var(--text-secondary); font-style: italic; border: 2px dashed var(--border-color); border-radius: 12px; margin-top: 20px; background: rgba(255,255,255,0.01); }

.btn-link { background: none; border: none; color: var(--accent); cursor: pointer; text-decoration: underline; font-size: 0.9rem; }
.hidden { display: none !important; }

/* =========================================
   AUTH MODAL STYLING
   ========================================= */
.auth-overlay { 
    position: fixed; inset: 0; background: rgba(5, 7, 10, 0.98); 
    z-index: 9999; display: flex; align-items: center; justify-content: center; 
    backdrop-filter: blur(15px); opacity: 0; visibility: hidden; transition: 0.5s; 
}
.auth-overlay.active { opacity: 1; visibility: visible; }

.auth-card { 
    background: var(--bg-panel); border: 1px solid var(--border-color); 
    padding: 40px; border-radius: 24px; width: 90%; max-width: 420px; 
    text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.5); 
    transform: translateY(30px); animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards; 
}
@keyframes slideUp { to { transform: translateY(0); } }

.auth-logo { height: 80px; width: auto; margin-bottom: 20px; filter: drop-shadow(0 0 10px rgba(0, 136, 255, 0.3)); }
.auth-card h2 { font-size: 1.8rem; margin-bottom: 10px; color: var(--text-primary); }
.auth-card p { margin-bottom: 25px; line-height: 1.5; color: var(--text-secondary); }

.auth-form { display: flex; flex-direction: column; gap: 15px; }
.input-group { position: relative; }
.input-group input { width: 100%; padding: 14px 14px 14px 45px; background: rgba(255,255,255,0.03); border: 1px solid var(--border-color); border-radius: 12px; color: white; outline: none; }
.input-group input:focus { border-color: var(--accent); background: rgba(0,136,255,0.05); }
.input-group i { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--text-secondary); }

.btn-login { 
    background: linear-gradient(135deg, var(--accent) 0%, #0066cc 100%); 
    color: white; border: none; padding: 14px; border-radius: 12px; 
    font-weight: 700; cursor: pointer; margin-top: 10px; transition: 0.2s;
}
.btn-login:hover { transform: translateY(-2px); box-shadow: 0 5px 20px var(--accent-glow); }
.error-msg { color: var(--danger); font-size: 0.85rem; min-height: 20px; margin-top: 10px; }

/* =========================================
   ADMIN PANEL STYLING
   ========================================= */
.admin-panel { 
    position: fixed; top: 0; right: -450px; width: 420px; height: 100vh; 
    background: rgba(13, 17, 23, 0.98); backdrop-filter: blur(20px); 
    border-left: 1px solid var(--border-color); z-index: 10000; 
    transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1); 
    display: flex; flex-direction: column; box-shadow: -20px 0 50px rgba(0,0,0,0.6); 
}
.admin-panel.open { right: 0; }
.admin-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 9999; display: none; backdrop-filter: blur(2px); }
.admin-overlay.open { display: block; }

.admin-header { padding: 25px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; background: rgba(255,255,255,0.02); }
.close-admin { background: none; border: none; color: white; font-size: 1.8rem; cursor: pointer; transition: 0.2s; }
.close-admin:hover { color: var(--danger); transform: rotate(90deg); }

.admin-content { flex: 1; overflow-y: auto; padding: 25px; display: flex; flex-direction: column; gap: 20px; padding-bottom: 100px; }
.admin-group { display: flex; flex-direction: column; gap: 8px; }
.admin-group label { font-size: 0.75rem; color: var(--text-secondary); text-transform: uppercase; font-weight: 800; letter-spacing: 0.5px; }
.admin-group input, .admin-group select { background: rgba(0,0,0,0.3); border: 1px solid var(--border-color); padding: 12px; border-radius: 8px; color: white; outline: none; width: 100%; font-family: monospace; }
.admin-group input:focus { border-color: var(--accent); background: rgba(0,136,255,0.05); }

.chart-input-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day-input { display: flex; flex-direction: column; align-items: center; }
.day-input label { font-size: 0.65rem; color: var(--accent); margin-bottom: 4px; font-weight: 700; }
.day-input input { padding: 8px 2px; text-align: center; }

.admin-divider { border: 0; border-top: 1px solid var(--border-color); margin: 10px 0; opacity: 0.5; }

.admin-action-box { background: rgba(0, 136, 255, 0.04); border: 1px solid rgba(0, 136, 255, 0.15); padding: 20px; border-radius: 12px; }
.admin-action-box h4 { margin-bottom: 15px; font-size: 0.9rem; color: var(--accent); text-transform: uppercase; font-weight: 800; }
.row-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 15px; }

.btn-row { display: flex; gap: 10px; }
.btn-admin-action { flex: 1; padding: 10px; border-radius: 6px; cursor: pointer; background: var(--bg-panel); border: 1px solid var(--accent); color: var(--accent); font-weight: 700; transition: 0.2s; }
.btn-admin-action:hover { background: var(--accent); color: white; }
.btn-admin-danger { flex: 1; padding: 10px; border-radius: 6px; cursor: pointer; background: var(--bg-panel); border: 1px solid var(--danger); color: var(--danger); font-weight: 700; transition: 0.2s; }
.btn-admin-danger:hover { background: var(--danger); color: white; }

.sticky-bottom { position: absolute; bottom: 0; left: 0; right: 0; padding: 25px; background: var(--bg-panel); border-top: 1px solid var(--border-color); display: flex; gap: 15px; box-shadow: 0 -10px 30px rgba(0,0,0,0.5); }
.btn-admin-save { flex: 2; background: var(--success); color: black; border: none; padding: 14px; border-radius: 8px; font-weight: 800; cursor: pointer; transition: 0.2s; letter-spacing: 0.5px; }
.btn-admin-save:hover { filter: brightness(1.1); transform: translateY(-2px); }
.btn-admin-reset { flex: 1; background: #222; color: #fff; border: 1px solid #444; border-radius: 8px; cursor: pointer; font-weight: 600; transition: 0.2s; }
.btn-admin-reset:hover { background: var(--danger); border-color: var(--danger); }