/* ==========================================================================
   ATLAS Design System Tokens
   Advanced Tallahassee Live Automated Signals

   Government V2X traffic visualization — utilitarian/industrial aesthetic.
   Signal colors (red/yellow/green) are SACRED for traffic states only.
   ========================================================================== */

/* --- Prevent white flash between page navigations ---
   Must be a raw value (not a CSS variable) so it applies before :root is parsed. */
html { background-color: #f5f5f5; }
html.dark { background-color: #0f1117; }



/* --------------------------------------------------------------------------
   1. COLOR TOKENS
   -------------------------------------------------------------------------- */
:root {
    /* --- Brand (City of Tallahassee #0087C7) --- */
    --atlas-primary:          #006DA3;
    --atlas-primary-light:    #005f8a;
    --atlas-primary-text:     #7ec8e3;
    --atlas-brand-accent:     #0087C7;  /* Official brand blue — buttons, links, accents */

    /* --- Page accent colors (override per-page via body.page-*) --- */
    --atlas-accent:           var(--atlas-primary);
    --atlas-accent-hover:     var(--atlas-primary-light);
    --atlas-accent-light:     #e0f2f9;

    /* --- Neutrals --- */
    --atlas-bg:               #f5f5f5;
    --atlas-surface:          #ffffff;
    --atlas-surface-alt:      #fafafa;
    --atlas-border:           #dddddd;
    --atlas-border-light:     #eeeeee;
    --atlas-divider:          #e0e0e0;

    /* --- Text --- */
    --atlas-text:             #333333;
    --atlas-text-secondary:   #666666;
    --atlas-text-muted:       #888888;
    --atlas-text-disabled:    #999999;
    --atlas-text-on-dark:     #ffffff;

    /* --- Semantic (NOT for traffic signals) --- */
    --atlas-success:          #4caf50;
    --atlas-success-dark:     #2e7d32;
    --atlas-success-light:    #e8f5e9;
    --atlas-warning:          #ff9800;
    --atlas-warning-dark:     #e65100;
    --atlas-warning-light:    #fff3e0;
    --atlas-error:            #f44336;
    --atlas-error-dark:       #c62828;
    --atlas-error-light:      #ffebee;
    --atlas-info:             #2196f3;
    --atlas-info-dark:        #1565c0;
    --atlas-info-light:       #e3f2fd;

    /* --- Traffic signal colors (SACRED — only for signal states) --- */
    --signal-red:             #f44336;
    --signal-yellow:          #ffc107;
    --signal-green:           #4caf50;
    --signal-dark:            #616161;

    /* --- Header --- */
    /* NOTE: --atlas-header-bg intentionally NOT set here.
       Header reads var(--atlas-header-bg, var(--atlas-accent))
       so it automatically follows per-page accent overrides.
       Dark mode keeps the same accent header — only page body goes dark. */
    --atlas-header-text:      var(--atlas-text-on-dark);
    --atlas-header-link-bg:   rgba(255, 255, 255, 0.15);
    --atlas-header-link-hover: rgba(255, 255, 255, 0.25);
    --atlas-header-active:    #d32f2f;
    --atlas-header-active-hover: #b71c1c;
    --atlas-header-shadow:    0 2px 4px rgba(0, 0, 0, 0.2);

    /* --- Cards & surfaces --- */
    --atlas-card-shadow:      0 1px 3px rgba(0, 0, 0, 0.1);
    --atlas-card-shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.12);
    --atlas-card-radius:      8px;

    /* --- Overlay --- */
    --atlas-overlay:          rgba(0, 0, 0, 0.5);
    --atlas-overlay-heavy:    rgba(0, 0, 0, 0.6);

    /* --------------------------------------------------------------------------
       2. TYPOGRAPHY TOKENS
       -------------------------------------------------------------------------- */
    --atlas-font-family:      'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --atlas-font-mono:        'Courier New', Consolas, monospace;

    /* Scale: minor third (1.2) */
    --atlas-text-xs:          0.75rem;    /* 12px */
    --atlas-text-sm:          0.8rem;     /* 12.8px */
    --atlas-text-base:        0.875rem;   /* 14px */
    --atlas-text-md:          0.9rem;     /* 14.4px */
    --atlas-text-lg:          1rem;       /* 16px */
    --atlas-text-xl:          1.125rem;   /* 18px */
    --atlas-text-2xl:         1.25rem;    /* 20px */
    --atlas-text-3xl:         1.5rem;     /* 24px */
    --atlas-text-4xl:         2.25rem;    /* 36px */
    --atlas-text-5xl:         2.8125rem;  /* 45px */

    --atlas-weight-normal:    400;
    --atlas-weight-medium:    500;
    --atlas-weight-semibold:  600;
    --atlas-weight-bold:      700;

    /* --------------------------------------------------------------------------
       3. SPACING TOKENS
       -------------------------------------------------------------------------- */
    --atlas-space-1:          0.25rem;    /* 4px */
    --atlas-space-2:          0.5rem;     /* 8px */
    --atlas-space-3:          0.75rem;    /* 12px */
    --atlas-space-4:          1rem;       /* 16px */
    --atlas-space-5:          1.25rem;    /* 20px */
    --atlas-space-6:          1.5rem;     /* 24px */
    --atlas-space-8:          2rem;       /* 32px */

    /* --------------------------------------------------------------------------
       4. LAYOUT TOKENS
       -------------------------------------------------------------------------- */
    --atlas-header-height:    48px;
    --atlas-sidebar-width:    350px;
    --atlas-max-content:      1200px;
    --atlas-max-content-wide: 1400px;
    --atlas-max-content-xl:   1600px;
    --atlas-radius-sm:        4px;
    --atlas-radius-md:        8px;
    --atlas-radius-lg:        12px;
    --atlas-radius-full:      9999px;

    /* --------------------------------------------------------------------------
       5. TRANSITION TOKENS
       -------------------------------------------------------------------------- */
    --atlas-transition-fast:  0.15s ease;
    --atlas-transition:       0.2s ease;
    --atlas-transition-slow:  0.3s ease;

    /* --------------------------------------------------------------------------
       6. Z-INDEX SCALE
       -------------------------------------------------------------------------- */
    --atlas-z-dropdown:       1000;
    --atlas-z-sticky:         1000;
    --atlas-z-modal:          2000;
    --atlas-z-toast:          4000;
    --atlas-z-menu:           10000;
}

/* --------------------------------------------------------------------------
   PAGE ACCENT OVERRIDES
   Each page sets its accent via a body class.
   -------------------------------------------------------------------------- */
body.page-map         { --atlas-accent: #006DA3; --atlas-accent-hover: #005f8a; --atlas-accent-dot: #0087C7; }
body.page-work-orders,
body.page-gis-map-fullscreen,
body.page-inventory,
body.page-users,
body.page-admin-config { --atlas-accent: #00897B; --atlas-accent-hover: #00695C; --atlas-accent-dot: #80CBC4; }
body.page-incidents   { --atlas-accent: #E53935; --atlas-accent-hover: #C62828; --atlas-accent-dot: #EF9A9A; }
body.page-tims        { --atlas-accent: #ff9800; --atlas-accent-hover: #f57c00; --atlas-accent-dot: #FFF176; }
body.page-tsc-health  { --atlas-accent: #2e7d32; --atlas-accent-hover: #1b5e20; --atlas-accent-dot: #81C784; }
body.page-obu         { --atlas-accent: #5C6BC0; --atlas-accent-hover: #3F51B5; --atlas-accent-dot: #9FA8DA; }
body.page-dashboard   { --atlas-accent: #9C27B0; --atlas-accent-hover: #7B1FA2; --atlas-accent-dot: #CE93D8; }
body.page-api-keys    { --atlas-accent: #9C27B0; --atlas-accent-hover: #7B1FA2; --atlas-accent-dot: #CE93D8; }
body.page-exports     { --atlas-accent: #9C27B0; --atlas-accent-hover: #7B1FA2; --atlas-accent-dot: #CE93D8; }
body.page-api-docs    { --atlas-accent: #9C27B0; --atlas-accent-hover: #7B1FA2; --atlas-accent-dot: #CE93D8; }

/* --------------------------------------------------------------------------
   DARK MODE TOKENS
   Activated via body.dark class (toggle or JS).
   -------------------------------------------------------------------------- */
body.dark {
    --atlas-bg:               #0f1117;
    --atlas-surface:          #1a1f2e;
    --atlas-surface-alt:      #1e2438;
    --atlas-border:           #2a3045;
    --atlas-border-light:     #242a3d;
    --atlas-divider:          #2a3045;

    --atlas-text:             #c5cae9;
    --atlas-text-secondary:   #b0b8cc;
    --atlas-text-muted:       #8891a5;
    --atlas-text-disabled:    #606878;

    --atlas-header-shadow:    0 2px 8px rgba(0, 0, 0, 0.4);

    --atlas-card-shadow:      0 2px 8px rgba(0, 0, 0, 0.3);
    --atlas-card-shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.5);

    --atlas-success-light:    #1b3a1b;
    --atlas-warning-light:    #3a351b;
    --atlas-error-light:      #3a1b1b;
    --atlas-info-light:       #1b2a3a;

    --atlas-accent-light:     rgba(255, 255, 255, 0.08);

    color-scheme: dark;
}

/* Dark mode header keeps its light accent color — only the page body goes dark */
body.dark .atlas-header {
    background-color: var(--atlas-accent) !important;
    color: #ffffff;
}
body.dark .atlas-header .header-brand,
body.dark .atlas-header .header-menu-btn,
body.dark .atlas-header .theme-toggle,
body.dark .atlas-header a,
body.dark .atlas-header .header-sibling-link {
    color: #ffffff;
}

/* --------------------------------------------------------------------------
   SHARED COMPONENTS — Used across all pages
   -------------------------------------------------------------------------- */

/* --- Layout modes ---
   .page-map:     flex column, 100vh, no scroll (map page)
   .page-scroll:  block layout, auto scroll (all other pages)
   This eliminates the need for !important body overrides.
   ------------------------------------------------------------------- */
body.page-scroll {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background: var(--atlas-bg);
}

body.page-scroll .atlas-header {
    flex-shrink: 0;
}

body.page-scroll #app {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

body.page-scroll main {
    display: block;
    overflow: visible;
    flex: none;
}

/* --- Header component --- */
.atlas-header {
    background: var(--atlas-header-bg, var(--atlas-accent));
    color: var(--atlas-header-text);
    min-height: var(--atlas-header-height);
    padding: 0.25rem var(--atlas-space-4);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--atlas-header-shadow);
}

.atlas-header .header-left {
    display: flex;
    align-items: center;
    gap: var(--atlas-space-2);
    margin-right: var(--atlas-space-4);
    flex-shrink: 0;
}

.atlas-header .header-brand {
    font-size: 22px;
    font-weight: var(--atlas-weight-semibold);
    color: var(--atlas-header-text);
    text-decoration: none;
}

.atlas-header .header-title {
    font-size: 22px;
    font-weight: var(--atlas-weight-medium);
    color: var(--atlas-header-text);
}

.atlas-header .header-right {
    display: flex;
    align-items: center;
    gap: var(--atlas-space-2);
    flex-wrap: nowrap;
    flex-shrink: 0;
}

.atlas-header .header-right a {
    color: var(--atlas-header-text);
    text-decoration: none;
    font-size: var(--atlas-text-base);
    opacity: 0.9;
    transition: opacity var(--atlas-transition-fast);
}

.atlas-header .header-right a:hover {
    opacity: 1;
}

/* --- Status dot (pulsating connection indicator) --- */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transition: all var(--atlas-transition-slow);
    flex-shrink: 0;
}

.status-dot.active {
    background: var(--atlas-accent-dot, var(--atlas-accent));
    box-shadow: 0 0 8px var(--atlas-accent-dot, var(--atlas-accent));
    animation: atlas-pulse-dot 1.5s infinite;
}

@keyframes atlas-pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* --- WebSocket status badge --- */
.ws-status-badge {
    padding: var(--atlas-space-1) var(--atlas-space-3);
    border-radius: var(--atlas-radius-sm);
    font-size: var(--atlas-text-base);
    font-weight: var(--atlas-weight-medium);
}

.ws-status-badge.status-connected {
    background-color: var(--atlas-success);
    color: white;
}

.ws-status-badge.status-disconnected {
    background-color: var(--atlas-error);
    color: white;
}

.ws-status-badge.status-connecting {
    background-color: var(--atlas-warning);
    color: white;
}

/* --- Header link pills (map page style) --- */
.header-link {
    color: var(--atlas-header-text);
    text-decoration: none;
    padding: var(--atlas-space-1) var(--atlas-space-3);
    border-radius: var(--atlas-radius-sm);
    font-size: var(--atlas-text-base);
    font-weight: var(--atlas-weight-medium);
    background: var(--atlas-header-link-bg);
    transition: background var(--atlas-transition);
    white-space: nowrap;
}

.header-link:hover {
    background: var(--atlas-header-link-hover);
}

.header-link.active {
    background: var(--atlas-header-active);
    color: white;
}

.header-link.active:hover {
    background: var(--atlas-header-active-hover);
}

/* --- Theme toggle button --- */
.theme-toggle {
    background: var(--atlas-header-link-bg);
    border: none;
    border-radius: var(--atlas-radius-sm);
    padding: 0.35rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--atlas-header-text);
    transition: background var(--atlas-transition);
}

.theme-toggle:hover {
    background: var(--atlas-header-link-hover);
}

/* Theme toggle as dropdown menu item — button.theme-toggle-menu beats .header-menu-item specificity */
button.theme-toggle-menu {
    display: flex;
    align-items: center;
    gap: var(--atlas-space-2);
    width: 100%;
    padding: 10px 16px;
    font-size: var(--atlas-text-base);
    color: var(--atlas-text);
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--atlas-transition-fast);
}

.theme-toggle-menu:hover {
    background: var(--atlas-surface-alt);
}

.theme-toggle-menu svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* --- Buttons --- */
.btn {
    padding: var(--atlas-space-2) var(--atlas-space-4);
    border: none;
    border-radius: var(--atlas-radius-sm);
    cursor: pointer;
    font-size: var(--atlas-text-base);
    font-weight: var(--atlas-weight-medium);
    transition: background-color var(--atlas-transition);
    display: inline-flex;
    align-items: center;
    gap: var(--atlas-space-1);
    text-decoration: none;
}

.btn:hover, .btn:focus { text-decoration: none; }
.btn-primary   { background: var(--atlas-accent); color: white; text-decoration: none; }
.btn-primary:hover { background: var(--atlas-accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-success   { background: var(--atlas-success); color: white; }
.btn-success:hover { background: var(--atlas-success-dark); }

.btn-warning   { background: var(--atlas-warning); color: white; }
.btn-warning:hover { background: var(--atlas-warning-dark); }

.btn-danger    { background: var(--atlas-error); color: white; }
.btn-danger:hover { background: var(--atlas-error-dark); }

.btn-secondary { background: #757575; color: white; text-decoration: none; }
.btn-secondary:hover { background: #616161; }

.btn-sm {
    padding: var(--atlas-space-1) var(--atlas-space-2);
    font-size: var(--atlas-text-sm);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--atlas-border);
    color: var(--atlas-text-secondary);
}
.btn-outline:hover {
    background: var(--atlas-surface-alt);
}

/* --- Cards --- */
.atlas-card {
    background: var(--atlas-surface);
    border-radius: var(--atlas-card-radius);
    box-shadow: var(--atlas-card-shadow);
    overflow: hidden;
}

.atlas-card:hover {
    box-shadow: var(--atlas-card-shadow-hover);
}

.atlas-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--atlas-space-4) var(--atlas-space-6);
    background: var(--atlas-surface-alt);
    border-bottom: 1px solid var(--atlas-border-light);
}

.atlas-card-body {
    padding: var(--atlas-space-6);
}

/* --- Tables --- */
.atlas-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--atlas-text-base);
}

.atlas-table th {
    text-align: left;
    padding: var(--atlas-space-3) var(--atlas-space-4);
    background: var(--atlas-surface-alt);
    color: var(--atlas-text-secondary);
    font-weight: var(--atlas-weight-semibold);
    border-bottom: 2px solid var(--atlas-border-light);
    font-size: var(--atlas-text-sm);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.atlas-table td {
    padding: var(--atlas-space-3) var(--atlas-space-4);
    border-bottom: 1px solid var(--atlas-border-light);
    color: var(--atlas-text-secondary);
    vertical-align: middle;
}

.atlas-table tbody tr:nth-child(even) {
    background: var(--atlas-surface-alt);
}

.atlas-table tbody tr:hover {
    background: var(--atlas-accent-light);
}

.atlas-table-wrap {
    background: var(--atlas-surface);
    border: 1px solid var(--atlas-border-light);
    border-radius: var(--atlas-card-radius);
    overflow-x: auto;
}

/* --- Badges --- */
.atlas-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: var(--atlas-radius-full);
    font-size: var(--atlas-text-xs);
    font-weight: var(--atlas-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.atlas-badge-success { background: var(--atlas-success-light); color: var(--atlas-success-dark); }
.atlas-badge-error   { background: var(--atlas-error-light); color: var(--atlas-error-dark); }
.atlas-badge-warning { background: var(--atlas-warning-light); color: var(--atlas-warning-dark); }
.atlas-badge-info    { background: var(--atlas-info-light); color: var(--atlas-info-dark); }
.atlas-badge-accent  { background: var(--atlas-accent-light); color: var(--atlas-accent); }

/* --- Modals --- */
.atlas-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--atlas-overlay-heavy);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--atlas-z-modal);
}

.atlas-modal-overlay.hidden {
    display: none;
}

.atlas-modal {
    background: var(--atlas-surface);
    border-radius: var(--atlas-radius-lg, 8px);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.atlas-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--atlas-space-4, 16px) var(--atlas-space-6, 24px);
    border-bottom: 1px solid var(--atlas-border-light);
}

.atlas-modal-header h2,
.atlas-modal-header h3,
.atlas-modal-header h4 {
    margin: 0;
    font-size: var(--atlas-text-2xl, 20px);
    font-weight: var(--atlas-weight-semibold, 600);
}

.atlas-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--atlas-text-muted);
    padding: 0;
    line-height: 1;
}

.atlas-modal-close:hover {
    color: var(--atlas-text);
}

.atlas-modal-body {
    padding: var(--atlas-space-4, 16px) var(--atlas-space-6, 24px);
}

.atlas-modal-body .form-group {
    margin-bottom: var(--atlas-space-4, 16px);
}

.atlas-modal-body label {
    display: block;
    font-size: var(--atlas-text-base, 14px);
    color: var(--atlas-text-secondary);
    margin-bottom: var(--atlas-space-1, 4px);
}

.atlas-modal-body input[type="text"],
.atlas-modal-body input[type="password"],
.atlas-modal-body input[type="number"],
.atlas-modal-body input[type="date"],
.atlas-modal-body select,
.atlas-modal-body textarea {
    width: 100%;
    padding: var(--atlas-space-2, 8px);
    border: 1px solid var(--atlas-border);
    border-radius: var(--atlas-radius-sm, 4px);
    font-family: var(--atlas-font-family);
    font-size: var(--atlas-text-base, 14px);
    background: var(--atlas-surface);
    color: var(--atlas-text);
    box-sizing: border-box;
}

.atlas-modal-body textarea {
    resize: vertical;
}

.atlas-modal-body select {
    padding-right: 2rem;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
}

.atlas-modal-body input:focus,
.atlas-modal-body select:focus,
.atlas-modal-body textarea:focus {
    outline: none;
    border-color: var(--atlas-accent);
    box-shadow: 0 0 0 2px rgba(0, 109, 163, 0.15);
}

.atlas-modal-body input:disabled {
    background: var(--atlas-surface-alt);
    color: var(--atlas-text-muted);
    cursor: not-allowed;
}

.atlas-modal-body p {
    margin: 0 0 var(--atlas-space-3) 0;
    font-size: var(--atlas-text-base);
    color: var(--atlas-text-secondary);
}

.atlas-modal-body .form-checkbox {
    display: flex;
    align-items: center;
    gap: var(--atlas-space-2, 8px);
}

.atlas-modal-body .form-checkbox label {
    display: inline;
    margin-bottom: 0;
    color: var(--atlas-text);
}

.atlas-modal-body .form-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--atlas-accent);
}

.atlas-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--atlas-space-2, 8px);
    padding: var(--atlas-space-4, 16px) var(--atlas-space-6, 24px);
    border-top: 1px solid var(--atlas-border-light);
}

.atlas-modal-error {
    padding: 0.75rem;
    background: var(--atlas-error-light);
    color: var(--atlas-error-dark);
    border-radius: 6px;
    font-size: var(--atlas-text-base);
}

body.dark .atlas-modal {
    background: var(--atlas-surface);
}

body.dark .atlas-modal-body input,
body.dark .atlas-modal-body select,
body.dark .atlas-modal-body textarea {
    background: var(--atlas-bg);
    border-color: var(--atlas-border);
    color: var(--atlas-text);
    color-scheme: dark;
}

/* --- Mapbox popup dark overrides (shared across all map pages) --- */
body.dark .mapboxgl-popup-content {
    background: var(--atlas-surface);
    color: var(--atlas-text);
}

body.dark .mapboxgl-popup-content .popup-info,
body.dark .mapboxgl-popup-content .lane-info {
    background: var(--atlas-surface-alt);
    color: var(--atlas-text-secondary);
}

body.dark .mapboxgl-popup-tip {
    border-top-color: var(--atlas-surface);
}

/* --- Alerts --- */
.atlas-alert {
    padding: var(--atlas-space-3) var(--atlas-space-4);
    border-radius: var(--atlas-radius-sm);
    margin: var(--atlas-space-4) 0;
    font-size: var(--atlas-text-md);
}

.atlas-alert-info    { background: var(--atlas-info-light); border-left: 4px solid var(--atlas-info); color: var(--atlas-info-dark); }
.atlas-alert-warning { background: var(--atlas-warning-light); border-left: 4px solid var(--atlas-warning); color: var(--atlas-warning-dark); }
.atlas-alert-error   { background: var(--atlas-error-light); border-left: 4px solid var(--atlas-error); color: var(--atlas-error-dark); }
.atlas-alert-success { background: var(--atlas-success-light); border-left: 4px solid var(--atlas-success); color: var(--atlas-success-dark); }

/* --- Toast notifications --- */
.toast-container {
    position: fixed;
    bottom: var(--atlas-space-4);
    right: var(--atlas-space-4);
    z-index: var(--atlas-z-toast);
}

.toast {
    background: var(--atlas-text);
    color: white;
    padding: var(--atlas-space-3) var(--atlas-space-5);
    border-radius: var(--atlas-radius-sm);
    margin-top: var(--atlas-space-2);
    font-size: var(--atlas-text-base);
    animation: atlas-toast-in 0.3s ease;
}

.toast.error   { background: var(--atlas-error); }
.toast.success { background: var(--atlas-success); }

@keyframes atlas-toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --- Forms --- */
.form-group {
    margin-bottom: var(--atlas-space-4);
}

.form-group label {
    display: block;
    font-size: var(--atlas-text-base);
    font-weight: var(--atlas-weight-medium);
    color: var(--atlas-text-secondary);
    margin-bottom: var(--atlas-space-1);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: var(--atlas-space-2) var(--atlas-space-3);
    border: 1px solid var(--atlas-border);
    border-radius: var(--atlas-radius-sm);
    font-size: var(--atlas-text-md);
    box-sizing: border-box;
    background: var(--atlas-surface);
    color: var(--atlas-text);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--atlas-accent);
    box-shadow: 0 0 0 2px rgba(0, 109, 163, 0.15);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group small {
    display: block;
    margin-top: var(--atlas-space-1);
    color: var(--atlas-text-muted);
    font-size: var(--atlas-text-xs);
}

/* --- Back link --- */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: var(--atlas-space-2);
    color: var(--atlas-accent);
    text-decoration: none;
    font-size: var(--atlas-text-base);
    margin-bottom: var(--atlas-space-4);
}

.back-link:hover {
    text-decoration: none;
}

/* --- Empty states --- */
.empty-state {
    text-align: center;
    padding: var(--atlas-space-8) var(--atlas-space-4);
    color: var(--atlas-text-disabled);
    font-style: italic;
}

/* --- Code blocks --- */
pre {
    background: var(--atlas-surface-alt);
    border: 1px solid var(--atlas-border);
    padding: var(--atlas-space-4);
    border-radius: var(--atlas-radius-sm);
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.5;
}

pre code {
    font-family: var(--atlas-font-mono);
    color: var(--atlas-text);
    background: none;
    padding: 0;
}

code {
    font-family: var(--atlas-font-mono);
    background: var(--atlas-surface-alt);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.9em;
}

/* --- Hamburger menu (shared header component) --- */
.header-menu-wrapper {
    position: relative;
}

.header-menu-btn {
    background: var(--atlas-header-link-bg);
    font-family: inherit;
    border: none;
    border-radius: var(--atlas-radius-sm);
    padding: 0.35rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--atlas-header-text);
    transition: background var(--atlas-transition);
}

.header-menu-btn:hover {
    background: var(--atlas-header-link-hover);
}

.header-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--atlas-surface);
    color: var(--atlas-text);
    border-radius: var(--atlas-card-radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    min-width: 200px;
    z-index: var(--atlas-z-menu);
    overflow: hidden;
}

.header-menu-dropdown.hidden {
    display: none;
}

.header-menu-item,
a.header-menu-item,
a.header-menu-item:visited,
.header-menu-dropdown a.header-menu-item,
.atlas-header .header-right .header-menu-dropdown a {
    display: block;
    width: 100%;
    padding: 10px 16px;
    font-size: var(--atlas-text-base);
    color: var(--atlas-text);
    text-decoration: none;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: background var(--atlas-transition-fast);
}

.header-menu-item:hover {
    background: var(--atlas-surface-alt);
}

.header-menu-divider {
    height: 1px;
    background: var(--atlas-divider);
    margin: 4px 0;
}

.header-menu-logout {
    color: var(--atlas-error);
    font-weight: var(--atlas-weight-medium);
}

/* --- Refresh button --- */
.header-refresh-btn {
    background: var(--atlas-header-link-bg);
    border: none;
    border-radius: var(--atlas-radius-sm);
    padding: 0.35rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--atlas-header-text);
    transition: background var(--atlas-transition);
}

.header-refresh-btn:hover {
    background: var(--atlas-header-link-hover);
}

.header-refresh-btn:active {
    transform: scale(0.95);
}

/* --- Flatpickr dark mode (shared across all pages) --- */
body.dark .flatpickr-calendar {
    background: var(--atlas-surface);
    border-color: var(--atlas-border);
    box-shadow: 0 4px 16px rgba(0,0,0,.4);
}

body.dark .flatpickr-months,
body.dark .flatpickr-weekdays,
body.dark span.flatpickr-weekday {
    color: var(--atlas-text);
    background: var(--atlas-surface);
}

body.dark .flatpickr-innerContainer {
    background: var(--atlas-surface);
}

body.dark .flatpickr-day {
    color: var(--atlas-text);
    background: var(--atlas-surface);
}

body.dark .flatpickr-day.prevMonthDay,
body.dark .flatpickr-day.nextMonthDay {
    color: var(--atlas-text-muted);
}

body.dark .flatpickr-day.flatpickr-disabled {
    color: var(--atlas-text-muted);
    opacity: 0.4;
}

body.dark .flatpickr-time input,
body.dark .flatpickr-time .flatpickr-am-pm {
    color: var(--atlas-text);
    background: var(--atlas-surface);
}

body.dark .flatpickr-time {
    border-top-color: var(--atlas-border);
}

body.dark .flatpickr-day:hover {
    background: var(--atlas-surface-alt);
    border-color: var(--atlas-border);
}

body.dark .flatpickr-day.selected,
body.dark .flatpickr-day.selected:hover {
    background: var(--atlas-primary);
    border-color: var(--atlas-primary);
    color: #fff;
}

body.dark .flatpickr-day.today {
    border-color: var(--atlas-primary);
}

body.dark .flatpickr-months .flatpickr-prev-month,
body.dark .flatpickr-months .flatpickr-next-month {
    fill: var(--atlas-text-secondary);
}

body.dark .flatpickr-months .flatpickr-prev-month:hover svg,
body.dark .flatpickr-months .flatpickr-next-month:hover svg {
    fill: var(--atlas-text);
}

body.dark .numInputWrapper:hover,
body.dark .flatpickr-current-month input.cur-year:hover {
    background: var(--atlas-surface-alt);
}

body.dark .flatpickr-current-month input.cur-year {
    color: var(--atlas-text);
}

body.dark .flatpickr-current-month .flatpickr-monthDropdown-months {
    color: var(--atlas-text);
    background: var(--atlas-surface);
}
