/* -------------------------------------------------------------
 * 1. ROOT VARIABLES & THEME (Premium Dark Mode with Forest Green & Amber Gold)
 * ------------------------------------------------------------- */
:root {
    --bg-main: #0a0d0b; /* Ultra-dark, premium forest-black canvas */
    --bg-sidebar: #070908;
    --bg-surface: rgba(22, 28, 24, 0.7); /* Translucent glass cards */
    --bg-surface-opaque: #161c18;
    --border-color: rgba(255, 255, 255, 0.07);
    --border-color-glow: rgba(38, 191, 100, 0.2);
    
    --primary: #1b8a47; /* Rich forest green */
    --primary-glow: rgba(27, 138, 71, 0.15);
    --primary-hover: #26bf64;
    
    --accent: #d48200; /* Amber gold */
    --accent-glow: rgba(212, 130, 0, 0.2);
    
    --military-red: #b81d18;
    --military-red-glow: rgba(184, 29, 24, 0.15);
    
    --text-primary: #ffffff; /* Sharp white text */
    --text-secondary: #a8bdae; /* Muted greenish-gray text */
    --text-muted: #627267;
    
    --card-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    --glow-shadow: 0 4px 20px rgba(38, 191, 100, 0.15);
    
    --font-sans: 'Be Vietnam Pro', 'Plus Jakarta Sans', sans-serif;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* -------------------------------------------------------------
 * 2. CORE RESET & BASE STYLES
 * ------------------------------------------------------------- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.6;
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* -------------------------------------------------------------
 * 3. BUTTONS & UTILITIES
 * ------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    outline: none;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--glow-shadow);
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.btn-accent {
    background: var(--accent);
    color: #000;
}
.btn-accent:hover {
    background: #ff9d00;
    transform: translateY(-2px);
}

.btn-red {
    background: var(--military-red);
    color: #fff;
}
.btn-red:hover {
    background: #e6231c;
    transform: translateY(-2px);
}

.btn-block {
    display: flex;
    width: 100%;
}

/* Glow Background Shapes */
body::before {
    content: '';
    position: fixed;
    top: -10%;
    right: -10%;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: rgba(27, 138, 71, 0.08);
    filter: blur(120px);
    z-index: -1;
    pointer-events: none;
}

body::after {
    content: '';
    position: fixed;
    bottom: -10%;
    left: -10%;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: rgba(212, 130, 0, 0.05);
    filter: blur(120px);
    z-index: -1;
    pointer-events: none;
}

/* -------------------------------------------------------------
 * 4. LOGIN INTERFACE (Glassmorphism Modal)
 * ------------------------------------------------------------- */
.login-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, #0f1612 0%, #050706 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

.login-card {
    background: rgba(22, 28, 24, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color-glow);
    padding: 40px;
    border-radius: 16px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.6);
    animation: fadeInUp 0.5s ease;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo {
    height: 64px;
    margin-bottom: 15px;
}

.login-header h2 {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    color: #fff;
    margin-bottom: 5px;
}

.login-header p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    padding: 12px 16px;
    border-radius: 8px;
    color: #fff;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    transition: var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(38, 191, 100, 0.15);
    background: rgba(0, 0, 0, 0.5);
}

.login-hint {
    background: rgba(212, 130, 0, 0.08);
    border: 1px solid rgba(212, 130, 0, 0.15);
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.8rem;
    color: #ffb84d;
    margin-bottom: 25px;
    line-height: 1.4;
}

.btn-login {
    width: 100%;
    padding: 14px;
    font-size: 0.95rem;
    background: var(--primary);
    color: #fff;
}
.btn-login:hover {
    background: var(--primary-hover);
}

/* -------------------------------------------------------------
 * 5. CRM DASHBOARD LAYOUT (Sidebar + Main)
 * ------------------------------------------------------------- */
.crm-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.crm-sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: var(--transition);
    position: relative;
    z-index: 100;
}

.sidebar-brand {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-brand img {
    height: 40px;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: 0.02em;
    color: #fff;
}

.brand-subtitle {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    font-weight: 700;
}

.sidebar-nav {
    flex-grow: 1;
    padding: 20px 14px;
}

.sidebar-nav ul {
    list-style: none;
}

.nav-item {
    margin-bottom: 8px;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.92rem;
    font-weight: 550;
    color: var(--text-secondary);
    transition: var(--transition);
}

.nav-item a i {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
}

.nav-item:hover a,
.nav-item.active a {
    color: #fff;
    background: rgba(255, 255, 255, 0.03);
}

.nav-item.active a {
    background: var(--primary-glow);
    border: 1px solid var(--border-color-glow);
}

.nav-item.active a i {
    color: var(--primary-hover);
}

.badge-count {
    margin-left: auto;
    background: var(--primary);
    color: #fff;
    font-size: 0.72rem;
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 700;
}

.badge-count.count-gold {
    background: var(--accent);
    color: #000;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0,0,0,0.15);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    font-size: 2.2rem;
    color: var(--text-muted);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
}

.user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.btn-logout {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-logout:hover {
    color: var(--military-red);
}

/* -------------------------------------------------------------
 * 6. TOPBAR & MAIN CONTENT PANELS
 * ------------------------------------------------------------- */
.crm-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
}

.crm-topbar {
    padding: 16px 30px;
    background: rgba(10, 13, 11, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.sidebar-toggle-btn {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.25rem;
    cursor: pointer;
}

.crm-topbar h1 {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.btn-home {
    font-size: 0.8rem;
    padding: 8px 14px;
}

.system-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-indicator.online {
    background: #26bf64;
    box-shadow: 0 0 8px #26bf64;
}

/* Sections management */
.crm-section {
    display: none;
    padding: 30px;
    flex-grow: 1;
    animation: fadeIn 0.4s ease;
}

.crm-section.active {
    display: block;
}

/* -------------------------------------------------------------
 * 7. SECTION 1: OVERVIEW DASHBOARD
 * ------------------------------------------------------------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-surface);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    padding: 22px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 18px;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-color-glow);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.bg-primary-glow { background: rgba(38, 191, 100, 0.1); }
.bg-gold-glow { background: rgba(212, 130, 0, 0.1); }
.bg-red-glow { background: rgba(184, 29, 24, 0.1); }
.bg-blue-glow { background: rgba(0, 119, 212, 0.1); }

.text-primary { color: var(--primary-hover); }
.text-gold { color: #ffb84d; }
.text-red { color: #ff4d4d; }
.text-blue { color: #4dabff; }

.stat-data {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.stat-value {
    font-size: 1.65rem;
    font-weight: 800;
    color: #fff;
    margin: 4px 0;
}

.stat-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.stat-desc i {
    margin-right: 3px;
}

/* Charts & Lists layout */
.content-grid {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 30px;
}

.card {
    background: var(--bg-surface);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body {
    padding: 24px;
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Recent Leads List styling */
.recent-leads-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.recent-lead-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border-radius: 8px;
    background: rgba(255,255,255,0.015);
    border: 1px solid rgba(255,255,255,0.02);
}

.recent-lead-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.recent-lead-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: #fff;
}

.recent-lead-course {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.recent-lead-meta {
    text-align: right;
}

.recent-lead-payment {
    display: inline-block;
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(38,191,100,0.1);
    color: #26bf64;
    font-weight: 600;
    margin-bottom: 4px;
}

.recent-lead-payment.installments {
    background: rgba(212, 130, 0, 0.1);
    color: #ffb84d;
}

.recent-lead-time {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* -------------------------------------------------------------
 * 8. SECTIONS ACTIONS BAR (SEARCH + CRUD BUTTONS)
 * ------------------------------------------------------------- */
.section-actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 24px;
}

.search-box {
    position: relative;
    width: 100%;
    max-width: 400px;
}

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

.search-box input {
    width: 100%;
    padding: 11px 16px 11px 40px;
    background: rgba(0,0,0,0.25);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: #fff;
    font-family: var(--font-sans);
    font-size: 0.88rem;
    outline: none;
    transition: var(--transition);
}

.search-box input:focus {
    border-color: var(--primary);
    background: rgba(0,0,0,0.4);
}

.action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* -------------------------------------------------------------
 * 9. DATA TABLES (CRM TABLES)
 * ------------------------------------------------------------- */
.table-wrapper {
    overflow-x: auto;
    width: 100%;
}

.crm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    text-align: left;
}

.crm-table th {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.crm-table td {
    padding: 14px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    vertical-align: middle;
}

.crm-table tbody tr {
    transition: var(--transition);
}

.crm-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.015);
}

/* Progress bar inside table */
.table-progress-box {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 120px;
}

.table-progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
}

.table-progress-bar-container {
    height: 5px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
}

.table-progress-bar-fill {
    height: 100%;
    background: var(--primary-hover);
    border-radius: 3px;
}

.table-progress-bar-fill.warning {
    background: var(--accent);
}

/* Badges inside table */
.crm-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

.badge-info { background: rgba(0, 119, 212, 0.15); color: #4dabff; }
.badge-warning { background: rgba(212, 130, 0, 0.15); color: #ffb84d; }
.badge-success { background: rgba(38, 191, 100, 0.15); color: #26bf64; }
.badge-danger { background: rgba(184, 29, 24, 0.15); color: #ff4d4d; }

/* Table action buttons */
.row-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    color: #fff;
}

.btn-icon.edit:hover {
    background: rgba(212, 130, 0, 0.15);
    border-color: rgba(212, 130, 0, 0.3);
    color: #ffb84d;
}

.btn-icon.delete:hover {
    background: rgba(184, 29, 24, 0.15);
    border-color: rgba(184, 29, 24, 0.3);
    color: #ff4d4d;
}

/* empty table indicator */
.empty-table-row {
    text-align: center;
    padding: 30px !important;
    color: var(--text-muted);
}

/* -------------------------------------------------------------
 * 10. SYSTEM SETTINGS LAYOUT
 * ------------------------------------------------------------- */
.settings-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 30px;
}

.form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

.download-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.download-actions button {
    justify-content: flex-start;
}

/* -------------------------------------------------------------
 * 11. OVERLAY & MODAL SYSTEM (Glassmorphism Modal Cards)
 * ------------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(5, 7, 6, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.modal-overlay.active {
    display: flex;
}

.modal-card {
    background: var(--bg-surface-opaque);
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 600px;
    border-radius: 12px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.7);
    overflow: hidden;
    animation: fadeInUp 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
}

.modal-close:hover {
    color: #fff;
}

.modal-body {
    padding: 24px;
}

.modal-footer-btns {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* -------------------------------------------------------------
 * 12. TOAST SYSTEM FOR USER NOTIFICATION
 * ------------------------------------------------------------- */
.crm-toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--bg-surface-opaque);
    border: 1px solid var(--primary-glow);
    border-left: 4px solid var(--primary-hover);
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    color: #fff;
    font-size: 0.88rem;
    font-weight: 600;
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 10px;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}

.crm-toast.active {
    transform: translateY(0);
    opacity: 1;
}

/* -------------------------------------------------------------
 * 13. ANIMATIONS
 * ------------------------------------------------------------- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* -------------------------------------------------------------
 * 14. RESPONSIVE MEDIA QUERIES (MOBILE SUPPORT)
 * ------------------------------------------------------------- */
@media (max-width: 991px) {
    .crm-sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        height: 100vh;
        box-shadow: 10px 0 30px rgba(0,0,0,0.5);
    }
    
    .crm-sidebar.active {
        left: 0;
    }
    
    .sidebar-toggle-btn {
        display: block;
    }
    
    .content-grid, .settings-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 575px) {
    .crm-topbar {
        padding: 16px 20px;
    }
    
    .crm-section {
        padding: 20px;
    }
    
    .form-row {
        flex-direction: column;
        gap: 15px;
    }
    
    .section-actions-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box {
        max-width: none;
    }
}
