/* =========================================================================
   TALLER DIGITAL — sistema de diseño
   -------------------------------------------------------------------------
   Dirección visual: hoja de inspección de taller, no "app bonita de moda".
   Fondo claro tipo acero/primer para que se lea bien bajo luz de nave
   industrial en una tablet; graphite oscuro para la barra superior y
   texto; naranja de seguridad (el mismo tono que usan conos y overoles)
   como único acento — se reserva para acciones primarias y marcas de
   daño, así siempre significa "esto importa, tocá acá".
   Tipografía: sin fuentes externas (cero dependencia de red) — se logra
   la sensación "condensada industrial" con font-stretch + peso + mayús-
   culas sobre la fuente del sistema, y monoespaciada para placas, como
   una placa real troquelada.
   ========================================================================= */

:root {
  --bg: #EEF1F3;
  --panel: #FFFFFF;
  --ink: #1B2027;
  --ink-soft: #5B6470;
  --line: #22282E;
  --line-2: #3A424C;
  --accent: #FF6A13;
  --accent-ink: #FFFFFF;
  --ok: #2E8B57;
  --warn: #C4791A;
  --danger: #B23A3A;
  --border: #D8DDE3;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(27, 32, 39, 0.06), 0 4px 14px rgba(27, 32, 39, 0.07);

  --font-body: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Arial Narrow", -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Roboto Mono", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-stretch: condensed;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin: 0;
}

button, input, select, textarea { font-family: inherit; font-size: 1rem; }
button { touch-action: manipulation; }

.hidden { display: none !important; }
.mono { font-family: var(--font-mono); }

/* ------------------------------------------------------------- AJUSTES */
.settings-heading {
  font-size: 1.1rem;
  margin: 28px 0 14px;
}
.settings-heading:first-child { margin-top: 0; }
.settings-sub { color: var(--ink-soft); font-size: 0.9rem; margin: -6px 0 16px; }

.logo-picker { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.logo-preview-box {
  width: 84px; height: 84px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  background: var(--panel);
  flex-shrink: 0;
}
.logo-preview { width: 100%; height: 100%; object-fit: contain; }
.logo-preview-empty { font-size: 0.72rem; color: var(--ink-soft); text-align: center; padding: 0 6px; }
.logo-picker-actions { display: flex; flex-direction: column; gap: 8px; }

.file-btn { position: relative; cursor: pointer; }
.hidden-file-input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
}

.info-box {
  background: #EAF1FB;
  border: 1px solid #C6D9F0;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin: 18px 0;
  color: #1B3A63;
  font-size: 0.9rem;
}
.info-box p { margin: 0 0 8px; }
.info-box p:last-child { margin-bottom: 0; }
.info-box-title { font-weight: 700; margin-bottom: 8px; }
.info-box-steps {
  background: rgba(255,255,255,0.6);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.85rem;
}

/* --------------------------------------------------------------- APP BAR */
.appbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--line);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.appbar-mark { color: var(--accent); display: flex; width: 26px; height: 26px; flex-shrink: 0; }
.appbar-mark svg { width: 26px; height: 26px; }
.appbar-mark img { width: 26px; height: 26px; object-fit: contain; border-radius: 4px; }
.appbar h1 { font-size: 1.25rem; color: #fff; flex: 1; }
.status-pill {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.1);
  color: #C9D1D9;
}

.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  border-radius: 999px;
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:active { background: rgba(255,255,255,0.12); }

/* ------------------------------------------------------------------ MAIN */
#app { max-width: 1100px; margin: 0 auto; padding: 20px 20px 48px; }
.view { animation: fadein .15s ease-out; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px);} to { opacity:1; transform: none; } }

/* --------------------------------------------------------------- BUTTONS */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  font-weight: 600;
  cursor: pointer;
  transition: transform .06s ease;
}
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: scale(0.97); }
.btn-sm { min-height: 44px; padding: 8px 16px; font-size: 0.9rem; }

.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-outline { background: var(--panel); color: var(--ink); border-color: var(--border); }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }

/* --------------------------------------------------------------- SEARCH */
.dash-toolbar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.search-field {
  flex: 1; min-width: 240px;
  display: flex; align-items: center; gap: 10px;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
}
.search-field:focus-within { border-color: var(--line); }
.search-icon { width: 18px; height: 18px; color: var(--ink-soft); flex-shrink: 0; }
.search-field input {
  border: none; outline: none; background: transparent;
  height: 52px; flex: 1; color: var(--ink);
}

/* ----------------------------------------------------------------- CARDS */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.expediente-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px;
  transition: transform .08s ease, border-color .08s ease;
}
.expediente-card:active { transform: scale(0.98); }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-placa { font-family: var(--font-mono); font-weight: 700; font-size: 1.15rem; letter-spacing: 0.06em; }
.card-cliente { color: var(--ink-soft); font-size: 0.95rem; }
.card-vehiculo { font-size: 0.88rem; color: var(--ink-soft); }

.badge {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 5px 10px; border-radius: 999px;
  white-space: nowrap;
}
.badge-ingresado { background: #E4E9ED; color: var(--ink-soft); }
.badge-en_proceso { background: #FCEBDD; color: var(--warn); }
.badge-listo { background: #DFF1E6; color: var(--ok); }
.badge-entregado { background: #22282E; color: #fff; }

/* --------------------------------------------------------------- EMPTY */
.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-soft); }
.empty-title { font-weight: 700; font-size: 1.1rem; color: var(--ink); margin-bottom: 6px; }
.empty-sub { margin: 0; }

/* --------------------------------------------------------------- FORMS */
.form-row { display: grid; gap: 14px; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
@media (max-width: 640px) {
  .form-row-2, .form-row-4 { grid-template-columns: 1fr; }
}

.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; color: var(--ink-soft); }
.field input, .field textarea {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--ink);
  outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--line); }
.field textarea { min-height: 100px; resize: vertical; }
.form-error {
  background: #FBEAEA; color: var(--danger);
  border: 1px solid #EFC6C6;
  padding: 12px 14px; border-radius: var(--radius-sm);
  margin-bottom: 16px; font-weight: 600;
}
.form-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }

/* --------------------------------------------------------- SHEET HEADER */
.sheet-header {
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-bottom: 16px;
  background: var(--panel);
  text-align: center;
}
.sheet-title {
  margin: 0;
  font-family: var(--font-body);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 700;
  font-size: 1.3rem;
}
.sheet-title-brand { color: #C0392B; }
.sheet-title-rest { color: #2452A8; }
.sheet-sub { margin: 6px 0 0; color: var(--ink); font-size: 0.92rem; font-weight: 700; }

.inspect-instruction {
  color: #2452A8;
  font-weight: 700;
  font-size: 0.92rem;
  margin: 0 0 14px;
}

/* -------------------------------------------------------------- DETAIL */
.detail-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  margin-bottom: 20px;
}
.detail-placa { font-size: 1.6rem; font-weight: 700; letter-spacing: 0.08em; }
.detail-cliente { margin: 4px 0 0; color: var(--ink-soft); font-size: 1.05rem; }
.estado-select {
  min-height: 48px; padding: 8px 14px;
  border-radius: 999px; border: 2px solid var(--border);
  background: var(--panel); font-weight: 600; color: var(--ink);
}

.tabs { display: flex; gap: 6px; background: #E4E9ED; padding: 5px; border-radius: 999px; margin-bottom: 20px; }
.tab-btn {
  flex: 1; min-height: 48px;
  border: none; background: transparent; border-radius: 999px;
  font-weight: 700; letter-spacing: 0.02em; color: var(--ink-soft);
  cursor: pointer;
}
.tab-btn.active { background: var(--line); color: #fff; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadein .15s ease-out; }

.info-list { display: grid; grid-template-columns: 160px 1fr; gap: 4px 16px; margin: 0 0 20px; }
.info-list dt {
  color: var(--ink-soft); font-weight: 700; font-size: 0.82rem;
  text-transform: uppercase; letter-spacing: 0.03em;
  align-self: end; padding-bottom: 6px;
}
.info-list dd {
  margin: 0; padding-bottom: 8px;
  border-bottom: 1px dotted var(--border);
  min-height: 1.4em;
}

/* -------------------------------------------------------------- CANVAS */
.canvas-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.tool-btn {
  min-height: 48px; padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--panel); color: var(--ink); font-weight: 600;
  cursor: pointer;
}
.tool-btn.active { border-color: var(--accent); color: var(--accent); background: #FFF2E9; }
.tool-btn-muted { color: var(--ink-soft); margin-right: auto; }

.danos-layout {
  display: grid;
  grid-template-columns: minmax(260px, 420px) 1fr;
  gap: 16px;
  align-items: start;
}

.canvas-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow);
}
#damage-canvas {
  width: 100%; height: auto; display: block;
  touch-action: none;
  border-radius: var(--radius-sm);
  background: #fff;
  aspect-ratio: 440 / 581;
}

.legend-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.legend-header {
  background: #E4E9ED;
  color: var(--ink);
  font-weight: 700;
  text-align: center;
  padding: 10px;
  border-bottom: 1px solid var(--border);
}
.legend-table { display: flex; flex-direction: column; }
.legend-item {
  display: grid;
  grid-template-columns: 56px 1fr;
  align-items: stretch;
  min-height: 44px;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: var(--panel);
  cursor: pointer;
  text-align: left;
  padding: 0;
}
.legend-item:last-child { border-bottom: none; }
.legend-item.active { background: #FFF2E9; }
.legend-code {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--ink);
  background: #F3F5F7;
  border-right: 1px solid var(--border);
  border-radius: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.legend-item.active .legend-code { background: var(--accent); color: #fff; }
.legend-label {
  font-size: 0.82rem; color: var(--ink);
  display: flex; align-items: center;
  padding: 6px 10px;
  line-height: 1.2;
}

@media (max-width: 780px) {
  .danos-layout { grid-template-columns: 1fr; }
}
.hint { color: var(--ink-soft); font-size: 0.9rem; margin-top: 10px; }
.hint:not(.hidden) { color: var(--ok); font-weight: 600; }

/* -------------------------------------------------------------- CAMERA */
.camera-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
#camera-video {
  width: 100%; max-height: 420px;
  background: #101316;
  border-radius: var(--radius-sm);
  display: block;
  object-fit: cover;
}
.camera-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

.fotos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}
.foto-thumb {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  background: #E4E9ED;
}
.foto-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ------------------------------------------------------------- LIGHTBOX */
.lightbox {
  position: fixed; inset: 0; background: rgba(11,13,16,0.92);
  z-index: 50; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.lightbox-close { position: absolute; top: 16px; right: 16px; background: rgba(255,255,255,0.1); }
.lightbox-delete { position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--danger); color: #fff; border-color: var(--danger); }

/* ---------------------------------------------------------------- TOAST */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--line); color: #fff;
  padding: 14px 22px; border-radius: 999px;
  font-weight: 600; box-shadow: var(--shadow);
  z-index: 60;
  animation: toastin .15s ease-out;
}
@keyframes toastin { from { opacity:0; transform: translate(-50%, 8px);} to { opacity:1; transform: translate(-50%,0);} }

/* --------------------------------------------------------- ACCESIBILIDAD */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ------------------------------------------------------------ RESPONSIVE */
@media (max-width: 640px) {
  #app { padding: 16px 14px 40px; }
  .detail-head { flex-direction: column; }
  .info-list { grid-template-columns: 1fr; }
  .info-list dt { margin-top: 8px; }
}
