/* ============================================================
   TRUCK DISPATCH — Professional Theme (Light + Dark)
   Color system inspired by modern SaaS dashboards.
============================================================ */

:root,
[data-theme="light"] {
    /* Brand */
    --brand: #6366f1;
    --brand-hover: #4f46e5;
    --brand-soft: rgba(99, 102, 241, 0.10);
    --brand-ring: rgba(99, 102, 241, 0.22);
    --brand-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --accent: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    /* Surfaces */
    --bg: #f1f5f9;
    --bg-subtle: #e2e8f0;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-hover: #f1f5f9;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --divider: #f1f5f9;

    /* Text */
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;

    /* Sidebar (stays dark in both themes for consistency) */
    --sidebar-bg: #0b1020;
    --sidebar-bg-2: #141a33;
    --sidebar-border: rgba(255, 255, 255, 0.06);
    --sidebar-text: #cbd5e1;
    --sidebar-text-muted: #64748b;
    --sidebar-hover: rgba(255, 255, 255, 0.06);
    --sidebar-active-glow: rgba(99, 102, 241, 0.45);

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow: 0 4px 12px -2px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 12px 32px -8px rgba(15, 23, 42, 0.14), 0 4px 12px rgba(15, 23, 42, 0.06);
    --shadow-brand: 0 8px 24px -6px rgba(99, 102, 241, 0.40);
    --shadow-ring: 0 0 0 3px var(--brand-ring);
}

[data-theme="dark"] {
    --brand: #818cf8;
    --brand-hover: #6366f1;
    --brand-soft: rgba(129, 140, 248, 0.14);
    --brand-ring: rgba(129, 140, 248, 0.28);
    --brand-gradient: linear-gradient(135deg, #818cf8 0%, #a78bfa 100%);
    --accent: #22d3ee;

    --bg: #0a0f1c;
    --bg-subtle: #0f172a;
    --surface: #121a2d;
    --surface-2: #0f172a;
    --surface-hover: #1a243e;
    --border: #1e2a47;
    --border-strong: #2d3b5f;
    --divider: #1a2442;

    --text: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;

    --sidebar-bg: #050814;
    --sidebar-bg-2: #0b1022;
    --sidebar-text: #cbd5e1;
    --sidebar-text-muted: #94a3b8;
    --sidebar-hover: rgba(129, 140, 248, 0.08);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.35), 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 12px 32px -8px rgba(0, 0, 0, 0.45), 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-brand: 0 8px 24px -6px rgba(129, 140, 248, 0.45);
}

/* ============================================================
   BASE
============================================================ */
* { box-sizing: border-box; }

html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background 0.2s ease, color 0.2s ease;
}

body {
    background-image:
        radial-gradient(circle at 0% 0%, rgba(99, 102, 241, 0.04) 0, transparent 45%),
        radial-gradient(circle at 100% 100%, rgba(6, 182, 212, 0.04) 0, transparent 45%);
    background-attachment: fixed;
}

[data-theme="dark"] body {
    background-image:
        radial-gradient(circle at 0% 0%, rgba(129, 140, 248, 0.06) 0, transparent 40%),
        radial-gradient(circle at 100% 100%, rgba(34, 211, 238, 0.04) 0, transparent 40%);
}

a { color: var(--brand); text-decoration: none; transition: color 0.15s ease; }
a:hover { color: var(--brand-hover); }

::selection { background: var(--brand-soft); color: var(--text); }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   APP SHELL
============================================================ */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ============================================================
   SIDEBAR — Deep gradient with glowing active state
============================================================ */
.app-sidebar {
    width: 268px;
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
    color: var(--sidebar-text);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: 22px 14px 22px;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 1px solid var(--sidebar-border);
    align-self: flex-start;
}

.app-sidebar::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.15) 0, transparent 30%),
        radial-gradient(circle at 0% 100%, rgba(139, 92, 246, 0.08) 0, transparent 40%);
    pointer-events: none;
}

.app-sidebar > * { position: relative; z-index: 1; }

.app-sidebar::-webkit-scrollbar { width: 4px; }
.app-sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border: none; }

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 10px 22px;
    border-bottom: 1px solid var(--sidebar-border);
    margin-bottom: 18px;
}

.brand-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-gradient);
    color: white;
    border-radius: 12px;
    font-size: 22px;
    box-shadow: 0 8px 20px -4px var(--sidebar-active-glow);
    position: relative;
}

.brand-icon::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 60%);
    border-radius: 12px;
    pointer-events: none;
}

.brand-title {
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.3px;
    line-height: 1.1;
}

.brand-subtitle {
    font-size: 10.5px;
    color: var(--sidebar-text-muted);
    font-weight: 600;
    margin-top: 3px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-section-title {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--sidebar-text-muted);
    text-transform: uppercase;
    letter-spacing: 1.3px;
    padding: 18px 12px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-section-title i { font-size: 13px; opacity: 0.85; }

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

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.sidebar-link i {
    font-size: 17px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.sidebar-link:hover:not(.disabled) {
    background: var(--sidebar-hover);
    color: #ffffff;
}

.sidebar-link:hover:not(.disabled) i {
    transform: scale(1.08);
}

.sidebar-link.active {
    background: var(--brand-gradient);
    color: #ffffff;
    box-shadow: 0 6px 18px -4px var(--sidebar-active-glow);
    font-weight: 600;
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: #ffffff;
    border-radius: 0 3px 3px 0;
    opacity: 0.9;
}

.sidebar-link.disabled {
    color: var(--sidebar-text-muted);
    cursor: not-allowed;
    opacity: 0.5;
}

/* Whole-row clickable list rows — wired by wwwroot/js/clickable-rows.js */
tr.clickable-row { cursor: pointer; }

/* ----- Collapsible parent groups (Master Data, Administration) ----- */
.sidebar-group {
    display: flex;
    flex-direction: column;
}

.sidebar-group-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--sidebar-text);
    font-size: 13.5px;
    font-weight: 500;
    background: transparent;
    border: 0;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-group-toggle:hover {
    background: var(--sidebar-hover);
    color: #ffffff;
}

.sidebar-group-toggle > i:first-child {
    font-size: 17px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.sidebar-group-toggle:hover > i:first-child {
    transform: scale(1.08);
}

.sidebar-group-toggle .group-chevron {
    margin-left: auto;
    font-size: 11px;
    width: auto;
    opacity: 0.7;
    transition: transform 0.22s ease;
}

.sidebar-group.open > .sidebar-group-toggle .group-chevron {
    transform: rotate(90deg);
    opacity: 1;
}

.sidebar-group-toggle.active-parent {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
}

.sidebar-group-children {
    overflow: hidden;
    max-height: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: max-height 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-group.open > .sidebar-group-children {
    max-height: 600px;
    margin-top: 4px;
}

.sidebar-group-children .sidebar-link {
    padding-left: 38px;
    font-size: 13px;
    border-radius: 8px;
}

.sidebar-group-children .sidebar-link i {
    font-size: 15px;
    width: 18px;
}

.badge-soon {
    margin-left: auto;
    font-size: 9px;
    font-weight: 700;
    padding: 3px 8px;
    background: rgba(148, 163, 184, 0.12);
    color: #94a3b8;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border: 1px solid rgba(148, 163, 184, 0.15);
}

/* ============================================================
   MAIN + TOPBAR
============================================================ */
.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    height: 66px;
    padding: 0 28px;
    display: flex;
    align-items: center;
    gap: 14px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: saturate(1.5);
}

.btn-icon {
    background: transparent;
    border: 1px solid transparent;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

.btn-icon:hover {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--border);
}

.btn-icon:focus { outline: none; box-shadow: var(--shadow-ring); }

.breadcrumb-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.breadcrumb-bar a { color: var(--text-muted); }
.breadcrumb-bar a:hover { color: var(--brand); }
.breadcrumb-bar .current { color: var(--text); font-weight: 600; }
.breadcrumb-bar .separator { color: var(--border-strong); font-size: 10px; }

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: 1px solid transparent;
    padding: 5px 12px 5px 5px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.user-btn:hover {
    background: var(--surface-hover);
    border-color: var(--border);
}

.user-btn::after { margin-left: 4px; opacity: 0.5; }

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--brand-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
    box-shadow: 0 4px 10px -2px var(--brand-ring);
}

.user-info { text-align: left; line-height: 1.2; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text); }
.user-role {
    font-size: 10.5px;
    color: var(--brand);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dropdown-menu {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 6px;
    font-size: 13.5px;
}

.dropdown-item {
    color: var(--text);
    border-radius: 8px;
    padding: 8px 12px;
}

.dropdown-item:hover { background: var(--surface-hover); color: var(--text); }
.dropdown-item-text { color: var(--text); padding: 6px 12px; }
.dropdown-divider { border-color: var(--border); }

/* ============================================================
   CONTENT
============================================================ */
.app-content {
    padding: 28px;
    flex: 1;
}

/* ============================================================
   PAGE HEADER
============================================================ */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
}

.page-title-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--brand-soft);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    position: relative;
}

.page-title-icon::after {
    content: '';
    position: absolute;
    inset: -1px;
    background: var(--brand-gradient);
    border-radius: 13px;
    opacity: 0.15;
    z-index: -1;
}

.page-header-left h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    letter-spacing: -0.5px;
}

.page-header-left p {
    font-size: 13.5px;
    color: var(--text-muted);
    margin: 3px 0 0;
}

/* ============================================================
   STAT CARDS
============================================================ */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--border-strong);
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 120px;
    height: 120px;
    background: var(--stat-accent, var(--brand-soft));
    filter: blur(40px);
    opacity: 0.4;
    pointer-events: none;
}

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

.stat-label {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    position: relative;
    z-index: 1;
}

.stat-icon.brand { background: var(--brand-soft); color: var(--brand); }
.stat-icon.success { background: rgba(16, 185, 129, 0.12); color: var(--success); }
.stat-icon.warning { background: rgba(245, 158, 11, 0.12); color: var(--warning); }
.stat-icon.accent { background: rgba(6, 182, 212, 0.12); color: var(--accent); }

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.8px;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-meta.positive { color: var(--success); }

/* ============================================================
   CARDS
============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    padding: 18px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.card-header h5 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body { padding: 22px; }

/* ============================================================
   TABLES
============================================================ */
.table-pro {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table-pro thead th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 13px 18px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    user-select: none;
}

.table-pro thead th.sortable { cursor: pointer; }
.table-pro thead th.sortable:hover { color: var(--text); background: var(--surface-hover); }
.table-pro thead th .sort-ind { opacity: 0.4; margin-left: 4px; font-size: 10px; }
.table-pro thead th.asc .sort-ind,
.table-pro thead th.desc .sort-ind { opacity: 1; color: var(--brand); }

.table-pro tbody td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--divider);
    font-size: 13.5px;
    color: var(--text);
    vertical-align: middle;
}

.table-pro tbody tr:last-child td { border-bottom: none; }
.table-pro tbody tr { transition: background-color 0.12s ease; }
.table-pro tbody tr:hover { background: var(--surface-hover); }
.table-pro tbody tr.selected { background: var(--brand-soft); }

.table-empty {
    text-align: center;
    padding: 56px 20px;
    color: var(--text-muted);
}

.table-empty-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--brand-soft);
    color: var(--brand);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 14px;
    position: relative;
}

.table-empty-icon::after {
    content: '';
    position: absolute;
    inset: -6px;
    border: 1.5px dashed var(--brand-soft);
    border-radius: 22px;
    opacity: 0.5;
}

.table-empty h6 { font-weight: 700; color: var(--text); margin: 0 0 4px; font-size: 16px; }

.id-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--text-secondary);
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    border: 1px solid var(--border);
}

/* ============================================================
   BUTTONS
============================================================ */
.btn {
    font-weight: 600;
    font-size: 13px;
    padding: 9px 16px;
    border-radius: 10px;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid transparent;
    letter-spacing: 0.1px;
}

.btn:focus { box-shadow: var(--shadow-ring); outline: none; }

.btn-primary {
    background: var(--brand-gradient);
    border-color: transparent;
    color: #ffffff;
    box-shadow: 0 2px 6px -1px var(--brand-ring);
}

.btn-primary:hover {
    color: #ffffff;
    box-shadow: var(--shadow-brand);
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.btn-secondary {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--surface-hover);
    border-color: var(--border-strong);
    color: var(--text);
}

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

.btn-danger:hover { background: #dc2626; border-color: #dc2626; color: white; }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 22px; font-size: 14px; }

.btn-outline-primary { border-color: var(--brand); color: var(--brand); background: transparent; }
.btn-outline-primary:hover { background: var(--brand); color: white; }
.btn-outline-danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn-outline-danger:hover { background: var(--danger); color: white; }

.btn-action {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 14px;
    transition: all 0.15s ease;
}

.btn-action:hover { background: var(--surface-hover); color: var(--text); transform: translateY(-1px); }
.btn-action.edit:hover { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); }
.btn-action.delete:hover { color: var(--danger); border-color: var(--danger); background: rgba(239, 68, 68, 0.1); }

/* ============================================================
   FORMS
============================================================ */
.form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    letter-spacing: 0;
    text-transform: none;
}

.form-label .req { color: var(--danger); font-weight: 700; margin-left: 2px; }

.form-control, .form-select {
    border: 1px solid var(--border) !important;
    border-radius: 10px !important;
    padding: 11px 14px !important;
    font-size: 14px !important;
    color: var(--text) !important;
    background: var(--surface) !important;
    transition: all 0.15s ease !important;
    width: 100%;
}

.form-control::placeholder { color: var(--text-muted); }

.form-control:focus, .form-select:focus {
    border-color: var(--brand) !important;
    box-shadow: var(--shadow-ring) !important;
    outline: none !important;
    background: var(--surface) !important;
}

.input-group-pro {
    position: relative;
}

.input-group-pro .form-control {
    padding-left: 42px !important;
}

.input-group-pro .input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 16px;
    pointer-events: none;
    z-index: 1;
}

.input-group-pro .form-control:focus + .input-icon,
.input-group-pro:focus-within .input-icon { color: var(--brand); }

.text-danger.field-validation-error { font-size: 12px; margin-top: 5px; display: block; color: var(--danger) !important; font-weight: 500; }

.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; }

/* ============================================================
   SEARCH + TOOLBAR
============================================================ */
.search-box {
    position: relative;
    max-width: 340px;
    flex: 1;
}

.search-box input {
    padding-left: 42px !important;
    padding-right: 40px !important;
    height: 40px !important;
    background: var(--surface-2) !important;
}

.search-box input:focus { background: var(--surface) !important; }

.search-box .search-ic {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 15px;
    pointer-events: none;
}

.search-box .search-kbd {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    font-weight: 600;
    padding: 3px 7px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text-muted);
    letter-spacing: 0.3px;
    pointer-events: none;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* ============================================================
   BADGES + CHIPS
============================================================ */
.badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 11px;
    font-size: 11.5px;
    font-weight: 600;
    border-radius: 20px;
    background: var(--brand-soft);
    color: var(--brand);
}

.count-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 20px;
    background: var(--surface-2);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.count-pill .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

/* ============================================================
   ALERTS
============================================================ */
.alert {
    border-radius: 12px;
    border: 1px solid;
    padding: 12px 16px;
    font-size: 13.5px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.25);
    color: var(--success);
}

[data-theme="dark"] .alert-success { background: rgba(16, 185, 129, 0.1); }

.alert-danger {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.25);
    color: var(--danger);
}

/* ============================================================
   MODAL
============================================================ */
.modal-pro-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    z-index: 1055;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-pro-overlay.show { display: flex; animation: fadeIn 0.15s ease; }

.modal-pro {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    max-width: 420px;
    width: 100%;
    padding: 28px;
    border: 1px solid var(--border);
    animation: popIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-pro-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    margin: 0 auto 16px;
}

.modal-pro h4 { font-size: 18px; font-weight: 700; text-align: center; margin-bottom: 6px; color: var(--text); }
.modal-pro p { text-align: center; color: var(--text-muted); margin-bottom: 20px; font-size: 13.5px; }
.modal-pro .modal-actions { display: flex; gap: 10px; }
.modal-pro .modal-actions .btn { flex: 1; justify-content: center; }

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

/* ============================================================
   AUTH (Login)
============================================================ */
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #0b1020 0%, #1e1b4b 50%, #3b0764 100%);
}

.auth-shell::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.25) 0, transparent 35%),
        radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.22) 0, transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(6, 182, 212, 0.1) 0, transparent 50%);
    animation: authGlow 12s ease-in-out infinite alternate;
}

@keyframes authGlow {
    0% { opacity: 0.8; transform: scale(1); }
    100% { opacity: 1; transform: scale(1.05); }
}

.auth-shell::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 60 60'%3E%3Cg fill='none' stroke='rgba(255,255,255,0.03)' stroke-width='1'%3E%3Cpath d='M0 30h60M30 0v60'/%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}

.auth-card {
    position: relative;
    z-index: 2;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 20px;
    padding: 44px 40px 36px;
    max-width: 440px;
    width: 100%;
    box-shadow:
        0 30px 80px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.05);
}

.auth-brand {
    text-align: center;
    padding-bottom: 26px;
    margin-bottom: 26px;
    border-bottom: 1px solid var(--border);
}

.auth-brand-icon {
    width: 68px;
    height: 68px;
    border-radius: 18px;
    background: var(--brand-gradient);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    margin-bottom: 16px;
    box-shadow: 0 14px 32px -6px rgba(99, 102, 241, 0.5);
    position: relative;
}

.auth-brand-icon::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.3) 0%, transparent 60%);
    border-radius: 18px;
}

.auth-brand-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.4px;
}

.auth-brand-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 700;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.auth-heading {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    text-align: center;
    margin: 0 0 6px;
    letter-spacing: -0.4px;
}

.auth-subheading {
    font-size: 13.5px;
    color: var(--text-muted);
    text-align: center;
    margin: 0 0 28px;
}

.alert-login-error {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: var(--danger);
    border-radius: 10px;
    padding: 11px 14px;
    margin-bottom: 18px;
    font-size: 13px;
    font-weight: 500;
}

.alert-login-error:empty { display: none; }
.alert-login-error ul { margin: 0; padding: 0; list-style: none; }

.auth-field { margin-bottom: 16px; }

.auth-label {
    display: block;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 7px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.auth-input-wrap { position: relative; }

.auth-input {
    height: 48px !important;
    padding-left: 44px !important;
    padding-right: 46px !important;
    font-size: 14px !important;
    border-radius: 10px !important;
    border: 1px solid var(--border) !important;
    background: var(--surface-2) !important;
    transition: all 0.15s ease !important;
}

.auth-input:focus {
    background: var(--surface) !important;
    border-color: var(--brand) !important;
    box-shadow: var(--shadow-ring) !important;
}

.auth-input-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 17px;
    pointer-events: none;
    transition: color 0.15s ease;
}

.auth-input-wrap:focus-within .auth-input-icon { color: var(--brand); }

.auth-toggle-pass {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-toggle-pass:hover { background: var(--surface-hover); color: var(--text); }
.auth-error { font-size: 12px; margin-top: 5px; display: block; color: var(--danger); font-weight: 500; }

.auth-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 8px 0 22px;
}

.auth-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    user-select: none;
    margin: 0;
}

.auth-checkbox input {
    width: 16px;
    height: 16px;
    accent-color: var(--brand);
    cursor: pointer;
    margin: 0;
}

.auth-submit {
    width: 100%;
    height: 48px;
    font-size: 14px;
    font-weight: 600;
    justify-content: center;
    border-radius: 10px;
    letter-spacing: 0.3px;
}

.auth-footer {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    letter-spacing: 0.5px;
}

/* ============================================================
   SIDEBAR TOGGLE + RESPONSIVE
============================================================ */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    z-index: 1040;
    display: none;
}

@media (max-width: 991px) {
    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }
    .app-shell.sidebar-open .app-sidebar { transform: translateX(0); }
    .app-shell.sidebar-open .sidebar-backdrop { display: block; }
}

@media (min-width: 992px) {
    .app-shell.sidebar-collapsed .app-sidebar { width: 78px; padding: 22px 10px; }
    .app-shell.sidebar-collapsed .brand-text,
    .app-shell.sidebar-collapsed .sidebar-link span,
    .app-shell.sidebar-collapsed .sidebar-section-title,
    .app-shell.sidebar-collapsed .sidebar-group-toggle span,
    .app-shell.sidebar-collapsed .sidebar-group-toggle .group-chevron,
    .app-shell.sidebar-collapsed .badge-soon { display: none; }
    .app-shell.sidebar-collapsed .sidebar-link,
    .app-shell.sidebar-collapsed .sidebar-group-toggle { justify-content: center; padding: 12px; }
    .app-shell.sidebar-collapsed .sidebar-group-children .sidebar-link { padding-left: 12px; }
    /* In collapsed mode, force all groups visually open so user sees a flat icon list with tooltips */
    .app-shell.sidebar-collapsed .sidebar-group > .sidebar-group-children { max-height: none; margin-top: 4px; }
    .app-shell.sidebar-collapsed .brand { justify-content: center; }
}

/* ============================================================
   UTILITIES
============================================================ */
.text-muted { color: var(--text-muted) !important; }
.text-primary { color: var(--brand) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }

.hstack { display: flex; align-items: center; gap: 10px; }
.vstack { display: flex; flex-direction: column; gap: 10px; }

.d-inline { display: inline; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

.fade-in { animation: fadeIn 0.25s ease; }

/* ============================================================
   TOASTS
============================================================ */
.toast-stack {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 420px;
    pointer-events: none;
}
.toast-item {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: flex-start;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 14px 14px 16px;
    box-shadow: var(--shadow-lg);
    transform: translateX(120%);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(.2,.9,.3,1.2), opacity 0.2s ease;
    pointer-events: auto;
    overflow: hidden;
    min-width: 320px;
}
.toast-item.toast-shown { transform: translateX(0); opacity: 1; }
.toast-item.toast-dismissing { transform: translateX(20%); opacity: 0; }
.toast-item .toast-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.toast-item .toast-body { min-width: 0; }
.toast-item .toast-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--text);
    margin: 0 0 2px;
}
.toast-item .toast-message {
    font-size: 13px;
    color: var(--text-secondary);
    word-wrap: break-word;
    line-height: 1.5;
}
.toast-item .toast-close {
    background: transparent;
    border: 0;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    font-size: 12px;
    border-radius: 6px;
    transition: all 0.15s ease;
    flex-shrink: 0;
}
.toast-item .toast-close:hover { color: var(--text); background: var(--surface-hover); }
.toast-item .toast-progress {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 3px;
    background: currentColor;
    opacity: 0.35;
    transform-origin: left;
    animation: toastProgress linear forwards;
}
@keyframes toastProgress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}
.toast-success { border-left: 4px solid var(--success); }
.toast-success .toast-icon { background: rgba(16,185,129,0.14); color: var(--success); }
.toast-success .toast-progress { color: var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-error .toast-icon { background: rgba(239,68,68,0.14); color: var(--danger); }
.toast-error .toast-progress { color: var(--danger); }
.toast-warn { border-left: 4px solid var(--warning); }
.toast-warn .toast-icon { background: rgba(245,158,11,0.14); color: var(--warning); }
.toast-warn .toast-progress { color: var(--warning); }
.toast-info { border-left: 4px solid var(--accent); }
.toast-info .toast-icon { background: rgba(6,182,212,0.14); color: var(--accent); }
.toast-info .toast-progress { color: var(--accent); }

/* ============================================================
   PAGE OVERLAY / LOADING BAR
============================================================ */
.page-loader {
    position: fixed;
    top: 0; left: 0;
    height: 3px; width: 100%;
    z-index: 10001;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.page-loader.active { opacity: 1; }
.page-loader::before {
    content: "";
    display: block;
    height: 100%;
    width: 30%;
    background: var(--brand-gradient);
    box-shadow: 0 0 12px rgba(99,102,241,0.6);
    animation: pageLoaderSlide 1.1s ease-in-out infinite;
}
@keyframes pageLoaderSlide {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(200%); }
    100% { transform: translateX(400%); }
}
.submit-spinner {
    display: inline-block;
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-right: 8px;
    vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   BULK ACTION BAR
============================================================ */
.bulk-bar {
    display: none;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    background: var(--brand-soft);
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
}
.bulk-bar.active { display: flex; }
.bulk-bar .count-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--brand-gradient);
    color: #fff;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}
.bulk-bar .spacer { flex: 1; }
.table-pro thead tr th.selcol,
.table-pro tbody tr td.selcol {
    width: 44px;
    padding-left: 18px;
    padding-right: 0;
}
.td-check {
    width: 16px; height: 16px;
    accent-color: var(--brand);
    cursor: pointer;
}

/* ============================================================
   PAGINATION
============================================================ */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 0 0 14px 14px;
    font-size: 13px;
    color: var(--text-secondary);
}
.pagination-bar .page-nav {
    display: flex;
    gap: 6px;
    align-items: center;
}
.page-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s ease;
}
.page-btn:hover:not(.disabled):not(.active) {
    border-color: var(--brand);
    color: var(--brand);
    background: var(--brand-soft);
}
.page-btn.active {
    background: var(--brand-gradient);
    border-color: transparent;
    color: #fff;
    box-shadow: var(--shadow-brand);
}
.page-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}
.page-size-select {
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    padding: 0 10px;
    font-size: 13px;
    cursor: pointer;
}
.page-size-select:focus { outline: none; border-color: var(--brand); box-shadow: var(--shadow-ring); }
.page-ellipsis {
    min-width: 28px;
    text-align: center;
    color: var(--text-muted);
    user-select: none;
}

/* ============================================================
   COMMAND PALETTE
============================================================ */
.cmdk-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(10,15,28,0.55);
    backdrop-filter: blur(6px);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12vh;
    animation: fadeIn 0.15s ease;
}
.cmdk-overlay.show { display: flex; }
.cmdk {
    width: 100%;
    max-width: 640px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: popIn 0.2s cubic-bezier(.2,.9,.3,1.2);
}
.cmdk-input-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}
.cmdk-input-wrap i { color: var(--text-muted); font-size: 18px; }
.cmdk-input {
    flex: 1;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: 16px;
    font-weight: 500;
}
.cmdk-input::placeholder { color: var(--text-muted); }
.cmdk-esc {
    font-size: 11px;
    padding: 3px 8px;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-weight: 600;
}
.cmdk-list {
    max-height: 50vh;
    overflow-y: auto;
    padding: 8px;
}
.cmdk-section {
    padding: 10px 12px 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}
.cmdk-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text);
    font-size: 14px;
    text-decoration: none;
}
.cmdk-item .cmdk-ic {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: var(--brand-soft);
    color: var(--brand);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.cmdk-item .cmdk-label { flex: 1; font-weight: 500; }
.cmdk-item .cmdk-sub { font-size: 11px; color: var(--text-muted); }
.cmdk-item.active,
.cmdk-item:hover { background: var(--surface-hover); }
.cmdk-item.active .cmdk-ic { background: var(--brand-gradient); color: #fff; }
.cmdk-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* ============================================================
   DROPDOWN THEME TWEAKS (Bootstrap override)
============================================================ */
.dropdown-menu {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    border-radius: 12px;
    padding: 6px;
}
.dropdown-item { color: var(--text); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.dropdown-item:hover { background: var(--surface-hover); color: var(--text); }
.dropdown-item-text { padding: 6px 10px; }
.dropdown-divider { border-color: var(--border); margin: 6px 0; }

/* ============================================================
   FORMS EXTRAS
============================================================ */
.form-help {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 768px) {
    .field-row { grid-template-columns: 1fr; }
}

/* ============================================================
   ACTIVITY FEED
============================================================ */
.activity-list { display: flex; flex-direction: column; gap: 2px; }
.activity-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 14px;
    align-items: flex-start;
    padding: 14px 18px;
    border-bottom: 1px solid var(--divider);
    transition: background 0.15s ease;
}
.activity-row:hover { background: var(--surface-hover); }
.activity-row:last-child { border-bottom: 0; }
.activity-ic {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}
.activity-ic.act-create { background: rgba(16,185,129,0.14); color: var(--success); }
.activity-ic.act-update { background: rgba(6,182,212,0.14); color: var(--accent); }
.activity-ic.act-delete { background: rgba(239,68,68,0.14); color: var(--danger); }
.activity-ic.act-restore { background: rgba(99,102,241,0.14); color: var(--brand); }
.activity-ic.act-export { background: rgba(245,158,11,0.14); color: var(--warning); }
.activity-ic.act-login, .activity-ic.act-logout { background: rgba(139,92,246,0.14); color: #8b5cf6; }
.activity-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}
.activity-row .activity-desc { font-size: 13px; color: var(--text); font-weight: 500; }
.activity-time { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ============================================================
   ERROR PAGES
============================================================ */
.error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 40px 20px;
    text-align: center;
}
.error-code {
    font-size: 128px;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1;
    background: var(--brand-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 12px;
}
.error-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}
.error-desc {
    font-size: 15px;
    color: var(--text-secondary);
    max-width: 480px;
    margin-bottom: 28px;
}

/* ============================================================
   DANGER ZONE
============================================================ */
.danger-zone {
    border: 1px solid rgba(239,68,68,0.28);
    background: rgba(239,68,68,0.05);
    border-radius: 14px;
    padding: 18px;
    margin-top: 20px;
}
.danger-zone h6 { color: var(--danger); font-weight: 700; margin: 0 0 6px; font-size: 14px; }
.danger-zone p { font-size: 13px; color: var(--text-secondary); margin: 0 0 12px; }

/* ============================================================
   DENSITY MODES
============================================================ */
[data-density="compact"] .table-pro th,
[data-density="compact"] .table-pro td { padding: 8px 12px; }
[data-density="compact"] .card-body,
[data-density="compact"] .card-header { padding: 12px 16px; }
[data-density="comfortable"] .table-pro th,
[data-density="comfortable"] .table-pro td { padding: 14px 16px; }

/* ============================================================
   SIDEBAR LINK TWEAKS
============================================================ */
.sidebar-link .badge-trash {
    margin-left: auto;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(239,68,68,0.18);
    color: #fca5a5;
}

/* ============================================================
   ENTITY PICKER
============================================================ */
.ep-control { position: relative; }
.ep-control .input-group-pro input.ep-display {
    cursor: pointer;
    background: var(--surface);
}
.ep-control .input-group-pro input.ep-display:focus {
    cursor: pointer;
}
.ep-control .ep-actions {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    display: flex;
    gap: 2px;
    align-items: center;
    z-index: 3;
}
.ep-control .ep-actions .btn {
    padding: 4px 8px;
    line-height: 1;
    border-radius: 6px;
}
.ep-control .input-group-pro input.ep-display {
    padding-right: 76px;
}
#entityPickerModal .ep-table thead th {
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
#entityPickerModal .ep-table tbody tr { transition: background 0.12s ease; }
#entityPickerModal .ep-table tbody tr:hover { background: var(--surface-hover); }
#entityPickerModal .ep-table tbody td { vertical-align: middle; font-size: 13.5px; }
#entityPickerModal .modal-body { padding-top: 16px; }
#entityPickerModal .ep-table-wrap { max-height: 50vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; }

/* ============================================================
   VALIDATION — visible error states
============================================================ */
.form-control.is-invalid,
.form-select.is-invalid,
.form-control.input-validation-error,
.form-select.input-validation-error {
    border-color: var(--danger) !important;
    background-image: none !important;
    padding-right: 14px !important;
}

.form-control.is-invalid:focus,
.form-select.is-invalid:focus,
.form-control.input-validation-error:focus,
.form-select.input-validation-error:focus {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18) !important;
}

.input-group-pro:has(.is-invalid) .input-icon,
.input-group-pro:has(.input-validation-error) .input-icon { color: var(--danger); }

.invalid-feedback,
.field-validation-error,
.text-danger.field-validation-error {
    display: block;
    font-size: 12px;
    margin-top: 5px;
    color: var(--danger) !important;
    font-weight: 500;
    line-height: 1.4;
}

.invalid-feedback::before,
.field-validation-error::before {
    content: "\F32A";
    font-family: "bootstrap-icons";
    margin-right: 5px;
    font-size: 11px;
    vertical-align: -1px;
}

.required-legend {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 14px;
    padding: 6px 10px;
    background: var(--surface-2);
    border: 1px dashed var(--border);
    border-radius: 8px;
}

.required-legend .req { color: var(--danger); font-weight: 700; }

/* ============================================================
   STATUS PILLS — reusable classes
============================================================ */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 11px;
    font-size: 11.5px;
    font-weight: 600;
    border-radius: 20px;
    background: rgba(148, 163, 184, 0.16);
    color: var(--text-muted);
    line-height: 1.4;
    letter-spacing: 0.2px;
}

.status-pill.status-pending,
.status-pill.status-onleave { background: rgba(245, 158, 11, 0.14); color: #d97706; }
[data-theme="dark"] .status-pill.status-pending,
[data-theme="dark"] .status-pill.status-onleave { color: #fbbf24; }

.status-pill.status-assigned,
.status-pill.status-printed { background: rgba(99, 102, 241, 0.14); color: var(--brand); }

.status-pill.status-intransit,
.status-pill.status-inprogress { background: rgba(6, 182, 212, 0.14); color: #0891b2; }
[data-theme="dark"] .status-pill.status-intransit,
[data-theme="dark"] .status-pill.status-inprogress { color: #22d3ee; }

.status-pill.status-delivered,
.status-pill.status-active,
.status-pill.status-finished { background: rgba(16, 185, 129, 0.14); color: #059669; }
[data-theme="dark"] .status-pill.status-delivered,
[data-theme="dark"] .status-pill.status-active,
[data-theme="dark"] .status-pill.status-finished { color: #34d399; }

.status-pill.status-cancelled,
.status-pill.status-inactive,
.status-pill.status-retired,
.status-pill.status-outofservice { background: rgba(239, 68, 68, 0.14); color: #dc2626; }
[data-theme="dark"] .status-pill.status-cancelled,
[data-theme="dark"] .status-pill.status-inactive,
[data-theme="dark"] .status-pill.status-retired,
[data-theme="dark"] .status-pill.status-outofservice { color: #f87171; }

.status-pill.status-maintenance { background: rgba(139, 92, 246, 0.14); color: #7c3aed; }
[data-theme="dark"] .status-pill.status-maintenance { color: #a78bfa; }

/* ============================================================
   PICKER FIELD AFFORDANCE — show it's clickable
============================================================ */
.ep-control .input-group-pro input.ep-display {
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.ep-control:hover .input-group-pro input.ep-display:not(:disabled) {
    border-color: var(--brand-ring) !important;
    background: var(--surface-hover) !important;
}

.ep-control .input-group-pro input.ep-display::placeholder {
    font-style: italic;
    opacity: 0.85;
}

/* ============================================================
   SIDEBAR COLLAPSED TOOLTIPS
============================================================ */
@media (min-width: 992px) {
    .app-shell.sidebar-collapsed .sidebar-link,
    .app-shell.sidebar-collapsed .sidebar-group-toggle {
        position: relative;
    }
    .app-shell.sidebar-collapsed .sidebar-group-toggle[data-tip]::after,
    .app-shell.sidebar-collapsed .sidebar-link[data-tip]::after {
        content: attr(data-tip);
        position: absolute;
        left: calc(100% + 10px);
        top: 50%;
        transform: translateY(-50%);
        background: var(--text);
        color: var(--surface);
        font-size: 12px;
        font-weight: 600;
        padding: 6px 10px;
        border-radius: 8px;
        white-space: nowrap;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.15s ease, transform 0.15s ease;
        z-index: 1060;
        box-shadow: var(--shadow);
    }
    .app-shell.sidebar-collapsed .sidebar-group-toggle[data-tip]:hover::after,
    .app-shell.sidebar-collapsed .sidebar-link[data-tip]:hover::after {
        opacity: 1;
        transform: translateY(-50%) translateX(2px);
    }
}

/* ============================================================
   RESPONSIVE TABLE UTILITIES
============================================================ */
@media (max-width: 767px) {
    .hide-sm-down { display: none !important; }
    .table-pro thead th,
    .table-pro tbody td { padding: 10px 12px; font-size: 13px; }
}

@media (max-width: 991px) {
    .hide-md-down { display: none !important; }
}

@media (max-width: 1199px) {
    .hide-lg-down { display: none !important; }
}

/* Hint that a table is scrollable horizontally */
.table-responsive {
    position: relative;
    -webkit-overflow-scrolling: touch;
}

/* ============================================================
   FORM SECTION DIVIDER + POLISH
============================================================ */
.form-section-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 18px 0 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.form-section-divider::before,
.form-section-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.form-hint, .form-text {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 5px;
    line-height: 1.5;
}

/* ============================================================
   BTN-ACTION A11Y — focus ring
============================================================ */
.btn-action:focus-visible {
    outline: none;
    box-shadow: var(--shadow-ring);
    border-color: var(--brand);
}

/* ============================================================
   SKIP LINK (a11y)
============================================================ */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--brand);
    color: #fff;
    padding: 10px 16px;
    z-index: 10002;
    border-radius: 0 0 8px 0;
    font-weight: 600;
}
.skip-link:focus { left: 0; color: #fff; }

/* ============================================================
   TIPS CARD (Create-form sidebar tips)
============================================================ */
.tips-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 13px;
}
.tips-list li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 7px 0;
    color: var(--text-secondary);
    line-height: 1.5;
}
.tips-list li i { color: var(--success); flex-shrink: 0; margin-top: 2px; }

/* ============================================================
   FORM ACTIONS ROW — consistent footer
============================================================ */
.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid var(--border);
    padding-top: 20px;
    margin-top: 6px;
    flex-wrap: wrap;
}

/* ============================================================
   CHECKBOX LIST (driver list etc.)
============================================================ */
.checkbox-list {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px;
    background: var(--surface-2);
}
.checkbox-list .form-check {
    padding: 6px 10px;
    border-radius: 8px;
    margin: 0;
    transition: background 0.12s ease;
}
.checkbox-list .form-check:hover { background: var(--surface-hover); }
.checkbox-list .form-check-input { accent-color: var(--brand); }

/* ============================================================
   DARK THEME ADJUSTMENTS
============================================================ */
[data-theme="dark"] .required-legend {
    background: rgba(148, 163, 184, 0.06);
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] textarea.form-control {
    background: var(--surface-2) !important;
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background: var(--surface) !important;
}

[data-theme="dark"] .auth-card {
    background: var(--surface);
    color: var(--text);
}

[data-theme="dark"] .auth-card .auth-brand-title,
[data-theme="dark"] .auth-card .auth-heading { color: var(--text); }

/* ============================================================
   MOTION — respect user preference
============================================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}
