:root {
    --sheriff-blue: #1a2f5a;
    --sheriff-blue-light: #243d75;
    --sheriff-gold: #c8a63e;
    --sheriff-bg: #f0f3f8;
}

html { font-size: 14px; }
@media (min-width: 768px) { html { font-size: 16px; } }

html { position: relative; min-height: 100%; }
body { margin-bottom: 0; background-color: var(--sheriff-bg); }

/* Navbar */
.bg-sheriff { background-color: var(--sheriff-blue) !important; }

/* Page headers */
.page-header {
    background: var(--sheriff-blue);
    color: #fff;
    padding: 0.9rem 1.25rem;
    border-radius: 6px;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.page-header h4, .page-header h5 { margin: 0; }

/* Section cards */
.section-card {
    background: #fff;
    border: 1px solid #dde3ec;
    border-radius: 6px;
    margin-bottom: 1rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.section-card .card-header {
    background-color: var(--sheriff-blue);
    color: #fff;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 0.45rem 1rem;
    border-radius: 5px 5px 0 0;
}
.section-card .card-header i { opacity: 0.85; }
.section-card .card-body { padding: 0.9rem 1rem; }

/* Scan box */
.scan-box {
    font-family: Consolas, monospace;
    font-size: 0.78rem;
    background: #0d1117;
    color: #3fb950;
    border: 1.5px solid #3fb950;
    border-radius: 4px;
    resize: vertical;
}
.scan-box:focus {
    background: #0d1117;
    color: #3fb950;
    border-color: #3fb950;
    box-shadow: 0 0 0 0.15rem rgba(63,185,80,0.3);
}

/* Form labels */
.form-label { font-size: 0.78rem; font-weight: 600; color: #4a5568; margin-bottom: 0.2rem; }
.form-control-sm, .form-select-sm { font-size: 0.85rem; }

/* Violation rows */
.violation-row {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
}
.violation-row:last-child { margin-bottom: 0; }

/* Fine display */
.fine-display {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    padding: 0.75rem 1rem;
}

/* Tables */
.table thead th {
    background-color: var(--sheriff-blue);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    border-color: var(--sheriff-blue-light);
    white-space: nowrap;
}
.table-hover tbody tr:hover { background-color: #c8d8f8 !important; color: #0a192f !important; cursor: pointer; }
.table-hover tbody tr.table-danger:hover { background-color: #f5b0b5 !important; color: #4a0010 !important; }
.badge-citation { font-family: monospace; font-size: 0.9rem; letter-spacing: 0.05em; }

/* Sortable column headers */
.sort-link {
    color: #fff;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.sort-link:hover { color: var(--sheriff-gold); }

/* Scrollable table body — thead stays fixed */
.table-scroll { max-height: 62vh; overflow-y: auto; }
.table-scroll thead th { position: sticky; top: 0; z-index: 2; }

/* Pagination — theme to sheriff blue */
.pagination .page-link {
    color: var(--sheriff-blue);
    border-color: #dde3ec;
}
.pagination .page-item.active .page-link {
    background-color: var(--sheriff-blue);
    border-color: var(--sheriff-blue);
    color: #fff;
}
.pagination .page-link:hover { background-color: #e8f0fe; color: var(--sheriff-blue); }
.pagination .page-item.disabled .page-link { color: #adb5bd; }

/* Detail rows */
.detail-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #718096;
    letter-spacing: 0.06em;
}
.detail-value { font-size: 0.9rem; color: #1a202c; }

/* Checkbox groups */
.check-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    padding: 0.5rem 0;
}
.check-group .form-check { margin: 0; padding-left: 1.5rem; }
.check-group .form-check-label { font-size: 0.82rem; cursor: pointer; }

/* Dark checkboxes — print clearly in black & white */
.form-check-input {
    accent-color: #1a2f5a;
}
@media print {
    .form-check-input {
        accent-color: #000 !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
}

/* Buttons */
.btn-sheriff {
    background-color: var(--sheriff-blue);
    border-color: var(--sheriff-blue);
    color: #fff;
}
.btn-sheriff:hover {
    background-color: var(--sheriff-blue-light);
    border-color: var(--sheriff-blue-light);
    color: #fff;
}

/* Focus styles */
.btn:focus, .btn:active:focus, .form-control:focus, .form-check-input:focus, .form-select:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

/* Citation number display */
.citation-number-display {
    font-size: 1.3rem;
    font-family: monospace;
    font-weight: 700;
    color: var(--sheriff-blue);
    letter-spacing: 0.1em;
}

/* Footer */
.footer { margin-top: auto; }

/* ── Dashboard Stat Cards ───────────────────────────────────────────────── */
.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 1.1rem 1.25rem;
    border-left: 5px solid #ccc;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.stat-card .stat-value {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1;
    color: var(--sheriff-blue);
}
.stat-card .stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #718096;
    margin-top: 0.35rem;
}
.stat-today  { border-left-color: #2563eb; }
.stat-week   { border-left-color: #16a34a; }
.stat-month  { border-left-color: #d97706; }
.stat-total  { border-left-color: var(--sheriff-blue); }

[data-theme="dark"] .stat-card {
    background: #242a3a;
    border-color: #3a4260;
}
[data-theme="dark"] .stat-card .stat-value { color: #7ba8ff; }
[data-theme="dark"] .stat-card .stat-label { color: #8899b5; }
[data-theme="dark"] .stat-today  { border-left-color: #3b82f6; }
[data-theme="dark"] .stat-week   { border-left-color: #22c55e; }
[data-theme="dark"] .stat-month  { border-left-color: #f59e0b; }
[data-theme="dark"] .stat-total  { border-left-color: #5a7adb; }

.stat-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}
.stat-card-link:hover .stat-card,
.stat-card-link:hover {
    text-decoration: none;
    color: inherit;
}
.stat-card-link:hover .stat-card {
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(0,0,0,0.13);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat-card { transition: transform 0.15s ease, box-shadow 0.15s ease; }

/* ── Dark Mode ─────────────────────────────────────────────────────── */
[data-theme="dark"] body {
    background-color: #1a1e2e;
    color: #c8d0e2;
}
[data-theme="dark"] .section-card {
    background: #242a3a;
    border-color: #3a4260;
}
[data-theme="dark"] .section-card .card-body {
    color: #c8d0e2;
}
[data-theme="dark"] .violation-row {
    background: #2a3048;
    border-color: #404d6e;
}
[data-theme="dark"] .fine-display {
    background: #2a3048;
    border-color: #404d6e;
}
[data-theme="dark"] .detail-label { color: #8899b5; }
[data-theme="dark"] .detail-value { color: #d0dae8; }
[data-theme="dark"] .form-label { color: #a0aec0; }
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: #1e2438;
    border-color: #3a4260;
    color: #c8d0e2;
}
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background-color: #232a42;
    border-color: #5a7adb;
    color: #e2e8f0;
}
[data-theme="dark"] .form-control::placeholder { color: #6678a0; }
[data-theme="dark"] .form-control[readonly],
[data-theme="dark"] .form-control.bg-white {
    background-color: #1a1e30 !important;
    color: #a0aec0;
}
[data-theme="dark"] .table {
    color: #c8d0e2;
    border-color: #3a4260;
}
[data-theme="dark"] .table > :not(caption) > * > * {
    background-color: transparent;
    border-bottom-color: #3a4260;
}
[data-theme="dark"] .table-hover tbody tr:hover {
    background-color: #2e4070 !important;
    color: #e2e8f0 !important;
}
[data-theme="dark"] .table-hover tbody tr.table-danger:hover {
    background-color: #5a2020 !important;
    color: #fdd !important;
}
[data-theme="dark"] .pagination .page-link {
    background-color: #242a3a;
    border-color: #3a4260;
    color: #7ba8ff;
}
[data-theme="dark"] .pagination .page-item.active .page-link {
    background-color: #3a5aaa;
    border-color: #3a5aaa;
    color: #fff;
}
[data-theme="dark"] .pagination .page-link:hover {
    background-color: #2e3f6e;
    color: #adc8ff;
}
[data-theme="dark"] .pagination .page-item.disabled .page-link {
    background-color: #1e2438;
    color: #4a5570;
}
[data-theme="dark"] .alert-info {
    background-color: #1e2d48;
    border-color: #2a4278;
    color: #90b8e8;
}
[data-theme="dark"] .citation-number-display { color: #7ba8ff; }
[data-theme="dark"] .text-muted { color: #7a8aaa !important; }
[data-theme="dark"] .btn-outline-primary {
    color: #7ba8ff;
    border-color: #4a6ebf;
}
[data-theme="dark"] .btn-outline-secondary {
    color: #a0aec0;
    border-color: #4a5570;
}
[data-theme="dark"] .btn-outline-secondary:hover { background-color: #2a3355; }
[data-theme="dark"] .border-top { border-color: #3a4260 !important; }
[data-theme="dark"] hr { border-color: #3a4260; }
[data-theme="dark"] .badge.bg-secondary { background-color: #3a4a6a !important; }
[data-theme="dark"] .scan-box {
    background: #0d1117;
    color: #3fb950;
    border-color: #3fb950;
}
/* Dark mode: plain Bootstrap cards (Reports page stat cards, filter card) */
[data-theme="dark"] .card {
    background-color: #242a3a;
    border-color: #3a4260;
    color: #c8d0e2;
}
/* Dark mode: table-light thead/tfoot overrides */
[data-theme="dark"] .table-light {
    --bs-table-bg: #1e2438;
    --bs-table-color: #8899b5;
    --bs-table-border-color: #3a4260;
}
[data-theme="dark"] .table-light > * {
    color: #8899b5;
    background-color: #1e2438 !important;
    border-color: #3a4260;
}
/* Dark mode: bg-dark badge (deputy badge numbers) */
[data-theme="dark"] .badge.bg-dark {
    background-color: #3a4a6a !important;
}

/* ── TomSelect overrides ────────────────────────────────────────────────── */
/* Light mode: make selected item text dark and easy to read */
.ts-wrapper .ts-control .item {
    color: #1a202c !important;
    font-weight: 500;
}
/* Light mode: dropdown option hover */
.ts-dropdown .option.active,
.ts-dropdown .option:hover {
    background-color: #d0dff8 !important;
    color: #1a202c !important;
}

/* Dark mode: match the dark form-control style */
[data-theme="dark"] .ts-wrapper .ts-control {
    background-color: #1e2438 !important;
    border-color: #3a4260 !important;
    color: #c8d0e2 !important;
}
[data-theme="dark"] .ts-wrapper .ts-control .item {
    color: #c8d0e2 !important;
    font-weight: 500;
}
[data-theme="dark"] .ts-wrapper .ts-control input {
    color: #c8d0e2 !important;
}
[data-theme="dark"] .ts-wrapper .ts-control input::placeholder {
    color: #6678a0 !important;
}
[data-theme="dark"] .ts-dropdown {
    background-color: #1e2438 !important;
    border-color: #3a4260 !important;
    color: #c8d0e2 !important;
}
[data-theme="dark"] .ts-dropdown .option {
    color: #c8d0e2 !important;
}
[data-theme="dark"] .ts-dropdown .option.active,
[data-theme="dark"] .ts-dropdown .option:hover {
    background-color: #2e4070 !important;
    color: #e2e8f0 !important;
}

/* Theme toggle button */
.theme-toggle {
    background: none;
    border: 1px solid rgba(255,255,255,0.3);
    color: #fff;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 1rem;
}
.theme-toggle:hover { background: rgba(255,255,255,0.15); }
