/* ==========================================================================
   Portal Case Search — design system
   Hand-rolled, no framework. Utility class names intentionally mirror a
   familiar (Bootstrap-shaped) vocabulary so templates don't need rewriting,
   but every value — color, radius, shadow, spacing, motion — is our own.
   ========================================================================== */

:root {
  --bg: #f4f5fa;
  --surface: #ffffff;
  --surface-alt: #f8f9fc;
  --border: #e6e8f0;
  --border-strong: #d7dae6;
  --text: #1a1d29;
  --text-muted: #6b7183;
  --text-faint: #9296a8;

  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef0ff;
  --primary-ring: rgba(79, 70, 229, .18);

  --success: #16a34a;
  --success-soft: #e8f8ee;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --warning: #d97706;
  --warning-soft: #fef3e2;
  --info: #0891b2;
  --info-soft: #e3f7fa;
  --secondary: #6b7183;
  --secondary-soft: #eef0f5;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(20, 22, 40, .05);
  --shadow-md: 0 4px 16px rgba(20, 22, 40, .07);
  --shadow-lg: 0 12px 32px rgba(20, 22, 40, .12);

  --sidebar-bg: #f8f9fa;
  --sidebar-bg-alt: #f8f9fa;
  --sidebar-text: #1a1d29;
  --sidebar-text-dim: #6b7183;
  --sidebar-active: #4f46e5;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 650; letter-spacing: -.01em; line-height: 1.25; }
h1 { font-size: 30px; } h2 { font-size: 25px; } h3 { font-size: 21px; }
h4 { font-size: 18px; } h5 { font-size: 20px; } h6 { font-size: 13px; }
p { margin: 0 0 .5rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); text-decoration: underline; }
code { background: var(--surface-alt); border-radius: 4px; padding: .1em .35em; font-size: .9em; }

::selection { background: var(--primary-ring); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ==========================================================================
   App shell
   ========================================================================== */

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

.sidebar {
  width: 264px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 40;
}

.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; }
.sidebar-brand img { max-width: 100%; height: auto; display: block; }

.sidebar-section-title {
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--sidebar-text-dim);
  margin: 18px 10px 8px;
}
.sidebar-section-title:first-of-type { margin-top: 4px; }

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

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s ease, color .15s ease;
}
.sidebar-link:hover { background: rgba(0,0,0,.05); color: var(--sidebar-text); text-decoration: none; }
.sidebar-link.active {
  background: var(--sidebar-active);
  color: #fff;
  box-shadow: 0 4px 14px rgba(79, 70, 229, .45);
}
.sidebar-link svg { flex-shrink: 0; opacity: .85; }
.sidebar-link.active svg { opacity: 1; }

.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }

.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px; margin-bottom: 10px; }
.sidebar-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.sidebar-user-name { font-size: 13px; color: var(--sidebar-text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-impersonate {
  background: rgba(217, 119, 6, .16);
  border: 1px solid rgba(217, 119, 6, .35);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-bottom: 14px;
  font-size: 12.5px;
  color: #955006;
}

.topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar img { height: 30px; }

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(10, 11, 20, .5);
  z-index: 39;
}

.content-area { flex: 1; min-width: 0; overflow-x: hidden; }
.container-fluid { max-width: 1180px; margin: 0 auto; padding: 28px 28px; }

@media (max-width: 991.98px) {
  .topbar { display: flex; }
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-backdrop.is-open { display: block; }
  .container-fluid { padding: 18px 16px; }
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .05s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-ring); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 7px; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(79,70,229,.25); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }

.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #128a3e; border-color: #128a3e; color: #fff; }

.btn-warning { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn-warning:hover { background: #b96305; border-color: #b96305; color: #fff; }

.btn-outline-primary { background: transparent; border-color: var(--primary); color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary-soft); color: var(--primary-dark); }

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

.btn-outline-danger { background: transparent; border-color: #f3c6c6; color: var(--danger); }
.btn-outline-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-close {
  width: 28px; height: 28px; border-radius: 50%;
  border: none; background: var(--surface-alt);
  color: var(--text-muted); font-size: 16px; line-height: 1;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s ease;
}
.btn-close:hover { background: var(--border); }
.btn-close::before { content: "\2715"; }

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-body { padding: 22px; }
.card-title { font-size: 16px; font-weight: 650; margin-bottom: 12px; }

/* ==========================================================================
   Grid (12-col, bootstrap-compatible breakpoints so markup stays as-is)
   ========================================================================== */

.row { display: flex; flex-wrap: wrap; margin: 0 -12px; }
[class*="col-"] { padding: 0 12px; width: 100%; margin-bottom: 0; }
.row.g-2 { margin: 0 -4px; } .row.g-2 > [class*="col-"] { padding: 0 4px; margin-bottom: 8px; }
.row.g-3 { margin: 0 -6px; } .row.g-3 > [class*="col-"] { padding: 0 6px; margin-bottom: 12px; }
.row.g-4 { margin: 0 -12px; } .row.g-4 > [class*="col-"] { padding: 0 12px; margin-bottom: 24px; }

.col-12 { width: 100%; }

@media (min-width: 768px) {
  .col-md-1 { width: 8.3333%; }
  .col-md-3 { width: 25%; }
  .col-md-5 { width: 41.6667%; }
  .col-md-6 { width: 50%; }
}
@media (min-width: 992px) {
  .col-lg-4 { width: 33.3333%; }
  .col-lg-6 { width: 50%; }
  .col-lg-8 { width: 66.6667%; }
}
@media (min-width: 1200px) {
  /* Reserved for splits that need more room than the sidebar + col-lg
     leaves at exactly 992px (e.g. a narrow sidebar column squeezed
     against a wide table) — see .col-xl-* usage. */
  .col-xl-4 { width: 33.3333%; }
  .col-xl-8 { width: 66.6667%; }
}

/* ==========================================================================
   Forms
   ========================================================================== */

.form-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .02em; }

.form-control, .form-select, textarea.form-control {
  width: 100%;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control::placeholder { color: var(--text-faint); }
.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.form-control-sm { padding: 6px 10px; font-size: 13.5px; }
select.form-select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'><path d='M4 6l4 4 4-4' stroke='%236b7183' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }

input[type="file"].form-control { padding: 6px 10px; }
input[type="file"].form-control::file-selector-button {
  font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 6px 12px; margin-right: 12px;
  border: 1px solid var(--border-strong); border-radius: 7px;
  background: var(--surface-alt); color: var(--text);
  cursor: pointer; transition: background .15s ease;
}
input[type="file"].form-control::file-selector-button:hover { background: var(--border); }

.form-check { display: flex; align-items: center; gap: 8px; }
.form-check-input {
  width: 16px; height: 16px; margin: 0;
  accent-color: var(--primary);
}
.form-check-label { font-size: 13.5px; color: var(--text-muted); }

.autocomplete-wrap { position: relative; }
.autocomplete-menu {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); max-height: 240px; overflow-y: auto; z-index: 50;
  display: none;
}
.autocomplete-menu.is-open { display: block; }
.autocomplete-item { padding: 8px 12px; cursor: pointer; font-size: 13.5px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.autocomplete-item:hover, .autocomplete-item.is-active { background: var(--surface-alt); }
.autocomplete-item .ac-state { color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: .02em; flex-shrink: 0; }
.autocomplete-empty { padding: 9px 12px; font-size: 12.5px; color: var(--text-faint); }

.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ==========================================================================
   Tables
   ========================================================================== */

.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-faint); font-weight: 700; padding: 9px 12px; border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr { transition: background .1s ease; }
.table-hover tbody tr:hover { background: var(--surface-alt); }
.table-sm th, .table-sm td { padding: 7px 10px; }
.table-danger td { background: var(--danger-soft); }
.table-success td { background: var(--success-soft); }

/* Below 640px, tables that opt in via .table-stack render as a list of
   cards (one per row) instead of clipping columns off-screen with no
   visible scroll affordance. */
@media (max-width: 640px) {
  .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr {
    border: 1px solid var(--border); border-radius: var(--radius-md);
    padding: 10px 12px; margin-bottom: 10px; background: var(--surface);
  }
  .table-stack tbody tr:hover { background: var(--surface); }
  .table-stack td {
    border: none; padding: 5px 0;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    text-align: right;
  }
  .table-stack td::before {
    content: attr(data-label);
    font-weight: 700; font-size: 10.5px; text-transform: uppercase; letter-spacing: .03em;
    color: var(--text-faint); text-align: left; flex-shrink: 0;
  }
  .table-stack td:empty { display: none; }
  .table-stack td[data-label=""] { display: flex; justify-content: flex-end; }
}

/* ==========================================================================
   Status pills
   ========================================================================== */

[class*="status-"] {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--radius-pill);
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em;
  white-space: nowrap;
}
[class*="status-"]::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-queued { background: var(--warning-soft); color: var(--warning); }
.status-pending { background: var(--secondary-soft); color: var(--secondary); }
.status-running { background: var(--primary-soft); color: var(--primary); }
.status-success { background: var(--danger-soft); color: var(--danger); }
.status-no_results { background: var(--success-soft); color: var(--success); }
.status-error { background: var(--danger-soft); color: var(--danger); }
.status-cancelled { background: var(--secondary-soft); color: var(--secondary); font-style: normal; }
.status-completed { background: var(--success-soft); color: var(--success); }

/* ==========================================================================
   Alerts
   ========================================================================== */

.alert { border-radius: var(--radius-sm); padding: 11px 14px; font-size: 13.5px; border: 1px solid transparent; margin-bottom: 14px; }
.alert-success { background: var(--success-soft); color: #0e6b34; border-color: #bfe9cd; }
.alert-danger { background: var(--danger-soft); color: #a11d1d; border-color: #f5c2c2; }
.alert-warning { background: var(--warning-soft); color: #955006; border-color: #f6dcae; }

/* ==========================================================================
   Badges
   ========================================================================== */

.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
.text-bg-primary { background: var(--primary-soft); color: var(--primary); }
.text-bg-secondary { background: var(--secondary-soft); color: var(--secondary); }
.text-bg-info { background: var(--info-soft); color: var(--info); }
.text-bg-warning { background: var(--warning-soft); color: var(--warning); }

/* ==========================================================================
   Progress
   ========================================================================== */

.progress { height: 6px; background: var(--border); border-radius: var(--radius-pill); overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--primary), #7c73f0); border-radius: var(--radius-pill); transition: width .4s ease; }

/* ==========================================================================
   Modal (vanilla JS driven — see app.js)
   ========================================================================== */

.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal.is-open { display: flex; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 11, 20, .55); z-index: 99; opacity: 0; display: none; transition: opacity .15s ease; }
.modal-backdrop.is-open { opacity: 1; }
.modal-dialog { width: 100%; max-width: 480px; }
.modal-xl { max-width: 900px; }
.modal-content {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; max-height: 82vh; overflow: hidden;
  animation: modal-pop .16s ease;
}
@keyframes modal-pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-title { font-size: 15.5px; font-weight: 650; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-dialog-scrollable .modal-body { overflow-y: auto; }

/* ==========================================================================
   Accordion (native <details>/<summary>, no JS)
   ========================================================================== */

.acc { display: flex; flex-direction: column; gap: 8px; }
.acc-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  overflow: hidden;
}
.acc-item[open] { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.acc-item summary {
  list-style: none; cursor: pointer; padding: 13px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 14px;
}
.acc-item summary::-webkit-details-marker { display: none; }
.acc-item summary:hover { background: var(--surface-alt); }
.acc-summary-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.acc-summary-main strong { font-size: 14.5px; }
.acc-chevron { flex-shrink: 0; transition: transform .15s ease; color: var(--text-faint); }
.acc-item[open] .acc-chevron { transform: rotate(180deg); }
.acc-body { padding: 4px 16px 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.acc-body h6 { margin-bottom: 6px; }

.clerk-list { display: flex; flex-direction: column; gap: 10px; }
.clerk-row { background: var(--surface-alt); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 13.5px; line-height: 1.6; }

/* ==========================================================================
   Pagination (matches Laravel's built-in pagination::bootstrap-5 markup)
   ========================================================================== */

.pagination { display: flex; list-style: none; gap: 4px; padding: 0; margin: 16px 0 0; flex-wrap: wrap; }
.page-item .page-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; padding: 0 10px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  color: var(--text); font-size: 13px; font-weight: 600; background: var(--surface);
  transition: background .15s ease, color .15s ease;
}
.page-item .page-link:hover { background: var(--surface-alt); text-decoration: none; }
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-item.disabled .page-link { color: var(--text-faint); cursor: default; }
.page-item.disabled .page-link:hover { background: var(--surface); }

/* ==========================================================================
   Utilities
   ========================================================================== */

.d-flex { display: flex; }
.d-none { display: none !important; }
.d-block { display: block; }
.flex-column { flex-direction: column; }
.flex-shrink-0 { flex-shrink: 0; }
.flex-grow-1 { flex-grow: 1; }
.flex-wrap { flex-wrap: wrap; }
.align-items-center { align-items: center; }
.align-items-end { align-items: flex-end; }
.align-middle { vertical-align: middle; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.gap-2 { gap: 8px; }
.mx-auto { margin-left: auto; margin-right: auto; }
.ms-auto { margin-left: auto; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 16px; } .mb-4 { margin-bottom: 24px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 16px; } .mt-auto { margin-top: auto; }
.me-2 { margin-right: 8px; }
.pt-3 { padding-top: 16px; }
.p-2 { padding: 8px; } .p-3 { padding: 16px; }
.px-1 { padding-left: 4px; padding-right: 4px; } .px-2 { padding-left: 8px; padding-right: 8px; } .px-3 { padding-left: 16px; padding-right: 16px; }
.py-0 { padding-top: 0; padding-bottom: 0; } .py-1 { padding-top: 4px; padding-bottom: 4px; } .py-2 { padding-top: 8px; padding-bottom: 8px; } .py-3 { padding-top: 16px; padding-bottom: 16px; }
.w-100 { width: 100%; }
.vh-100 { min-height: 100vh; }
.overflow-auto { overflow: auto; }
.text-center { text-align: center; }
.text-start { text-align: left; }
.text-end { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-uppercase { text-transform: uppercase; }
.fw-semibold { font-weight: 650; }
.small { font-size: 12.5px; }
.font-monospace { font-family: ui-monospace, Consolas, 'SFMono-Regular', monospace; }
.border-top { border-top: 1px solid var(--border); }
.border-bottom { border-bottom: 1px solid var(--border); }
.border-end { border-right: 1px solid var(--border); }
.border { border: 1px solid var(--border); }
.border-dashed { border-style: dashed !important; }
.rounded { border-radius: var(--radius-sm); }

@media (min-width: 992px) {
  .flex-lg-row { flex-direction: row; }
  .d-lg-none { display: none !important; }
  .d-lg-block { display: block !important; }
}

.lock-icon { display: inline-flex; flex-shrink: 0; }

/* Job-status detail table used inside the results modal */
#detailsModalBody td { font-size: 13px; }
