/* Reset en basis styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Backgrounds */
    --bg-primary: #0f0f0f;
    --bg-secondary: #171717;
    --bg-tertiary: #212121;
    --bg-hover: #2a2a2a;
    
    /* Text */
    --text-primary: #f5f5f5;
    --text-secondary: #a3a3a3;
    --text-muted: #737373;
    
    /* Borders */
    --border-primary: #2e2e2e;
    --border-secondary: #404040;
    
    /* Status */
    --status-success: #22c55e;
    --status-warning: #eab308;
    --status-error: #ef4444;
    --status-info: #3b82f6;
    
    /* Accent */
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    
    /* Spacing */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 
                 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    overflow-x: hidden;
}

code, .mono {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
}

h1 { font-size: 24px; font-weight: 600; margin-bottom: 16px; }
h2 { font-size: 18px; font-weight: 600; margin-bottom: 16px; }
h3 { font-size: 16px; font-weight: 500; margin-bottom: 12px; }

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1a1a 0%, #0a0a0a 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: 40px;
}

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

.login-header h1 {
    font-size: 28px;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-form {
    margin-bottom: 24px;
}

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

.form-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.input {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color 0.15s ease;
}

.input:focus {
    outline: none;
    border-color: var(--accent);
}

.input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 10px;
    font-size: 13px;
}

.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--status-error);
    border-radius: var(--radius-md);
    padding: 12px;
    color: var(--status-error);
    margin-bottom: 16px;
    font-size: 13px;
}

.login-footer {
    text-align: center;
    padding-top: 24px;
    border-top: 1px solid var(--border-primary);
}

.login-footer p {
    color: var(--text-muted);
    font-size: 12px;
}

/* Dashboard Layout */
.dashboard-layout {
    display: grid;
    grid-template-areas:
        "header header"
        "sidebar main"
        "footer footer";
    grid-template-columns: 240px 1fr;
    grid-template-rows: 60px 1fr 40px;
    height: 100vh;
}

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

.header-left h1 {
    font-size: 20px;
    margin: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.username {
    color: var(--text-secondary);
    font-size: 14px;
}

.dashboard-sidebar {
    grid-area: sidebar;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-primary);
    padding: 20px 0;
    overflow-y: auto;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.15s ease;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--bg-tertiary);
    color: var(--accent);
    border-left: 3px solid var(--accent);
}

.nav-item i {
    font-size: 20px;
}

.dashboard-main {
    grid-area: main;
    padding: 24px;
    overflow-y: auto;
    background: var(--bg-primary);
}

.dashboard-footer {
    grid-area: footer;
    display: flex;
    align-items: center;
    padding: 0 20px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-primary);
}

.footer-metrics {
    display: flex;
    gap: 24px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Pages */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-header i {
    font-size: 16px;
}

.card-header span {
    flex: 1;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.metric-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

.metric-header i {
    font-size: 16px;
}

.metric-value {
    font-size: 32px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.metric-label {
    font-size: 12px;
    color: var(--text-muted);
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.charts-grid canvas {
    width: 100% !important;
    height: 200px !important;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--bg-tertiary);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    min-width: 300px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success { border-left: 3px solid var(--status-success); }
.toast.error { border-left: 3px solid var(--status-error); }
.toast.warning { border-left: 3px solid var(--status-warning); }
.toast.info { border-left: 3px solid var(--status-info); }

.toast i {
    font-size: 20px;
}

.toast.success i { color: var(--status-success); }
.toast.error i { color: var(--status-error); }
.toast.warning i { color: var(--status-warning); }
.toast.info i { color: var(--status-info); }

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9997;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-large {
    max-width: 900px;
}

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

.modal-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px;
    border-top: 1px solid var(--border-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    font-size: 20px;
}

.modal-close:hover {
    color: var(--text-primary);
}

/* Mobile Navigation */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    margin-right: 12px;
}

.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* Responsive */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
    }

    .dashboard-header {
        padding: 0 12px;
    }

    .dashboard-header h1 {
        font-size: 18px;
    }

    .header-left {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .username {
        display: none;
    }

    .dashboard-layout {
        grid-template-columns: 1fr;
        grid-template-rows: 60px 1fr 60px;
    }

    .dashboard-sidebar {
        position: fixed;
        top: 60px;
        left: -100%;
        width: 280px;
        height: calc(100vh - 100px);
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.3);
    }

    .dashboard-sidebar.active {
        left: 0;
    }

    .dashboard-main {
        padding: 16px;
        overflow-x: hidden;
        width: 100%;
    }

    .card {
        padding: 16px;
    }

    .metrics-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .metric-card {
        padding: 16px;
    }

    .metric-value {
        font-size: 24px;
    }

    .charts-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .dashboard-footer {
        padding: 0 12px;
        height: 60px;
    }

    .footer-metrics {
        gap: 12px;
        font-size: 11px;
        flex-wrap: wrap;
    }

    .footer-metrics span {
        flex: 1;
        min-width: 80px;
        text-align: center;
    }

    .modal-content {
        width: 95%;
        max-height: 85vh;
    }

    .modal-large {
        max-width: 95%;
    }

    .toast-container {
        bottom: 80px;
        right: 12px;
        left: 12px;
    }

    .toast {
        min-width: auto;
        width: 100%;
    }

    .btn {
        padding: 10px 12px;
        font-size: 13px;
    }

    .input {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .dashboard-main {
        padding: 12px;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 12px;
    }

    h2 {
        font-size: 16px;
    }

    .footer-metrics {
        font-size: 10px;
    }

    .footer-metrics span {
        min-width: 70px;
    }
}
