/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
    /* DEFAULT DARK MODE COLORS */
    --primary-bg: #1E232C;
    --card-bg: #29303D;
    --text-primary: #F8F8F8;
    --text-secondary: #AAAAAA;
    --accent-blue: #4A90E2;
    --success-green: #22C55E;
    --danger-red: #ef4444;
    --warning-orange: #f59e0b;
    --border-color: #3A3F4A;
    --input-bg: #2A303D;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--primary-bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding-bottom: 80px; /* Space for bottom nav */
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

/* =========================================
   2. HEADER & TOP NAV
   ========================================= */
.header {
    background: var(--primary-bg);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color 0.3s ease;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* HAMBURGER MENU */
.hamburger {
    width: 24px;
    height: 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
}

.hamburger span {
    width: 100%;
    height: 2px;
    background: var(--text-primary);
    border-radius: 1px;
    transition: background-color 0.3s ease;
}

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

/* ICONS */
.header-icon {
    width: 24px;
    height: 24px;
    color: var(--text-primary);
    cursor: pointer;
    transition: color 0.3s ease;
}

.header-icon:hover {
    color: var(--accent-blue);
}

.currency-selector {
    background: var(--input-bg);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

/* LANGUAGE BUTTON */
.lang-selector-wrapper {
    position: relative;
    margin-right: 5px;
}
#google_translate_element {
    display: none;
}
.custom-lang-btn {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s;
}
.custom-lang-btn:hover {
    border-color: var(--accent-blue);
}

/* =========================================
   3. LEFT SIDEBAR (PROFILE & MENU)
   ========================================= */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1500;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

.sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100%;
    background: var(--card-bg);
    z-index: 2000;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    box-shadow: 4px 0 15px rgba(0,0,0,0.3);
}

.sidebar.active {
    left: 0;
}

/* -- PROFILE HEADER -- */
.sidebar-header {
    position: relative;
    padding: 0;
    background-color: var(--primary-bg);
    border-bottom: 1px solid var(--border-color);
    text-align: center;
    overflow: hidden;
}

.profile-cover {
    height: 100px;
    width: 100%;
    background-size: cover;
    background-position: center;
    background-color: var(--accent-blue);
    position: relative;
}

.profile-cover::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0,0.6) 100%);
}

.profile-content {
    padding: 0 20px 20px 20px;
    margin-top: -40px;
    position: relative;
    z-index: 2;
}

.profile-avatar-img {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 4px solid var(--card-bg);
    background: var(--card-bg);
    object-fit: cover;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin-bottom: 8px;
}

.profile-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.profile-email {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    word-break: break-all;
}

.profile-stats-row {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.p-stat-item { text-align: center; flex: 1; }
.p-stat-value { font-size: 14px; font-weight: 700; color: var(--accent-blue); display: block; }
.p-stat-label { font-size: 10px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }

/* -- NAVIGATION -- */
.sidebar-nav { flex: 1; padding: 20px 0; overflow-y: auto; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.sidebar-link:hover { background: var(--input-bg); color: var(--text-primary); }

.sidebar-link.active {
    background: rgba(74, 144, 226, 0.1);
    color: var(--accent-blue);
    border-left-color: var(--accent-blue);
}

.sidebar-link.logout { color: var(--danger-red); }
.sidebar-footer { padding: 20px; border-top: 1px solid var(--border-color); }


/* =========================================
   4. RIGHT SIDEBAR (NOTIFICATIONS)
   ========================================= */
.notif-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2900;
    opacity: 0; visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(2px);
}

.notif-overlay.active { opacity: 1; visibility: visible; }

.notif-sidebar {
    position: fixed; top: 0; right: -320px;
    width: 300px; height: 100%;
    background: var(--card-bg);
    z-index: 3000;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 1px solid var(--border-color);
    box-shadow: -4px 0 15px rgba(0,0,0,0.3);
    display: flex; flex-direction: column;
}

.notif-sidebar.active { right: 0; }

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

.notif-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.notif-close { background: none; border: none; color: var(--text-secondary); cursor: pointer; font-size: 24px; }

.notif-content { flex: 1; overflow-y: auto; }

/* Notification Items */
.notif-item {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}
.notif-item:hover { background: var(--input-bg); }
.notif-item-title { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.notif-item-msg { font-size: 12px; color: var(--text-secondary); line-height: 1.4; }
.notif-item-time { font-size: 10px; color: var(--accent-blue); margin-top: 6px; opacity: 0.8; }


/* =========================================
   5. TELEGRAM FLOATING WIDGET
   ========================================= */
.telegram-fab {
    position: fixed;
    bottom: 85px; /* Above footer nav */
    right: 20px;
    width: 50px; height: 50px;
    background: #0088cc;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 136, 204, 0.4);
    cursor: pointer;
    z-index: 9000;
    transition: transform 0.3s ease;
    animation: pulse 2s infinite;
}
.telegram-fab:hover { transform: scale(1.1); }
.telegram-fab svg { width: 24px; height: 24px; color: white; margin-right: 2px; margin-top: 2px; }

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(0, 136, 204, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(0, 136, 204, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 136, 204, 0); }
}

/* Chat Popup */
.tg-popup {
    position: fixed; bottom: 145px; right: 20px;
    width: 300px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    z-index: 9001;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}
.tg-popup.active { display: flex; }

.tg-header { background: #0088cc; padding: 15px; color: white; display: flex; align-items: center; gap: 10px; }
.tg-avatar { width: 32px; height: 32px; background: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #0088cc; font-weight: bold; font-size: 14px; }
.tg-info h4 { margin: 0; font-size: 13px; }
.tg-info p { margin: 0; font-size: 10px; opacity: 0.9; }
.tg-close { margin-left: auto; background: none; border: none; color: white; font-size: 20px; cursor: pointer; }

.tg-body { padding: 20px; }
.tg-textarea { width: 100%; background: var(--input-bg); border: 1px solid var(--border-color); border-radius: 8px; padding: 10px; color: var(--text-primary); font-family: inherit; resize: none; margin-bottom: 15px; }
.tg-btn { width: 100%; background: #0088cc; color: white; border: none; padding: 10px; border-radius: 8px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; }
.tg-btn:hover { background: #0077b3; }


/* =========================================
   6. MAIN CONTENT & FORMS
   ========================================= */
.main-content { padding: 24px 16px; max-width: 800px; margin: 0 auto; }
.content-section { margin-bottom: 32px; }
.section-title { font-size: 16px; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.section-description { font-size: 14px; color: var(--text-secondary); margin-bottom: 16px; }

.form-group { margin-bottom: 24px; }
.input-field {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.3s ease;
}

select.input-field {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23AAAAAA' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
}

.input-field:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.purchase-btn {
    width: 100%;
    height: 56px;
    background: linear-gradient(135deg, var(--accent-blue), #357abd);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.purchase-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(74, 144, 226, 0.4); }
.purchase-btn:disabled { background: var(--input-bg); color: var(--text-secondary); cursor: not-allowed; box-shadow: none; }
.purchase-note { font-size: 12px; color: var(--text-secondary); text-align: center; margin-top: 8px; }

/* =========================================
   7. DASHBOARD WIDGETS
   ========================================= */
.status-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin: 24px 0;
    text-align: center;
}
.status-header { font-size: 16px; font-weight: 600; color: var(--text-primary); margin-bottom: 16px; }
.status-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.status-value { font-size: 24px; font-weight: 700; color: var(--accent-blue); margin-bottom: 4px; }
.status-label { font-size: 12px; color: var(--text-secondary); }

.order-summary {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin: 24px 0;
}
.summary-title { font-size: 18px; font-weight: 600; color: var(--text-primary); margin-bottom: 16px; }
.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}
.summary-item:last-child { border-bottom: none; margin-top: 8px; padding-top: 16px; }
.summary-label { font-size: 14px; color: var(--text-secondary); display: flex; align-items: center; }
.summary-value { font-size: 14px; color: var(--text-primary); font-weight: 500; }
.summary-total { font-size: 24px; font-weight: 700; color: var(--accent-blue); }

/* =========================================
   8. PROXY CARDS
   ========================================= */
.proxy-query-controls {
    background: var(--card-bg);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
}
.query-controls-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.query-label { font-size: 12px; color: var(--text-secondary); display: block; margin-bottom: 5px;}

.proxy-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
}
.proxy-header { display: flex; justify-content: space-between; margin-bottom: 12px; }
.proxy-ip { font-family: 'Courier New', monospace; font-weight: 600; }
.proxy-status { padding: 2px 8px; border-radius: 12px; font-size: 11px; text-transform: uppercase; }
.status-online { background: rgba(34, 197, 94, 0.2); color: var(--success-green); }
.status-offline { background: rgba(239, 68, 68, 0.2); color: var(--danger-red); }

.proxy-details-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px; font-size: 12px; color: var(--text-secondary); margin-bottom: 15px;
}
.detail-full { grid-column: span 2; }
.detail-value { color: var(--text-primary); font-family: monospace; word-break: break-all; }

.proxy-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.action-btn {
    padding: 8px; border: none; border-radius: 6px; font-size: 11px; font-weight: 600; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 4px;
}
.btn-copy { background: #4a5568; color: white; grid-column: span 2; }
.btn-renew { background: var(--accent-blue); color: white; }

.proxy-list-empty { text-align: center; padding: 40px 20px; color: var(--text-secondary); }

/* =========================================
   9. AUTH & FOOTER
   ========================================= */
.auth-container {
    max-width: 450px;
    margin: 60px auto;
    background: var(--card-bg);
    padding: 32px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
}
.auth-title { font-size: 24px; font-weight: 700; text-align: center; margin-bottom: 24px; }
.auth-link { display: block; text-align: center; margin-top: 16px; color: var(--text-secondary); font-size: 14px; text-decoration: none; }
.auth-link span { color: var(--accent-blue); font-weight: 600; }

.alert { padding: 12px; border-radius: 8px; margin-bottom: 20px; font-size: 14px; text-align: center; }
.alert-danger { background: rgba(239, 68, 68, 0.2); color: var(--danger-red); border: 1px solid var(--danger-red); }
.alert-success { background: rgba(34, 197, 94, 0.2); color: var(--success-green); border: 1px solid var(--success-green); }

.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--primary-bg);
    border-top: 1px solid var(--border-color);
    display: flex; justify-content: space-around;
    padding: 12px 8px;
    z-index: 1000;
    transition: background-color 0.3s ease;
}

.nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    color: var(--text-secondary); text-decoration: none; font-size: 12px;
    transition: color 0.3s ease;
}
.nav-item:hover, .nav-item.active { color: var(--accent-blue); }
.nav-icon { width: 24px; height: 24px; }

/* =========================================
   10. UTILITIES
   ========================================= */
.hidden { display: none !important; }
.spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    border-top-color: var(--accent-blue);
    animation: spin 1s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slideUp { from { transform: translateY(100px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

#notification { display: none; }
.bg-red { background: var(--danger-red); }
.bg-green { background: var(--success-green); }

@media (max-width: 768px) { .auth-container { margin: 30px 16px; } }

/* =========================================
   11. LIGHT MODE THEME
   ========================================= */
body.light-mode {
    --primary-bg: #F0F2F5;
    --card-bg: #FFFFFF;
    --text-primary: #1E232C;
    --text-secondary: #64748B;
    --input-bg: #F8F9FA;
    --border-color: #E2E8F0;
}

body.light-mode .sidebar-header,
body.light-mode .header,
body.light-mode .sidebar,
body.light-mode .bottom-nav,
body.light-mode .notif-header,
body.light-mode .notif-sidebar,
body.light-mode .tg-popup {
    background: #FFFFFF;
}

body.light-mode .hamburger span { background: #1E232C; }
body.light-mode .sidebar-overlay,
body.light-mode .notif-overlay { background: rgba(0, 0, 0, 0.5); }

body.light-mode .profile-avatar-img {
    border-color: #FFFFFF;
    background: #FFFFFF;
}

@media (max-width: 768px) {
    .content-section > div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
    #trafficChart {
        height: 200px !important;
    }
}

/* =========================================
   14. PREMIUM AUTH LAYOUT
   ========================================= */
.auth-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
    background: var(--primary-bg);
}

/* Left Side (Branding/Art) */
.auth-left {
    flex: 1;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 60px;
    overflow: hidden;
}
.auth-left::before {
    content: '';
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-image: url('https://images.unsplash.com/photo-1550751827-4bd374c3f58b?q=80&w=2070&auto=format&fit=crop');
    background-size: cover;
    background-position: center;
    opacity: 0.3;
    mix-blend-mode: overlay;
}

.auth-brand { position: relative; z-index: 2; font-size: 28px; font-weight: 800; color: white; letter-spacing: 1px; }
.auth-quote { position: relative; z-index: 2; color: rgba(255,255,255,0.8); font-size: 18px; line-height: 1.6; max-width: 400px; }
.auth-quote cite { display: block; margin-top: 15px; font-size: 14px; font-style: normal; color: var(--accent-blue); font-weight: 600; }

/* Right Side (Form) */
.auth-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: var(--card-bg);
    max-width: 600px; /* Limit width on large screens */
}

.auth-box { width: 100%; max-width: 400px; }

/* Google Button */
.btn-google {
    width: 100%;
    height: 50px;
    background: white;
    color: #333;
    border: 1px solid #ddd;
    border-radius: 12px;
    font-weight: 600;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 25px;
}
.btn-google:hover { background: #f8f9fa; transform: translateY(-1px); }
.btn-google img { width: 20px; height: 20px; }

.auth-separator {
    display: flex; align-items: center; margin: 20px 0; color: var(--text-secondary); font-size: 12px; text-transform: uppercase;
}
.auth-separator::before, .auth-separator::after {
    content: ''; flex: 1; height: 1px; background: var(--border-color);
}
.auth-separator span { padding: 0 10px; }

/* Responsive */
@media (max-width: 900px) {
    .auth-left { display: none; }
    .auth-right { max-width: 100%; background: var(--primary-bg); }
}