/* Portal del cliente — rediseño 2026-09-18.
   Principios: mobile-first 100%, tipografía grande y legible (adultos mayores),
   targets táctiles ≥48px, cero webfonts (system stack = rápido en celulares
   flojos), fondo negro puro que funde con el logo original del taller. */
:root {
  --bg: #0a0a0b;
  --card: #131316;
  --card2: #1c1c21;
  --border: #2a2a30;
  --text: #f5f5f5;
  --muted: #9d9da8;
  --accent: #e63946;
  --accent-press: #c92c39;
  --ok: #34b06f;
  --warn: #ffb44d;
  --wsp: #25d366;
  --radius: 16px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Header: el logo original sobre negro puro (el PNG funde solo) */
.p-header {
  padding: calc(6px + env(safe-area-inset-top)) 16px 2px;
  text-align: center;
}
.p-logo { width: 88px; height: 88px; object-fit: contain; }

#p-main { flex: 1; width: 100%; max-width: 680px; margin: 0 auto; padding: 4px 14px 20px; }

.p-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px;
  margin-bottom: 14px;
}
.p-hidden { display: none !important; }

.p-title { font-size: 24px; line-height: 1.25; margin: 0 0 10px; letter-spacing: -0.3px; }
.p-copy { color: var(--muted); font-size: 16px; margin: 0 0 16px; }
.p-copy-small { font-size: 14px; margin: 14px 0 0; }
.p-copy a, .p-footer a { color: var(--text); text-underline-offset: 3px; }

.p-trust { list-style: none; margin: 18px 0 0; padding: 14px 0 0; border-top: 1px solid var(--border); display: grid; gap: 10px; }
.p-trust li { font-size: 15px; color: var(--muted); }

/* Loader con branding: dos engranajes engranados girando en contrafase */
.p-loader { text-align: center; padding: 12vh 20px 0; }
.p-gears { width: 120px; height: 96px; margin: 0 auto 18px; position: relative; }
.p-gear { position: absolute; color: var(--muted); }
.p-gear-big { width: 68px; height: 68px; left: 8px; top: 14px; animation: p-gear-cw 3.2s linear infinite; }
.p-gear-small { width: 44px; height: 44px; left: 68px; top: 0; color: var(--accent); animation: p-gear-ccw 2.1s linear infinite; }
@keyframes p-gear-cw { to { transform: rotate(360deg); } }
@keyframes p-gear-ccw { to { transform: rotate(-360deg); } }
@media (prefers-reduced-motion: reduce) {
  .p-gear-big { animation-duration: 8s; }
  .p-gear-small { animation-duration: 5.5s; }
}
.p-loader-brand { font-size: 14px; font-weight: 800; letter-spacing: 4px; text-transform: uppercase; }
.p-loader-text { font-size: 15px; color: var(--muted); margin-top: 8px; }
.p-loader-text::after { content: '…'; animation: p-dots 1.4s steps(4, end) infinite; display: inline-block; width: 1.2em; text-align: left; }
@keyframes p-dots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '…'; }
}

.p-error { color: #ff8a8a; font-size: 15px; margin: 12px 0 0; }
.p-ok { margin-top: 14px; background: var(--card2); border: 1px solid var(--ok); border-radius: 12px; padding: 14px; font-size: 16px; }

.p-field { margin-bottom: 14px; }
.p-field label { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.p-field input, .p-field select, .p-field textarea {
  width: 100%;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 18px;
  padding: 14px;
  font-family: inherit;
  min-height: 52px;
}
.p-field input { text-transform: uppercase; letter-spacing: 2px; }
.p-field input:focus, .p-field select:focus, .p-field textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.p-btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 16px;
  min-height: 54px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  font-family: inherit;
}
.p-btn-primary { background: var(--accent); color: #fff; }
.p-btn-primary:active { background: var(--accent-press); }
.p-btn-primary:disabled { opacity: 0.6; }
.p-btn-wsp { background: var(--wsp); color: #06300f; margin-top: 12px; }

/* Hero: la foto del vehículo como portada */
.p-hero {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  background: #000;
}
.p-hero img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block; }
.p-hero-shade {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.72) 0%, transparent 45%);
}
.p-hero-patente {
  position: absolute; left: 16px; bottom: 12px;
  font-size: 26px; font-weight: 800; letter-spacing: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  text-shadow: 0 1px 6px rgba(0,0,0,0.8);
}

.p-veh-card { text-align: center; padding: 18px; }
.p-veh-patente { font-size: 30px; font-weight: 800; letter-spacing: 3px; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.p-veh-desc { font-size: 17px; color: var(--text); margin-top: 2px; font-weight: 600; }
.p-veh-sub { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; margin-top: 6px; font-size: 14px; color: var(--muted); }

.p-section-title { font-size: 15px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); margin: 0 0 12px; font-weight: 700; }

/* Galerías de fotos/videos */
.p-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.p-gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; display: block; background: #000; }
.p-gallery a { border-radius: 10px; overflow: hidden; display: block; }
.p-gallery video { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 10px; display: block; background: #000; grid-column: 1 / -1; }

/* Tabs grandes tipo segmented control, pegajosos al scrollear */
.p-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
  position: sticky;
  top: 8px;
  z-index: 5;
  background: var(--bg);
  padding: 4px 0;
}
.p-tab {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--muted);
  font-size: 17px;
  font-weight: 700;
  padding: 14px 8px;
  min-height: 52px;
  cursor: pointer;
  font-family: inherit;
}
.p-tab-active { color: #fff; background: var(--card2); border-color: var(--accent); }

/* Reparaciones: cada una es una card propia */
.p-rep {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
}
.p-rep-fecha { font-size: 14px; color: var(--muted); }
.p-rep-motivo { font-size: 19px; font-weight: 700; margin: 3px 0 8px; line-height: 1.3; }
.p-rep-detalle { font-size: 16px; color: var(--muted); line-height: 1.55; white-space: pre-line; }
.p-rep-detalle strong { color: var(--text); }
.p-rep-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-radius: 8px;
  padding: 5px 10px;
  margin-top: 10px;
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--muted);
}
.p-rep-badge.finalizada { border-color: var(--ok); color: var(--ok); }
.p-rep-piezas { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.p-rep-pieza { font-size: 13px; background: var(--card2); border: 1px solid var(--border); border-radius: 8px; padding: 4px 10px; color: var(--muted); }
.p-rep .p-gallery { margin-top: 12px; }

/* Factura desplegable */
.p-factura { margin-top: 12px; background: var(--card2); border: 1px solid var(--border); border-radius: 12px; }
.p-factura summary {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 14px; cursor: pointer; list-style: none;
  font-size: 16px; font-weight: 700; min-height: 48px;
}
.p-factura summary::-webkit-details-marker { display: none; }
.p-factura-estado {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  border: 1px solid var(--border); border-radius: 8px; padding: 4px 9px; color: var(--muted);
}
.p-factura-estado.pagada { border-color: var(--ok); color: var(--ok); }
.p-factura-body { border-top: 1px solid var(--border); padding: 10px 14px 14px; }
.p-factura-row { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; color: var(--muted); padding: 5px 0; }
.p-factura-monto { font-family: ui-monospace, "SF Mono", Menlo, monospace; white-space: nowrap; }
.p-factura-total { border-top: 1px solid var(--border); margin-top: 5px; padding-top: 10px; color: var(--text); font-weight: 700; font-size: 17px; }
.p-factura-saldo { color: var(--warn); font-weight: 700; }

.p-btn-pdf {
  display: block;
  width: 100%;
  margin-top: 12px;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  padding: 13px;
  min-height: 50px;
  cursor: pointer;
  font-family: inherit;
}
.p-btn-pdf:active { border-color: var(--accent); }

/* Turnos */
.p-franjas { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.p-franja {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  padding: 14px 8px;
  min-height: 64px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}
.p-franja small { font-weight: 500; font-size: 13px; color: var(--muted); }
.p-franja.sel { border-color: var(--accent); background: rgba(230, 57, 70, 0.12); }
.p-franja:disabled { opacity: 0.4; cursor: not-allowed; }

/* Listado de vehículos (modo cliente / flotas) */
.p-veh-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  text-align: left;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  min-height: 64px;
  margin-bottom: 10px;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
}
.p-veh-item:active { border-color: var(--accent); }
.p-veh-item-patente { font-size: 22px; font-weight: 800; letter-spacing: 2px; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.p-veh-item-desc { font-size: 15px; color: var(--muted); }

/* Toolbar de la ficha */
.p-toolbar { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.p-toolbar-btn {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  padding: 10px 14px;
  min-height: 44px;
  cursor: pointer;
  margin-left: auto;
  font-family: inherit;
}
.p-toolbar-btn:first-child { margin-left: 0; }

.p-footer {
  border-top: 1px solid var(--border);
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.p-footer p { margin: 2px 0; }

/* Pantallas más anchas */
@media (min-width: 560px) {
  .p-gallery { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .p-gallery video { grid-column: span 2; }
  .p-logo { width: 104px; height: 104px; }
}

/* Impresión / guardar PDF de la ficha */
@media print {
  body { background: #fff; color: #000; }
  .p-header, .p-footer, .p-toolbar, .p-tabs, #panel-turno, .p-btn-pdf, .p-hero-shade { display: none !important; }
  .p-card, .p-factura, .p-rep { border: 1px solid #ccc; background: #fff; }
  .p-factura .p-factura-body { display: block; border-top: 1px solid #ccc; }
  .p-rep-detalle, .p-rep-fecha, .p-factura-row { color: #333; }
  .p-veh-desc, .p-veh-sub { color: #444; }
  #panel-historial { display: block !important; }
  .p-gallery video { display: none; }
}
