/* Root variables for light mode */
:root {
    --bg-primary: #f3f4f6;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f9fafb;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-tertiary: #9ca3af;
    --border-color: #d1d5db;
    --sidebar-bg: #111827;
    --sidebar-text: #d1d5db;
    --sidebar-hover: rgba(255, 255, 255, 0.05);
    --sidebar-active: rgba(102, 126, 234, 0.1);
    --accent-primary: #667eea;
    --accent-hover: #5568d3;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #0f172a;
        --bg-secondary: #1e293b;
        --bg-tertiary: #334155;
        --text-primary: #f1f5f9;
        --text-secondary: #cbd5e1;
        --text-tertiary: #94a3b8;
        --border-color: #475569;
        --sidebar-bg: #020617;
        --sidebar-text: #cbd5e1;
        --sidebar-hover: rgba(255, 255, 255, 0.1);
        --sidebar-active: rgba(102, 126, 234, 0.2);
        --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);
    }
}

/* Explicit dark mode class */
body.dark-mode {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --border-color: #475569;
    --sidebar-bg: #020617;
    --sidebar-text: #cbd5e1;
    --sidebar-hover: rgba(255, 255, 255, 0.1);
    --sidebar-active: rgba(102, 126, 234, 0.2);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

/* Login Page */
body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

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

.login-card {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

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

.login-header h1 {
    font-size: 28px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

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

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

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

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.2s;
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-login:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.login-alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.login-alert.error {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid var(--danger);
}

/* Dashboard Layout */
body.dashboard-page {
    display: flex;
}

.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
    transition: background-color 0.3s;
}

.sidebar-header {
    padding: 30px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h3 {
    font-size: 18px;
    margin-bottom: 5px;
    color: white;
}

.sidebar-subtitle {
    font-size: 13px;
    color: var(--sidebar-text);
}

/* Theme Dropdown */
.theme-dropdown {
    position: relative;
    margin-top: 20px;
}

.theme-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: var(--sidebar-text);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.theme-dropdown-trigger:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.theme-dropdown-trigger .theme-icon {
    display: flex;
    align-items: center;
    color: var(--accent-primary);
}

.theme-dropdown-trigger .theme-label {
    flex: 1;
}

.theme-dropdown-trigger .theme-chevron {
    transition: transform 0.2s;
    opacity: 0.6;
}

.theme-dropdown-trigger[aria-expanded="true"] .theme-chevron {
    transform: rotate(180deg);
}

.theme-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    padding: 4px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s;
    z-index: 1000;
}

.theme-dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.theme-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    text-align: left;
}

.theme-dropdown-item:hover {
    background: var(--bg-tertiary);
}

.theme-dropdown-item svg:first-child {
    color: var(--accent-primary);
    flex-shrink: 0;
}

.theme-dropdown-item span {
    flex: 1;
}

.theme-dropdown-item .check-icon {
    opacity: 0;
    color: var(--success);
    flex-shrink: 0;
}

.theme-dropdown-item.active .check-icon {
    opacity: 1;
}

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: white;
}

.nav-item.active {
    background: var(--sidebar-active);
    color: var(--accent-primary);
    border-left-color: var(--accent-primary);
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 30px;
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
}

.content-header {
    margin-bottom: 30px;
}

.content-header h1 {
    font-size: 32px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

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

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s;
}

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

/* Status Card */
.status-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.status-header h2 {
    font-size: 20px;
    color: var(--text-primary);
}

.status-badge {
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
}

.status-badge.status-active {
    background: #d1fae5;
    color: #10b981;
}

.status-badge.status-inactive {
    background: #fee2e2;
    color: #ef4444;
}

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

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.metric-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

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

.metric-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value-large {
    font-size: 36px;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.metric-sublabel {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
}

.progress-bar-thin {
    width: 100%;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill-thin {
    height: 100%;
    transition: width 0.5s ease;
    border-radius: 3px;
}

.progress-fill-thin.progress-normal {
    background: var(--success);
}

.progress-fill-thin.progress-warning {
    background: var(--warning);
}

.progress-fill-thin.progress-critical {
    background: var(--danger);
}

.info-card {
    background: var(--bg-tertiary);
    border-left: 4px solid var(--accent-primary);
    padding: 16px 20px;
    border-radius: 8px;
    color: var(--text-primary);
}

/* Actions Grid */
.actions-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 24px;
}

.action-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

.action-card:not(.disabled):hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

.action-card h3 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.action-card p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 20px;
}

.action-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.warning-card {
    background: #fef3c7;
    border-left: 4px solid var(--warning);
    padding: 20px;
    border-radius: 8px;
    margin-top: 24px;
}

@media (prefers-color-scheme: dark) {
    .warning-card {
        background: rgba(245, 158, 11, 0.1);
    }
}

body.dark-mode .warning-card {
    background: rgba(245, 158, 11, 0.1);
}

.warning-card h3 {
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.warning-card p {
    color: var(--text-primary);
    margin-bottom: 12px;
    line-height: 1.6;
}

.warning-card ul {
    margin-left: 20px;
    color: var(--text-primary);
}

.warning-card li {
    margin-bottom: 8px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn.btn-large {
    padding: 14px 32px;
    font-size: 16px;
    width: 100%;
}

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

.btn.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

.btn.btn-success:hover:not(:disabled) {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

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

.btn.btn-danger:hover:not(:disabled) {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Period Selector */
.period-selector {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.period-btn {
    padding: 10px 20px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

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

.chart-container {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.chart-container h3 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.chart-container canvas {
    max-height: 300px;
}

/* Status Banner */
.status-banner {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-left: 4px solid var(--text-tertiary);
    transition: all 0.3s ease;
}

.status-banner.status-active {
    border-left-color: var(--success);
    background: linear-gradient(to right, rgba(16, 185, 129, 0.05), var(--bg-secondary));
}

.status-banner.status-inactive {
    border-left-color: var(--danger);
    background: linear-gradient(to right, rgba(239, 68, 68, 0.05), var(--bg-secondary));
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-tertiary);
    position: relative;
    flex-shrink: 0;
}

.status-dot::before {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 50%;
    border: 2px solid currentColor;
    opacity: 0;
    animation: pulse 2s infinite;
}

.status-banner.status-active .status-dot {
    background: var(--success);
    color: var(--success);
}

.status-banner.status-inactive .status-dot {
    background: var(--danger);
    color: var(--danger);
}

.status-banner.status-active .status-dot::before {
    opacity: 0.4;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.4;
    }
    50% {
        transform: scale(1.3);
        opacity: 0;
    }
}

.status-text strong {
    display: block;
    color: var(--text-primary);
    font-size: 16px;
    margin-bottom: 2px;
}

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

.status-meta {
    color: var(--text-tertiary);
    font-size: 13px;
}

/* Alerts */
.alert {
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 15px;
}

.alert.alert-success {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid var(--success);
}

.alert.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid var(--danger);
}

.alert.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border-left: 4px solid #3b82f6;
}

@media (prefers-color-scheme: dark) {
    .alert.alert-success {
        background: rgba(16, 185, 129, 0.1);
        color: #6ee7b7;
    }

    .alert.alert-danger {
        background: rgba(239, 68, 68, 0.1);
        color: #fca5a5;
    }

    .alert.alert-info {
        background: rgba(59, 130, 246, 0.1);
        color: #93c5fd;
    }
}

body.dark-mode .alert.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: #6ee7b7;
}

body.dark-mode .alert.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
}

body.dark-mode .alert.alert-info {
    background: rgba(59, 130, 246, 0.1);
    color: #93c5fd;
}

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

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

@media (max-width: 768px) {
    .sidebar {
        width: 80px;
    }

    .sidebar .sidebar-header h3,
    .sidebar .sidebar-subtitle,
    .sidebar .nav-item span,
    .sidebar .logout-btn span {
        display: none;
    }

    .main-content {
        margin-left: 80px;
        width: calc(100% - 80px);
        padding: 20px;
    }
}
