/* =========================================================================
 * CZPWeb vehicle-database.css — v149.42 (Phase 1B Step 5)
 * =========================================================================
 *
 * Styles for the in-app Vehicle Database panel (Option B architecture).
 * All selectors prefixed with .vdb- to avoid collision with main app CSS.
 * Inherits theme variables from app.css (--app-bg, --app-text, etc.) so
 * the panel adapts to the active skin (Courtroom default).
 *
 * Structure:
 *   .vdb-panel                       outer container (replaces workspace view)
 *     .vdb-panel-header              top bar with title + close
 *     .vdb-main                      grid: filters | results
 *       .vdb-filters                 left sidebar with filter controls
 *       .vdb-results                 right pane with toolbar + table
 *     .vdb-modal-backdrop            overlay for detail + save modals
 *     .vdb-toast                     transient notification
 *
 * D-049 — formatting (inches, feet) is done in JS; CSS only provides
 *   monospace alignment for numeric columns and the courtroom skin's
 *   high-contrast palette.
 * ========================================================================= */

/* ---- Outer panel ------------------------------------------------------- */

.vdb-panel {
  position: fixed;
  inset: 0;
  background: var(--app-bg);
  color: var(--app-text);
  z-index: 50;
  display: flex;
  flex-direction: column;
  font-family: var(--app-font-ui);
}

.vdb-panel-header {
  border-bottom: 1px solid var(--app-border);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--app-topbar);
  flex-shrink: 0;
}

.vdb-panel-title {
  font-family: var(--app-font-body);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--app-text);
}

.vdb-panel-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--app-font-mono);
  font-size: 11px;
}

.vdb-data-version {
  color: var(--app-text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.vdb-brand-sub {
  color: var(--app-text-muted);
  font-weight: 400;
}

/* ---- Main two-pane grid ------------------------------------------------ */

.vdb-main {
  flex: 1;
  display: grid;
  grid-template-columns: 320px 1fr;
  overflow: hidden;
}

/* ---- Filter sidebar ---------------------------------------------------- */

.vdb-filters {
  border-right: 1px solid var(--app-border-soft);
  padding: 14px 16px;
  overflow-y: auto;
  background: var(--app-surface-alt);
}

.vdb-filter-group {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--app-border-faint);
}
.vdb-filter-group:last-of-type {
  border-bottom: 0;
  margin-bottom: 6px;
}

.vdb-filter-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--app-font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--app-text-muted);
  margin-bottom: 5px;
}

.vdb-filter-hint {
  font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--app-text-subtle);
}

.vdb-input,
.vdb-select {
  width: 100%;
  background: var(--app-surface);
  border: 1px solid var(--app-border-faint);
  color: var(--app-text);
  padding: 6px 8px;
  font-family: var(--app-font-mono);
  font-size: 12px;
  border-radius: 3px;
  box-sizing: border-box;
}
.vdb-input:focus,
.vdb-select:focus {
  outline: none;
  border-color: var(--app-input-border);
}

.vdb-range {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 5px;
  align-items: center;
}
.vdb-range-input {
  padding: 5px 6px;
  font-size: 11px;
}
.vdb-range-sep {
  color: var(--app-text-muted);
  font-family: var(--app-font-mono);
}

.vdb-checkbox-list {
  border: 1px solid var(--app-border-faint);
  background: var(--app-surface);
  padding: 4px 6px;
  border-radius: 3px;
  max-height: 180px;
  overflow-y: auto;
}
.vdb-checkbox-list label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 1px;
  font-family: var(--app-font-mono);
  font-size: 11px;
  cursor: pointer;
  user-select: none;
  color: var(--app-text);
}
.vdb-checkbox-list input[type=checkbox] { accent-color: var(--app-text); margin: 0; }

.vdb-filter-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.vdb-filter-actions .btn { flex: 1; }

/* ---- Results pane ------------------------------------------------------ */

.vdb-results {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--app-bg);
}

.vdb-results-toolbar {
  border-bottom: 1px solid var(--app-border-soft);
  padding: 8px 16px;
  background: var(--app-surface-alt);
  flex-shrink: 0;
  font-family: var(--app-font-mono);
  font-size: 11px;
  color: var(--app-text-muted);
  letter-spacing: 0.04em;
}
.vdb-num {
  color: var(--app-text);
  font-weight: 600;
}
.vdb-sort-info {
  margin-left: 10px;
  color: var(--app-text-subtle);
}

.vdb-table-wrap {
  flex: 1;
  overflow: auto;
  position: relative;
}

.vdb-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--app-font-mono);
  font-size: 11.5px;
}
.vdb-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--app-surface-alt);
}
.vdb-table th {
  padding: 7px 10px;
  text-align: left;
  border-bottom: 1.5px solid var(--app-border);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--app-text-muted);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  background: var(--app-surface-alt);
}
.vdb-table th:hover { color: var(--app-text); }
.vdb-table th.vdb-sorted { color: var(--app-text); }
.vdb-table th.vdb-sorted::after {
  content: '';
  display: inline-block;
  margin-left: 6px;
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
}
.vdb-table th.vdb-sorted.asc::after  { border-bottom: 5px solid var(--app-text); }
.vdb-table th.vdb-sorted.desc::after { border-top:    5px solid var(--app-text); }

.vdb-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--app-border-faint);
  color: var(--app-text);
  white-space: nowrap;
}
.vdb-table tbody tr {
  cursor: pointer;
  transition: background 60ms;
}
.vdb-table tbody tr:nth-child(even) { background: var(--app-surface-alt); }
.vdb-table tbody tr:hover  { background: var(--app-accent-soft); }

.vdb-table td.vdb-num   { text-align: right; }
.vdb-table td.vdb-mfr   { font-weight: 600; letter-spacing: 0.02em; }
.vdb-table td.vdb-model { color: var(--app-text); }

.vdb-table-cap {
  padding: 12px 16px;
  font-family: var(--app-font-mono);
  font-size: 11px;
  color: var(--app-text-muted);
  text-align: center;
  border-top: 1px solid var(--app-border-faint);
  background: var(--app-surface-alt);
}

.vdb-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 240px;
  color: var(--app-text-muted);
  text-align: center;
  padding: 40px;
}
.vdb-empty-big {
  font-family: var(--app-font-body);
  font-size: 24px;
  color: var(--app-text);
  margin-bottom: 8px;
}
.vdb-empty-sub {
  font-family: var(--app-font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.7;
}

/* ---- Modal (detail + save sub-modal) ----------------------------------- */

.vdb-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 30px;
}
.vdb-modal-backdrop.show { display: flex; }
.vdb-save-backdrop { z-index: 1100; }   /* above the detail modal */

.vdb-modal {
  background: var(--app-surface);
  color: var(--app-text);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-md);
  width: 100%;
  max-width: 880px;
  max-height: 88vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--app-shadow);
  font-family: var(--app-font-ui);
}
.vdb-save-modal { max-width: 600px; }

.vdb-modal-head {
  border-bottom: 1px solid var(--app-border);
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  background: var(--app-surface-alt);
}
.vdb-modal-title {
  font-family: var(--app-font-body);
  font-size: 19px;
  font-weight: 600;
  color: var(--app-text);
}

.vdb-modal-close {
  background: transparent;
  border: 1px solid var(--app-border-faint);
  color: var(--app-text-muted);
  width: 28px;
  height: 28px;
  border-radius: 3px;
  cursor: pointer;
  font-family: var(--app-font-mono);
  font-size: 14px;
  flex-shrink: 0;
}
.vdb-modal-close:hover {
  color: var(--app-text);
  border-color: var(--app-border);
}

.vdb-modal-body {
  overflow-y: auto;
  padding: 16px 20px 20px;
  font-family: var(--app-font-ui);
}

.vdb-modal-footer {
  border-top: 1px solid var(--app-border-soft);
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--app-surface-alt);
  flex-shrink: 0;
}
.vdb-modal-note {
  font-family: var(--app-font-mono);
  font-size: 10px;
  color: var(--app-text-muted);
  letter-spacing: 0.04em;
}
.vdb-modal-actions { display: flex; gap: 8px; }

/* ---- Detail panel content (uses VehicleSpec.renderDetailPanel HTML) ---- */

.vsl-detail .vsl-detail-header {
  border-bottom: 1px solid var(--app-border);
  padding-bottom: 8px;
  margin-bottom: 14px;
}
.vsl-detail .vsl-detail-title {
  font-family: var(--app-font-body);
  font-size: 17px;
  font-weight: 600;
  color: var(--app-text);
}

.vsl-section {
  margin-bottom: 16px;
}
.vsl-section-label {
  font-family: var(--app-font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--app-text);
  border-bottom: 1px solid var(--app-border-faint);
  padding-bottom: 3px;
  margin-bottom: 8px;
  font-weight: 600;
}
.vsl-section-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px 20px;
}
.vsl-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 4px 0;
  border-bottom: 1px dashed var(--app-border-faint);
  font-family: var(--app-font-mono);
  font-size: 12px;
}
.vsl-row .vsl-key { color: var(--app-text-muted); }
.vsl-row .vsl-val { color: var(--app-text); text-align: right; font-weight: 500; }
.vsl-row.vsl-row-missing .vsl-val { color: var(--app-text-subtle); font-style: italic; font-weight: 400; }
.vsl-mono { font-family: var(--app-font-mono); }

.vsl-section-forensic .vsl-row .vsl-val,
.vsl-section-forensic .vsl-section-label {
  color: var(--app-text);
  font-weight: 600;
}

.vsl-section-derived .vsl-section-label,
.vsl-section-provenance .vsl-section-label,
.vsl-section-notes .vsl-section-label {
  color: var(--app-text-muted);
}

.vsl-notes {
  width: 100%;
  min-height: 60px;
  padding: 8px 10px;
  font-family: var(--app-font-ui);
  font-size: 12px;
  border: 1px solid var(--app-border-faint);
  border-radius: 4px;
  background: var(--app-surface);
  color: var(--app-text);
  box-sizing: border-box;
  resize: vertical;
}

/* ---- Save sub-modal --------------------------------------------------- */

.vdb-save-section {
  margin-bottom: 14px;
}
.vdb-save-section:last-child { margin-bottom: 0; }

.vdb-save-vehicle-summary {
  background: var(--app-surface-alt);
  border: 1px solid var(--app-border-faint);
  border-radius: 5px;
  padding: 10px 12px;
}
.vdb-save-veh-title {
  font-family: var(--app-font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--app-text);
  margin-bottom: 4px;
}
.vdb-save-veh-summary {
  font-family: var(--app-font-mono);
  font-size: 11px;
  color: var(--app-text-muted);
  margin-bottom: 4px;
}
.vdb-save-veh-prov {
  font-family: var(--app-font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--app-text-subtle);
}

.vdb-save-or {
  text-align: center;
  font-family: var(--app-font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--app-text-muted);
  margin: 8px 0;
}

.vdb-save-newrow {
  display: flex;
  gap: 6px;
  align-items: center;
}
.vdb-save-newrow .vdb-input { flex: 1; }
.vdb-save-newrow .btn { white-space: nowrap; }

.vdb-save-hint {
  font-family: var(--app-font-mono);
  font-size: 10px;
  color: var(--app-text-subtle);
  margin-top: 6px;
}

.vdb-save-binding-preview:empty { display: none; }
.vdb-save-binding-preview {
  background: var(--app-surface-alt);
  border-left: 3px solid var(--app-text);
  padding: 8px 12px;
  border-radius: 3px;
}
.vdb-binding-preview-title {
  font-family: var(--app-font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--app-text-muted);
  margin-bottom: 4px;
}
.vdb-binding-preview-list {
  font-family: var(--app-font-ui);
  font-size: 12px;
  color: var(--app-text);
  margin: 0;
  padding-left: 18px;
  line-height: 1.45;
}
.vdb-binding-preview-list li { margin-bottom: 3px; }
.vdb-binding-preview-list li.vdb-warn { color: var(--app-warning); }

.vdb-save-notes {
  font-family: var(--app-font-ui);
  font-size: 12px;
  min-height: 60px;
  resize: vertical;
}

/* ---- Toast ------------------------------------------------------------ */

.vdb-toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--app-text);
  color: var(--app-bg);
  padding: 10px 16px;
  border-radius: 4px;
  font-family: var(--app-font-ui);
  font-size: 12px;
  z-index: 2000;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 200ms, transform 200ms;
  box-shadow: var(--app-shadow);
  pointer-events: none;
  max-width: 480px;
}
.vdb-toast.vdb-toast-show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.vdb-toast-error { background: var(--app-danger); }
.vdb-toast-success { background: var(--app-text); }

/* ---- Print: vehicle DB panel itself doesn't print; the saved
 *     vehicleSpec items in the project pane do (via their own
 *     print rules in app.css). The panel hides on print. ---- */
@media print {
  .vdb-panel { display: none !important; }
  .vdb-modal-backdrop { display: none !important; }
}
