/* ===== Global ===== */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f0f2f5;
  font-size: 0.9rem;
  color: #1a1a2e;
}
body.panel-open {
  overflow: hidden;
}

/* ===== Navbar ===== */
.navbar {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%) !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  padding: 0.5rem 1rem;
}
.navbar-brand {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

/* ===== Page heading ===== */
.page-header {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1e293b;
}

/* ===== Card wrapper for dashboard content ===== */
.content-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  border: 1px solid #e2e8f0;
  padding: 1.25rem;
}

/* ===== Filter bar ===== */
.filter-bar .form-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
  margin-bottom: 2px;
}
.filter-bar .form-select,
.filter-bar .form-control {
  font-size: 0.82rem;
  border-radius: 6px;
  border-color: #e2e8f0;
}
.filter-bar .form-select:focus,
.filter-bar .form-control:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}

/* ===== Status tabs (pills) ===== */
.status-tabs {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  padding: 0;
  margin: 0;
  list-style: none;
}
.status-tabs .tab-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: #64748b;
  background: transparent;
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}
.status-tabs .tab-pill:hover {
  background: #f1f5f9;
  color: #334155;
}
.status-tabs .tab-pill.active {
  background: #1e293b;
  color: #fff;
  border-color: #1e293b;
}
.status-tabs .tab-pill .tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 10px;
  padding: 0 5px;
}
.status-tabs .tab-pill .tab-count { background: #e2e8f0; color: #475569; }
.status-tabs .tab-pill.active .tab-count { background: rgba(255,255,255,0.2); color: #fff; }

/* ===== Quality dot indicator ===== */
.quality-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.quality-green { background: #22c55e; }
.quality-yellow { background: #eab308; }
.quality-red { background: #ef4444; }

/* ===== Ticket table ===== */
.ticket-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.83rem;
}
.ticket-table thead th {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
  padding: 0.5rem 0.6rem;
  border-bottom: 2px solid #e2e8f0;
  background: transparent;
  white-space: nowrap;
}
.ticket-table tbody td {
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.ticket-table tbody tr {
  cursor: pointer;
  transition: background 0.1s ease;
}
.ticket-table tbody tr:hover {
  background: #f8fafc;
}
.ticket-table tbody tr:last-child td {
  border-bottom: none;
}

/* Group header rows */
.ticket-table .group-header td {
  background: #f8fafc;
  padding: 0.4rem 0.6rem;
  font-weight: 600;
  font-size: 0.78rem;
  color: #475569;
  border-bottom: 1px solid #e2e8f0;
  cursor: default;
}

/* Status badges */
.status-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 4px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.status-badge.pending   { background: #dbeafe; color: #1e40af; }
.status-badge.approved  { background: #e0f2fe; color: #0369a1; }
.status-badge.failed    { background: #fee2e2; color: #b91c1c; }
.status-badge.uploaded  { background: #dcfce7; color: #166534; }
.status-badge.archived  { background: #f1f5f9; color: #64748b; }

/* Active row highlight */
.ticket-row.active-row {
  background: #eff6ff !important;
  box-shadow: inset 3px 0 0 #3b82f6;
}

/* Uploaded rows - muted */
.ticket-row.row-muted {
  color: #94a3b8;
}

/* ===== Transcript box ===== */
.transcript-box {
  max-height: 500px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 0.82rem;
  line-height: 1.6;
  background: #f8fafc;
  padding: 0.85rem;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  color: #334155;
}

/* ===== HTMX loading indicator ===== */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }

/* ===== Custom autocomplete dropdown ===== */
.ac-wrap { position: relative; }
.ac-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1050;
  max-height: 220px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-top: none;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
}
.ac-dropdown.show { display: block; }
.ac-option {
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.83rem;
}
.ac-option:hover, .ac-option.active {
  background: #3b82f6;
  color: #fff;
}
.ac-empty {
  padding: 6px 12px;
  color: #94a3b8;
  font-size: 0.83rem;
  font-style: italic;
}

/* ===== Dashboard Layout ===== */
.dashboard-layout {
  position: relative;
  min-height: calc(100vh - 80px);
}
.list-col {
  width: 100%;
}

/* ===== Detail Panel — Overlay Drawer ===== */
.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 52%;
  max-width: 680px;
  background: #fff;
  z-index: 1055;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,0.1);
  transform: translateX(100%);
  transition: transform 0.25s ease;
}
.dashboard-layout.panel-open .detail-panel {
  transform: translateX(0);
}

/* Backdrop overlay */
.panel-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15,23,42,0.15);
  z-index: 1054;
  transition: opacity 0.2s ease;
}
.dashboard-layout.panel-open .panel-backdrop {
  display: block;
}

/* ===== Panel internals ===== */
.panel-header {
  flex-shrink: 0;
  background: #fff;
  z-index: 10;
  border-bottom: 1px solid #e2e8f0;
  padding: 0.75rem 1rem;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.panel-footer {
  flex-shrink: 0;
  padding: 0.65rem 1rem;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}

/* Panel sections — separated by subtle dividers */
.panel-section {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #f1f5f9;
}
.panel-section:last-child {
  border-bottom: none;
}

/* Panel labels */
.panel-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 3px;
}

/* Panel form inputs */
.detail-panel .form-control,
.detail-panel .form-select {
  font-size: 0.84rem;
  padding: 0.35rem 0.55rem;
  border-radius: 5px;
  border-color: #e2e8f0;
}
.detail-panel .form-control:focus,
.detail-panel .form-select:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 2px rgba(59,130,246,0.12);
}

/* Transcript toggles */
.panel-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  padding: 2px 0;
}
.panel-toggle:hover {
  color: #334155;
}

/* Panel transcript box */
.detail-panel .transcript-box {
  max-height: 200px;
  font-size: 0.78rem;
  padding: 0.65rem;
}

/* Transcript chevron rotation: right > -> down v */
.transcript-chevron {
  transition: transform 0.2s ease;
  color: #94a3b8;
}
[aria-expanded="true"] .transcript-chevron {
  transform: rotate(90deg);
}

/* ===== Buttons ===== */
.btn {
  font-size: 0.83rem;
  border-radius: 6px;
  font-weight: 500;
}
.btn-sm {
  font-size: 0.78rem;
  padding: 0.3rem 0.7rem;
}

/* ===== Mobile: panel goes full width ===== */
@media (max-width: 768px) {
  .detail-panel {
    width: 100%;
    max-width: 100%;
  }
  .content-card {
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
}

/* ===== Empty state ===== */
.empty-state {
  padding: 3rem 1rem;
  text-align: center;
  color: #94a3b8;
  font-size: 0.9rem;
}
