:root {
    --sidebar-w: 250px;
    --sidebar-bg: #0f172a;
    --sidebar-fg: #cbd5e1;
    --sidebar-active: #1e293b;
    --accent: #1d4ed8;
}
* { box-sizing: border-box; }
body { margin: 0; background: #f1f5f9; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }

.app-wrapper { display: flex; min-height: 100vh; }

.app-sidebar {
    width: var(--sidebar-w); flex-shrink: 0;
    background: var(--sidebar-bg); color: var(--sidebar-fg);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}

.sidebar-brand {
    padding: 1rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .55rem;
    text-align: center;
}

.sidebar-brand .brand-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 80px;
}

.sidebar-brand .brand-logo img {
    max-height: 80px;
    max-width: 100%;
    width: auto;
    height: auto;
    background: transparent;
    padding: 0;
    border-radius: 0;
    object-fit: contain;

    /* Make white pixels transparent on the dark sidebar */
    mix-blend-mode: screen;

    /* Two-tone glow that now hugs the actual logo shape (not the white box) */
    filter:
        drop-shadow(0 0 8px  rgba(29, 78, 216, .55))
        drop-shadow(0 0 4px  rgba(59, 130, 246, .40))
        drop-shadow(0 0 2px  rgba(212, 175, 55, .65));
    transition: filter .25s ease;
}

.sidebar-brand .brand-logo img:hover {
    filter:
        drop-shadow(0 0 12px rgba(29, 78, 216, .75))
        drop-shadow(0 0 6px  rgba(59, 130, 246, .55))
        drop-shadow(0 0 3px  rgba(212, 175, 55, .85));
}

.sidebar-brand .brand-logo i {
    font-size: 2rem;
    color: #cbd5e1;
}

.sidebar-brand .brand-name {
    font-weight: 700;
    font-size: .84rem;
    line-height: 1.15;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: .04em;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-width: 100%;
}

.sidebar-nav { padding: .5rem 0; }

.sidebar-nav .nav-link {
    color: var(--sidebar-fg); padding: .6rem 1.25rem; font-size: .92rem;
    display: flex; align-items: center; gap: .55rem;
    border-left: 3px solid transparent;
}
.sidebar-nav .nav-link:hover { background: var(--sidebar-active); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--sidebar-active); color: #fff; border-left-color: var(--accent); }
.nav-section {
    padding: .75rem 1.25rem .35rem; font-size: .7rem;
    text-transform: uppercase; letter-spacing: .08em; color: #64748b;
}
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    background: #fff; padding: .75rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex; align-items: center; justify-content: space-between;
}
.app-content { padding: 1.25rem; }
.card { border: 1px solid #e2e8f0; box-shadow: 0 1px 2px rgba(15,23,42,.04); }

.stat-card { border-radius: .65rem; padding: 1rem 1.15rem; color: #fff; }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: .8rem; opacity: .9; text-transform: uppercase; letter-spacing: .05em; }
.stat-primary  { background: linear-gradient(135deg,#1d4ed8,#3b82f6); }
.stat-success  { background: linear-gradient(135deg,#059669,#10b981); }
.stat-warning  { background: linear-gradient(135deg,#d97706,#f59e0b); }
.stat-danger   { background: linear-gradient(135deg,#dc2626,#ef4444); }
.stat-info     { background: linear-gradient(135deg,#0891b2,#06b6d4); }
.stat-secondary{ background: linear-gradient(135deg,#475569,#64748b); }

@media (max-width: 991.98px) {
    .app-sidebar { position: fixed; left: -260px; z-index: 1050; transition: left .2s; }
    .app-sidebar.show { left: 0; }
    .app-content { padding: .85rem; }
}

/* ================= Sidebar user block ================= */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .65rem 1.25rem;
    margin-top: .25rem;
    border-top: 1px solid rgba(255,255,255,.06);
    color: var(--sidebar-fg);
}
.sidebar-user > i {
    font-size: 1.6rem;
    opacity: .85;
    flex-shrink: 0;
}
.sidebar-user-info { min-width: 0; line-height: 1.15; }
.sidebar-user-name { color: #fff; font-size: .85rem; font-weight: 600; }
.sidebar-user-role { color: #94a3b8; font-size: .72rem; }

/* ================ Sidebar scroll polish ================ */
.sidebar-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    padding-bottom: 1rem;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.12);
    border-radius: 3px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.22); }

/* ================= Nav-link icon width ================= */
.sidebar-nav .nav-link > i {
    font-size: 1rem;
    width: 1.15rem;
    text-align: center;
    flex-shrink: 0;
}
.sidebar-nav .nav-link > span { white-space: nowrap; }

/* ============= Clickable stat cards ============= */
a .stat-card {
    transition: transform .15s ease, box-shadow .15s ease;
    cursor: pointer;
}
a:hover .stat-card {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(15,23,42,.12);
}

/* ============= Dashboard list-group polish ============= */
.list-group-item-action:hover {
    background: #f8fafc;
}

/* ============ Hearing cards (case profile → Hearings tab) ============ */
.hearing-cards { display: flex; flex-direction: column; gap: .75rem; }

.hearing-card {
    border: 1px solid #e2e8f0;
    border-radius: .6rem;
    background: #fff;
    padding: 1rem 1.15rem;
    display: grid;
    grid-template-columns: minmax(220px, 1.1fr) 2fr auto;
    gap: 1.25rem;
    align-items: center;
    transition: box-shadow .15s ease, border-color .15s ease;
}
.hearing-card:hover {
    border-color: #c7d2fe;
    box-shadow: 0 4px 14px rgba(15,23,42,.06);
}

/* Left: case context */
.hearing-case {
    border-right: 1px dashed #e2e8f0;
    padding-right: 1rem;
    min-width: 0;
}
.hearing-case .case-row {
    display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
    margin-bottom: .3rem;
}
.hearing-case .sn-chip {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .68rem;
    background: #0f172a; color: #fff;
    padding: .14rem .45rem; border-radius: 999px;
    letter-spacing: .02em;
    white-space: nowrap;
}
.hearing-case .case-no {
    font-weight: 700; color: #0f172a; font-size: .95rem;
}
.hearing-case .case-versus {
    color: #334155; font-size: .85rem; line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: .35rem;
}
.hearing-case .case-meta {
    display: flex; gap: .85rem; flex-wrap: wrap;
    font-size: .74rem; color: #64748b;
}
.hearing-case .case-meta i { color: #94a3b8; }

/* Middle: hearing details */
.hearing-details {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .65rem 1rem;
    min-width: 0;
}
.hd-item { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.hd-label {
    font-size: .68rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 600;
}
.hd-value {
    font-size: .85rem;
    color: #334155;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.hd-value i { color: #64748b; margin-right: .15rem; }
.hd-date .hd-value { color: #0f172a; font-weight: 700; }

/* Right: actions */
.hearing-actions {
    display: flex;
    gap: .35rem;
    align-items: center;
    justify-content: flex-end;
}

/* Mobile: stack */
@media (max-width: 991.98px) {
    .hearing-card {
        grid-template-columns: 1fr;
        gap: .85rem;
    }
    .hearing-case {
        border-right: 0;
        border-bottom: 1px dashed #e2e8f0;
        padding-right: 0; padding-bottom: .75rem;
    }
    .hearing-details {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .hearing-actions { justify-content: flex-start; }
}

/* ======================= DARK THEME ======================= */
body.theme-dark {
    background: #0f172a;
    color: #cbd5e1;
}
body.theme-dark .topbar {
    background: #1e293b;
    border-bottom-color: #334155;
    color: #e2e8f0;
}
body.theme-dark .topbar h5,
body.theme-dark .topbar small { color: #e2e8f0; }

body.theme-dark .card {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
}
body.theme-dark .card-header {
    background: #1e293b !important;
    border-bottom-color: #334155;
    color: #e2e8f0;
}
body.theme-dark .card-footer {
    background: #1e293b !important;
    border-top-color: #334155;
}

body.theme-dark .table {
    color: #cbd5e1;
}
body.theme-dark .table thead th {
    background: #0f172a;
    color: #94a3b8;
    border-bottom-color: #334155;
}
body.theme-dark .table td {
    border-bottom-color: #334155;
}
body.theme-dark .table tbody tr:hover {
    background: #1e293b;
}

body.theme-dark .form-control,
body.theme-dark .form-select,
body.theme-dark .input-group-text {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}
body.theme-dark .form-control:focus,
body.theme-dark .form-select:focus {
    background: #0f172a;
    color: #e2e8f0;
    border-color: #3b82f6;
    box-shadow: 0 0 0 .2rem rgba(59,130,246,.25);
}
body.theme-dark .input-group-text {
    background: #1e293b;
    color: #94a3b8;
}

body.theme-dark .btn-outline-secondary {
    color: #cbd5e1;
    border-color: #475569;
}
body.theme-dark .btn-outline-secondary:hover {
    background: #334155;
    color: #fff;
}
body.theme-dark .btn-outline-primary {
    color: #93c5fd;
    border-color: #3b82f6;
}
body.theme-dark .btn-outline-primary:hover {
    background: #3b82f6;
    color: #fff;
}

body.theme-dark .text-muted { color: #94a3b8 !important; }
body.theme-dark .border,
body.theme-dark .border-top,
body.theme-dark .border-bottom { border-color: #334155 !important; }

body.theme-dark .bg-light { background: #0f172a !important; }
body.theme-dark .bg-white { background: #1e293b !important; }
body.theme-dark .dropdown-menu {
    background: #1e293b;
    border-color: #334155;
}
body.theme-dark .dropdown-item { color: #cbd5e1; }
body.theme-dark .dropdown-item:hover { background: #334155; color: #fff; }
body.theme-dark .dropdown-divider { border-top-color: #334155; }

body.theme-dark .nav-tabs .nav-link { color: #94a3b8; }
body.theme-dark .nav-tabs .nav-link.active {
    background: #1e293b;
    color: #93c5fd;
    border-color: transparent transparent #3b82f6 transparent;
}

body.theme-dark .modal-content {
    background: #1e293b;
    color: #cbd5e1;
}
body.theme-dark .modal-header,
body.theme-dark .modal-footer {
    border-color: #334155;
}
body.theme-dark .btn-close { filter: invert(1); }
body.theme-dark .alert { color: inherit; }

/* ======================= HIGH CONTRAST ======================= */
body.theme-contrast {
    background: #000;
    color: #fff;
}
body.theme-contrast .topbar,
body.theme-contrast .card,
body.theme-contrast .card-header,
body.theme-contrast .card-footer {
    background: #111 !important;
    border-color: #ffcc00 !important;
    color: #fff;
}
body.theme-contrast .table {
    color: #fff;
    border-color: #ffcc00;
}
body.theme-contrast .table th,
body.theme-contrast .table td {
    border-color: #ffcc00;
}
body.theme-contrast .table thead th {
    background: #222;
    color: #ffcc00;
}
body.theme-contrast .btn-primary {
    background: #ffcc00;
    border-color: #ffcc00;
    color: #000;
    font-weight: 700;
}
body.theme-contrast .form-control,
body.theme-contrast .form-select {
    background: #000;
    color: #fff;
    border-color: #ffcc00;
}

/* ======================= LIGHT SIDEBAR ======================= */
body.sidebar-light .app-sidebar {
    background: #f8fafc;
    color: #334155;
    border-right: 1px solid #e2e8f0;
}

body.sidebar-light .sidebar-brand {
    color: #0f172a;
    border-bottom-color: #e2e8f0;
}
body.sidebar-light .sidebar-brand .brand-logo img {
    background: #fff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .05);
}
body.sidebar-light .sidebar-brand .brand-logo i {
    color: #64748b;
}
body.sidebar-light .sidebar-brand .brand-name {
    color: #0f172a;
}

body.sidebar-light .sidebar-nav .nav-link {
    color: #475569;
}
body.sidebar-light .sidebar-nav .nav-link > i {
    color: #94a3b8;
}
body.sidebar-light .sidebar-nav .nav-link:hover {
    background: #e2e8f0;
    color: #0f172a;
}
body.sidebar-light .sidebar-nav .nav-link:hover > i {
    color: #475569;
}
body.sidebar-light .sidebar-nav .nav-link.active {
    background: #dbeafe;
    color: #1e40af;
    border-left-color: #1d4ed8;
}
body.sidebar-light .sidebar-nav .nav-link.active > i {
    color: #1e40af;
}

body.sidebar-light .nav-section {
    color: #94a3b8;
    border-top-color: #e2e8f0;
}

body.sidebar-light .sidebar-user {
    border-top-color: #e2e8f0;
    color: #475569;
}
body.sidebar-light .sidebar-user > i {
    color: #64748b;
}
body.sidebar-light .sidebar-user-name {
    color: #0f172a;
}
body.sidebar-light .sidebar-user-role {
    color: #64748b;
}

body.sidebar-light .sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, .12);
}
body.sidebar-light .sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(15, 23, 42, .22);
}