/* FleetOps360 design tokens (Phase 3 UI/UX). Light theme is the default; dark theme
   overrides via [data-theme="dark"]. Every color reference in component styles below
   goes through one of these custom properties — never a hardcoded hex — so re-theming
   the whole app means editing this one block. */
:root {
    --color-bg: #f4f6f8;
    --color-surface: #ffffff;
    --color-surface-alt: #eef1f4;
    --color-border: #dde2e7;
    --color-text: #1a2027;
    --color-text-muted: #5b6572;
    --color-primary: #1f4e79;
    --color-primary-hover: #163a5c;
    --color-accent: #2f8f6e;
    --color-warning: #b8860b;
    --color-danger: #b3261e;
    --color-info: #2b6cb0;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);
    --radius-sm: 6px;
    --radius-md: 10px;
    --font-sans: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
    --color-bg: #12161c;
    --color-surface: #1a2029;
    --color-surface-alt: #212836;
    --color-border: #2e3646;
    --color-text: #e6e9ef;
    --color-text-muted: #9aa5b1;
    --color-primary: #4f8fc4;
    --color-primary-hover: #6ba4d1;
    --color-accent: #57b894;
    --color-warning: #e0b34d;
    --color-danger: #e5726b;
    --color-info: #6ba4d1;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
}

a { color: var(--color-primary); }

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* --- Nav --- */
.app-nav {
    width: 240px;
    flex-shrink: 0;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.app-nav__brand { padding: 0.5rem 0.75rem 1.25rem; }

.app-nav__logo { font-weight: 700; font-size: 1.1rem; color: var(--color-primary); }

.app-nav__section {
    margin-top: 1rem;
    padding: 0.4rem 0.75rem 0.2rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}

.app-nav__link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.92rem;
}

.app-nav__link:hover { background: var(--color-surface-alt); }

.app-nav__link.active {
    background: var(--color-primary);
    color: white;
}

/* --- Top bar --- */
.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.app-topbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    padding: 0.6rem 1.5rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.app-topbar__theme-toggle, .app-topbar__logout {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.6rem;
    cursor: pointer;
    color: var(--color-text);
}

.app-topbar__user { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; }

.app-content { padding: 1.5rem; flex: 1; }

/* --- Cards / surfaces --- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border-radius: var(--radius-sm);
    padding: 0.55rem 1.1rem;
    font-size: 0.92rem;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
}

.btn--primary { background: var(--color-primary); color: white; }
.btn--primary:hover { background: var(--color-primary-hover); }
.btn--secondary { background: var(--color-surface-alt); color: var(--color-text); border-color: var(--color-border); }
.btn--danger { background: var(--color-danger); color: white; }
.btn--block { width: 100%; }

/* --- Forms --- */
label { display: block; margin-bottom: 0.85rem; font-size: 0.88rem; color: var(--color-text-muted); }

input, select, textarea {
    display: block;
    width: 100%;
    margin-top: 0.3rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.94rem;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 25%, transparent);
}

.validation-message { color: var(--color-danger); font-size: 0.82rem; }

/* --- Tables --- */
table.data-table { width: 100%; border-collapse: collapse; background: var(--color-surface); }
.data-table th, .data-table td { padding: 0.65rem 0.85rem; border-bottom: 1px solid var(--color-border); text-align: left; font-size: 0.9rem; }
.data-table th { color: var(--color-text-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
.data-table tbody tr:hover { background: var(--color-surface-alt); }

/* --- Badges (status pills) --- */
.badge { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.76rem; font-weight: 600; }
.badge--neutral { background: var(--color-surface-alt); color: var(--color-text-muted); }
.badge--info { background: color-mix(in srgb, var(--color-info) 18%, transparent); color: var(--color-info); }
.badge--success { background: color-mix(in srgb, var(--color-accent) 18%, transparent); color: var(--color-accent); }
.badge--warning { background: color-mix(in srgb, var(--color-warning) 18%, transparent); color: var(--color-warning); }
.badge--danger { background: color-mix(in srgb, var(--color-danger) 18%, transparent); color: var(--color-danger); }

/* --- Alerts --- */
.alert { padding: 0.75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: 0.9rem; }
.alert--error { background: color-mix(in srgb, var(--color-danger) 12%, transparent); color: var(--color-danger); border: 1px solid color-mix(in srgb, var(--color-danger) 30%, transparent); }
.alert--success { background: color-mix(in srgb, var(--color-accent) 12%, transparent); color: var(--color-accent); border: 1px solid color-mix(in srgb, var(--color-accent) 30%, transparent); }

/* --- Auth pages --- */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--color-bg); }
.auth-card { width: 380px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: 2rem; }
.auth-card h1 { font-size: 1.3rem; margin: 0 0 0.25rem; color: var(--color-primary); }
.auth-card__subtitle { color: var(--color-text-muted); margin-bottom: 1.5rem; font-size: 0.9rem; }
.auth-card__forgot { display: block; text-align: center; margin-top: 1rem; font-size: 0.85rem; }
.auth-card__remember { display: flex; align-items: center; gap: 0.5rem; }
.auth-card__remember input { width: auto; display: inline; }

/* --- Notification bell --- */
.notification-bell { position: relative; }
.notification-bell__button { position: relative; background: none; border: none; font-size: 1.1rem; cursor: pointer; }
.notification-bell__badge { position: absolute; top: -4px; right: -6px; background: var(--color-danger); color: white; font-size: 0.65rem; padding: 0 4px; border-radius: 999px; }
.notification-bell__panel { position: absolute; right: 0; top: 130%; width: 320px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-md); z-index: 50; max-height: 360px; overflow-y: auto; }
.notification-bell__item { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--color-border); text-decoration: none; color: var(--color-text); font-size: 0.85rem; }
.notification-bell__item--unread { background: color-mix(in srgb, var(--color-info) 8%, transparent); }
.notification-bell__empty { padding: 1rem; color: var(--color-text-muted); font-size: 0.85rem; text-align: center; }

/* --- Kanban board --- */
.kanban-board { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: 1rem; }
.kanban-column { flex: 0 0 280px; background: var(--color-surface-alt); border-radius: var(--radius-md); padding: 0.75rem; }
.kanban-column__header { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 0.6rem; font-size: 0.88rem; }
.kanban-column__header--over-limit { color: var(--color-danger); }
.kanban-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 0.65rem; margin-bottom: 0.6rem; cursor: grab; box-shadow: var(--shadow-sm); }
.kanban-card__priority { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; }

/* --- Stat tiles (Dashboard) --- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-tile { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 1.1rem; text-decoration: none; color: var(--color-text); box-shadow: var(--shadow-sm); }
.stat-tile__value { font-size: 1.8rem; font-weight: 700; color: var(--color-primary); }
.stat-tile__label { font-size: 0.82rem; color: var(--color-text-muted); margin-top: 0.2rem; }

.not-found, .access-denied { padding: 2rem; text-align: center; color: var(--color-text-muted); }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.page-header h1 { margin: 0; }

.detail-grid { display: grid; grid-template-columns: 160px 1fr; row-gap: 0.6rem; margin: 0; }
.detail-grid dt { color: var(--color-text-muted); font-size: 0.85rem; }
.detail-grid dd { margin: 0; font-size: 0.92rem; }

@media (max-width: 900px) {
    .app-nav { position: fixed; left: -260px; height: 100%; z-index: 100; transition: left 0.2s ease; }
    .app-shell { flex-direction: column; }
}

/* --- Print (work orders, reports) --- */
@media print {
    .app-nav, .app-topbar, .no-print { display: none !important; }
    .app-shell, .app-main, .app-content { display: block !important; margin: 0 !important; padding: 0 !important; }
    body { background: #fff !important; color: #000 !important; }
    .card { box-shadow: none !important; border: 1px solid #ccc !important; break-inside: avoid; }
}
