/* MSP Reboot - Dark/Light Theme System */

/* Smooth transitions for theme switching */
*,
*::before,
*::after {
    transition: background-color 0.3s ease,
                color 0.3s ease,
                border-color 0.3s ease,
                box-shadow 0.3s ease !important;
}

/* Light Mode (Default) */
:root {
    /* Background Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-tertiary: #fafafa;
    --bg-elevated: #ffffff;

    /* Text Colors */
    --text-primary: #1a1a1a;
    --text-secondary: #4a4a4a;
    --text-tertiary: #6b7280;
    --text-muted: #9ca3af;

    /* Brand Colors */
    --brand-primary: #3b82f6;
    --brand-secondary: #06b6d4;
    --brand-gradient-start: #3b82f6;
    --brand-gradient-end: #06b6d4;

    /* Interactive Elements */
    --link-color: #3b82f6;
    --link-hover: #2563eb;

    /* Borders */
    --border-color: #e5e7eb;
    --border-color-strong: #d1d5db;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    /* Status Colors */
    --success-bg: #dcfce7;
    --success-text: #166534;
    --success-border: #86efac;

    --warning-bg: #fef3c7;
    --warning-text: #92400e;
    --warning-border: #fcd34d;

    --error-bg: #fee2e2;
    --error-text: #991b1b;
    --error-border: #fca5a5;

    --info-bg: #dbeafe;
    --info-text: #1e40af;
    --info-border: #93c5fd;

    /* Form Elements */
    --input-bg: #ffffff;
    --input-border: #d1d5db;
    --input-text: #1a1a1a;
    --input-placeholder: #9ca3af;
    --input-focus-border: #3b82f6;

    /* Buttons */
    --button-primary-bg: #3b82f6;
    --button-primary-text: #ffffff;
    --button-primary-hover: #2563eb;

    --button-secondary-bg: #6b7280;
    --button-secondary-text: #ffffff;
    --button-secondary-hover: #4b5563;

    /* Cards */
    --card-bg: #ffffff;
    --card-border: rgba(0, 0, 0, 0.05);
    --card-hover-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);

    /* Tables */
    --table-header-bg: #f8f9fa;
    --table-row-hover: #f9fafb;
}

/* Dark Mode */
html.dark {
    /* Background Colors */
    --bg-primary: #1a1a1a;
    --bg-secondary: #242424;
    --bg-tertiary: #2d2d2d;
    --bg-elevated: #2d2d2d;

    /* Text Colors */
    --text-primary: #f5f5f5;
    --text-secondary: #e5e5e5;
    --text-tertiary: #b0b0b0;
    --text-muted: #8a8a8a;

    /* Brand Colors (Lighter in dark mode) */
    --brand-primary: #60a5fa;
    --brand-secondary: #22d3ee;
    --brand-gradient-start: #60a5fa;
    --brand-gradient-end: #22d3ee;

    /* Interactive Elements */
    --link-color: #60a5fa;
    --link-hover: #93c5fd;

    /* Borders */
    --border-color: #3d3d3d;
    --border-color-strong: #525252;

    /* Shadows (Subtle in dark mode) */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.4), 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.4);

    /* Status Colors (Adjusted for dark mode) */
    --success-bg: #064e3b;
    --success-text: #86efac;
    --success-border: #065f46;

    --warning-bg: #78350f;
    --warning-text: #fcd34d;
    --warning-border: #92400e;

    --error-bg: #7f1d1d;
    --error-text: #fca5a5;
    --error-border: #991b1b;

    --info-bg: #1e3a8a;
    --info-text: #93c5fd;
    --info-border: #1e40af;

    /* Form Elements */
    --input-bg: #2d2d2d;
    --input-border: #3d3d3d;
    --input-text: #f5f5f5;
    --input-placeholder: #8a8a8a;
    --input-focus-border: #60a5fa;

    /* Buttons */
    --button-primary-bg: #60a5fa;
    --button-primary-text: #1a1a1a;
    --button-primary-hover: #93c5fd;

    --button-secondary-bg: #4b5563;
    --button-secondary-text: #f5f5f5;
    --button-secondary-hover: #6b7280;

    /* Cards */
    --card-bg: #2d2d2d;
    --card-border: #3d3d3d;
    --card-hover-shadow: 0 3px 10px rgba(0, 0, 0, 0.6);

    /* Tables */
    --table-header-bg: #353535;
    --table-row-hover: #333333;
}

/* Apply theme variables */
body {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

/* Headers */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary) !important;
}

/* Paragraphs and text */
p, span, div, label, li {
    color: var(--text-secondary);
}

/* Links */
a {
    color: var(--link-color);
}

a:hover {
    color: var(--link-hover);
}

/* Cards */
.card, .stat-card, .announcement-item, .submenu-content {
    background-color: var(--card-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--card-border) !important;
    box-shadow: var(--shadow);
}

.card:hover, .stat-card:hover {
    box-shadow: var(--card-hover-shadow) !important;
}

.card h2, .card h3, .card p {
    color: var(--text-primary) !important;
}

/* Forms */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
textarea,
select {
    background-color: var(--input-bg) !important;
    color: var(--input-text) !important;
    border-color: var(--input-border) !important;
}

input::placeholder,
textarea::placeholder {
    color: var(--input-placeholder) !important;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--input-focus-border) !important;
    outline-color: var(--input-focus-border) !important;
}

/* Buttons */
.btn, button[type="submit"], .button {
    background: var(--button-primary-bg) !important;
    color: var(--button-primary-text) !important;
    border: none !important;
}

.btn:hover, button[type="submit"]:hover {
    background: var(--button-primary-hover) !important;
}

.btn-secondary {
    background: var(--button-secondary-bg) !important;
    color: var(--button-secondary-text) !important;
}

.btn-secondary:hover {
    background: var(--button-secondary-hover) !important;
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    color: #ffffff !important;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    color: #ffffff !important;
}

/* Tables */
table {
    background-color: var(--card-bg) !important;
    color: var(--text-primary) !important;
}

thead th {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

tbody td {
    border-color: var(--border-color) !important;
    color: var(--text-secondary) !important;
}

tbody tr:hover {
    background-color: var(--bg-tertiary) !important;
}

/* Badges */
.badge {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
}

.badge.pending_approval {
    background-color: var(--warning-bg) !important;
    color: var(--warning-text) !important;
}

.badge.sent {
    background-color: var(--success-bg) !important;
    color: var(--success-text) !important;
}

/* Navigation and Headers */
.header, .navbar, nav {
    background: linear-gradient(135deg, var(--brand-gradient-start) 0%, var(--brand-gradient-end) 100%) !important;
    color: #ffffff !important;
}

.header h1, .header h2, .navbar a {
    color: #ffffff !important;
}

.submenu-header {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%) !important;
    color: #ffffff !important;
}

/* Specific component overrides */
.container {
    background-color: transparent !important;
}

.grid {
    background-color: transparent !important;
}

/* Code blocks */
pre, code {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* Modals */
.modal-content {
    background-color: var(--card-bg) !important;
    color: var(--text-primary) !important;
}

/* Alerts */
.alert {
    border-color: var(--border-color) !important;
}

.alert-success {
    background-color: var(--success-bg) !important;
    color: var(--success-text) !important;
    border-color: var(--success-border) !important;
}

.alert-warning {
    background-color: var(--warning-bg) !important;
    color: var(--warning-text) !important;
    border-color: var(--warning-border) !important;
}

.alert-error, .alert-danger {
    background-color: var(--error-bg) !important;
    color: var(--error-text) !important;
    border-color: var(--error-border) !important;
}

.alert-info {
    background-color: var(--info-bg) !important;
    color: var(--info-text) !important;
    border-color: var(--info-border) !important;
}

/* Dropdown menus */
.dropdown-menu, select option {
    background-color: var(--card-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* Scrollbars (webkit) */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color-strong);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color-strong) var(--bg-secondary);
}

/* Theme Toggle Button Styles */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
}

.theme-toggle:active {
    transform: scale(0.95);
}

/* Prevent flash of unstyled content */
html:not(.theme-loaded) {
    visibility: hidden;
}

html.theme-loaded {
    visibility: visible;
}

/* ========================================
   STANDARDIZED HEADER NAVIGATION
   ======================================== */

header {
    background: linear-gradient(135deg, var(--brand-gradient-start) 0%, var(--brand-gradient-end) 100%);
    padding: 1rem 2rem;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 1000;
}

header .container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

header .logo-section {
    flex-shrink: 0;
}

header .logo-section img {
    max-height: 60px;
    width: auto;
    display: block;
}

header nav {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

header nav a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s;
    background: rgba(255,255,255,0.15);
    font-size: 0.95rem;
}

header nav a:hover {
    background: rgba(255,255,255,0.25);
    transform: translateY(-1px);
}

header nav a:active {
    transform: translateY(0);
}

/* Mobile Menu */
.mobile-menu-btn,
.mobile-menu-close {
    display: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    background: rgba(255,255,255,0.15);
    border-radius: 8px;
    border: none;
}

@media (max-width: 768px) {
    header .container {
        flex-wrap: wrap;
    }

    .mobile-menu-btn {
        display: block;
    }

    header nav {
        display: none;
        position: fixed;
        top: 0;
        right: 0;
        width: 280px;
        height: 100vh;
        background: linear-gradient(135deg, var(--brand-gradient-start) 0%, var(--brand-gradient-end) 100%);
        flex-direction: column;
        padding: 2rem;
        box-shadow: -4px 0 20px rgba(0,0,0,0.2);
        overflow-y: auto;
    }

    #mobile-menu-toggle:checked ~ nav {
        display: flex;
    }

    .mobile-menu-close {
        display: block;
        align-self: flex-end;
        margin-bottom: 2rem;
    }

    header nav a {
        width: 100%;
        text-align: left;
    }
}
