/* Base Variables */
:root {
    /* Light Theme (default fallback) */
    --bg-main: #FFF4E6;
    --bg-card: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #3A2C22;
    --primary-color: #FF3C00;
    --primary-hover: #FFA452;
    --sidebar-bg: #FFF4E6;
    
    /* Semantic Colors */
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;

    /* Chart Colors */
    --chart-1: #FF3C00;
    --chart-2: #FFA452;
    --chart-3: #10b981;
    --chart-4: #f43f5e;
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-main: #18261E;
    --bg-card: #2F4B3C;
    --text-primary: #FFF4E6;
    --text-secondary: rgba(255, 244, 230, 0.7);
    --border-color: #3A2C22;
    --primary-color: #FF3C00;
    --primary-hover: #FFA452;
    --sidebar-bg: #18261E;
    
    /* Semantic Colors */
    --success: #10b981;
    --danger: #ef4444;
    
    /* Glow Effects */
    --glow-primary: rgba(255, 60, 0, 0.4);
    --glass-border: #3A2C22;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

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

ul {
    list-style: none;
}

/* Utility */
.positive { color: var(--success) !important; }
.negative { color: var(--danger) !important; }

/* Theme Toggle */
.theme-toggle {
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    font-size: 1.2rem;
    color: var(--text-secondary);
    backdrop-filter: blur(10px);
}

.theme-toggle:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: 0 0 10px var(--glow-primary);
}

/* ================== LOGIN PAGE ================== */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, rgba(255, 60, 0, 0.15) 0%, transparent 40%),
                radial-gradient(circle at bottom right, rgba(255, 164, 82, 0.15) 0%, transparent 40%),
                var(--bg-main);
}

.login-body .theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
    animation: fadeUp 0.6s ease-out forwards;
}

.login-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    padding: 40px;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.logo-mark {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    box-shadow: 0 4px 20px var(--glow-primary);
}

.logo-container h2 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 30px;
}

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

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

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper i {
    position: absolute;
    left: 16px;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.input-wrapper input {
    width: 100%;
    padding: 14px 16px 14px 44px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s ease;
}

[data-theme="light"] .input-wrapper input {
    background: #f8fafc;
}

.input-wrapper input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--glow-primary);
}

.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    font-size: 0.85rem;
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    cursor: pointer;
}

.forgot-password {
    color: var(--primary-color);
    font-weight: 600;
}

.forgot-password:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--glow-primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--glow-primary);
}

.btn-secondary {
    padding: 14px;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.btn-small {
    padding: 10px 16px;
    font-size: 0.85rem;
}

.dev-links {
    margin-top: 20px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.dev-links a {
    color: var(--primary-color);
    margin: 0 5px;
}

/* ================== DASHBOARD LAYOUT ================== */
.dashboard-body {
    display: flex;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

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

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 800;
}

.sidebar-nav {
    padding: 24px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    transition: all 0.2s ease;
}

.nav-item i {
    font-size: 1.25rem;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

[data-theme="light"] .nav-item:hover {
    background: #f1f5f9;
}

.nav-item.active {
    background: rgba(255, 60, 0, 0.1);
    color: var(--primary-color);
}

.sidebar-footer {
    padding: 24px 16px;
    border-top: 1px solid var(--border-color);
}

.text-danger {
    color: var(--danger);
}
.text-danger:hover {
    background: rgba(239, 68, 68, 0.1) !important;
    color: var(--danger) !important;
}

/* Main Content */
.main-content {
    flex: 1;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.topbar {
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    background: rgba(47, 75, 60, 0.8);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 5;
}

[data-theme="light"] .topbar {
    background: rgba(244, 246, 248, 0.8);
}

.topbar-left h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.topbar-left p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

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

.date-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

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

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.client-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1rem;
}

.user-info strong {
    display: block;
    font-size: 0.95rem;
}

.user-info span {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.content-wrapper {
    padding: 40px;
    flex: 1;
}

/* KPIs */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    padding: 24px;
    border-radius: 20px;
    backdrop-filter: blur(20px);
    box-shadow: 0 10px 30px -10px rgba(0,0,0,0.2);
    transition: transform 0.3s ease;
}

.kpi-card:hover {
    transform: translateY(-5px);
    border-color: var(--border-color);
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.icon-blue { background: rgba(255, 60, 0, 0.1); color: var(--primary-color); }
.icon-purple { background: rgba(255, 164, 82, 0.1); color: var(--primary-hover); }
.icon-green { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.icon-orange { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }

.kpi-trend {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.05);
}

.kpi-card h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 4px;
    letter-spacing: -1px;
}

.kpi-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Charts Area */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    padding: 24px;
    border-radius: 20px;
    backdrop-filter: blur(20px);
}

.chart-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 24px;
}

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

/* ================== ADMIN PANEL ================== */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
}

.section-header .btn-primary {
    width: auto;
    padding: 10px 20px;
}

.table-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 0;
    overflow: hidden;
}

.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 16px 24px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .data-table th {
    background: #f8fafc;
}

.data-table td {
    font-size: 0.95rem;
    color: var(--text-primary);
}

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

[data-theme="light"] .data-table tbody tr:hover {
    background: #f8fafc;
}

.client-cell {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
}

.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-block;
}

.badge-api { background: rgba(255, 60, 0, 0.15); color: var(--primary-color); }
.badge-sheets { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.badge-success { background: rgba(16, 185, 129, 0.15); color: #10b981; }

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

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 100;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    width: 100%;
    max-width: 500px;
    border-radius: 24px;
    border: 1px solid var(--border-color);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
}

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

.modal-header h2 {
    font-size: 1.25rem;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

.close-btn:hover {
    color: var(--danger);
}

.modal-body {
    padding: 24px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 24px 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

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

.divider span {
    padding: 0 10px;
}

.custom-select {
    width: 100%;
    padding: 14px 16px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    appearance: none;
}

[data-theme="light"] .custom-select {
    background: #f8fafc;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 32px;
}

.modal-actions button {
    width: auto;
    padding: 12px 24px;
}

/* Animations */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Responsive */
@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .dashboard-body {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    .main-content {
        height: auto;
    }
    .content-wrapper {
        padding: 20px;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .topbar {
        padding: 16px 20px;
    }
}
