/* ═══════════════════════════════════════════════════════
   styles.css — Estación Mecánico, Servicio Técnico Volvo
   ═══════════════════════════════════════════════════════ */

:root {
  --bg:       #0f1117;
  --surf:     #181c26;
  --surf2:    #1f2436;
  --border:   rgba(255,255,255,0.07);
  --text:     #e8eaf0;
  --muted:    #6b7280;
  --accent:   #f0c040;
  --success:  #22c55e;
  --warn:     #f59e0b;
  --danger:   #ef4444;
  --info:     #60a5fa;
  --r:        12px;
  --r-sm:     8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── HEADER ─────────────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(15,17,23,0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.brand-h {
  font-family: 'Space Mono', monospace;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.brand-h span { color: var(--accent); }

.hdr-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wh-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  transition: all 0.4s;
  white-space: nowrap;
}
.wh-badge.active   { background: rgba(34,197,94,0.12); color: #4ade80; border: 1px solid rgba(34,197,94,0.22); }
.wh-badge.inactive { background: rgba(239,68,68,0.10); color: #f87171; border: 1px solid rgba(239,68,68,0.2); }

.user-pill {
  font-size: 12px;
  font-weight: 600;
  background: var(--surf2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 13px;
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: border-color 0.2s, background 0.2s;
}
.user-pill:hover { background: var(--surf); border-color: rgba(255,255,255,0.15); }

/* ── OVERLAY — nombre ────────────────────────────────────── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  z-index: 999;
  justify-content: center;
  align-items: center;
  padding: 20px;
}
.overlay.open { display: flex; }

.name-box {
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 40px 32px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,0.6);
}
.brand {
  font-family: 'Space Mono', monospace;
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 22px;
}
.brand span { color: var(--accent); }
.name-box h2 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.name-box p  { font-size: 13px; color: var(--muted); line-height: 1.55; margin-bottom: 24px; }

.name-box input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  margin-bottom: 14px;
  transition: border-color 0.2s;
}
.name-box input:focus { border-color: rgba(240,192,64,0.5); }
.name-box button {
  width: 100%;
  padding: 13px;
  background: var(--accent);
  color: #111;
  border: none;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.2s;
}
.name-box button:hover { opacity: 0.85; }

.auth-error {
  display: none;
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.3);
  color: #f87171;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  margin-bottom: 14px;
  text-align: left;
}

.btn-salir {
  font-size: 12px;
  font-weight: 600;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.65);
  padding: 5px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.2s, color 0.2s;
}
.btn-salir:hover { border-color: rgba(255,255,255,0.4); color: white; }

/* ── TOAST ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surf2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 22px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  white-space: nowrap;
  z-index: 500;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── MAIN LAYOUT ─────────────────────────────────────────── */
main { padding: 20px 16px 48px; }

.wrap {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── CARD ────────────────────────────────────────────────── */
.card {
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
}

.card-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.card-title { font-size: 14px; font-weight: 600; }

.btn-ico {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 17px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}
.btn-ico:hover { color: var(--text); background: var(--surf2); }

/* ── FIELDS ─────────────────────────────────────────────── */
.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 8px;
}
.lbl-opt {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
}

.field input[type="text"],
.field textarea {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  resize: none;
}
.field input[type="text"]:focus,
.field textarea:focus { border-color: rgba(240,192,64,0.45); }
.field textarea { min-height: 64px; resize: vertical; }

/* ── SEARCH DROPDOWN ─────────────────────────────────────── */
.srch-wrap { position: relative; }

.srch-drop {
  display: none;
  position: absolute;
  top: calc(100% + 5px);
  left: 0; right: 0;
  background: var(--surf2);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--r-sm);
  overflow: hidden;
  z-index: 60;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
  max-height: 300px;
  overflow-y: auto;
}
.srch-drop.open { display: block; }

.dd-item {
  padding: 11px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.dd-item:last-child { border-bottom: none; }
.dd-item:hover { background: rgba(255,255,255,0.05); }
.dd-name { font-size: 14px; font-weight: 500; margin-bottom: 3px; }
.dd-meta { font-size: 11px; color: var(--muted); }
.dd-stock-ok   { color: #4ade80; }
.dd-stock-warn { color: #fbbf24; }

.dd-empty {
  padding: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* ── PART PREVIEW ────────────────────────────────────────── */
.part-preview {
  display: none;
  flex-direction: row;
  align-items: center;
  gap: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  margin-bottom: 16px;
  animation: fadeIn 0.2s ease;
}
.part-preview.show { display: flex; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.prev-img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  background: var(--surf2);
}
.prev-no-img {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  background: var(--surf2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.prev-info { flex: 1; min-width: 0; }
.prev-name { font-size: 14px; font-weight: 600; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prev-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.p-tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--surf2);
  color: var(--muted);
  white-space: nowrap;
}
.p-tag.ok   { color: #4ade80; }
.p-tag.warn { color: #fbbf24; }
.p-tag.low  { color: #f87171; }

/* ── QUANTITY ────────────────────────────────────────────── */
.qty-row {
  display: flex;
  align-items: center;
  width: fit-content;
}
.qty-btn {
  width: 42px;
  height: 42px;
  background: var(--surf2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.qty-btn:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.qty-btn:last-child  { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.qty-btn:hover { background: rgba(255,255,255,0.1); }

#qtyInput {
  width: 68px;
  height: 42px;
  text-align: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: none;
  border-right: none;
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  font-family: 'Space Mono', monospace;
  outline: none;
}

/* ── SEND BUTTON ─────────────────────────────────────────── */
.btn-send {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #111;
  border: none;
  border-radius: var(--r-sm);
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.2s, background 0.35s;
  margin-top: 4px;
}
.btn-send:hover:not(:disabled) { opacity: 0.88; }
.btn-send:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-send.sent { background: var(--success); color: white; }

/* ── PEDIDOS LIST ────────────────────────────────────────── */
.empty-msg {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 32px 0;
}

.pedido-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 10px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s;
}
.pedido-item::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--muted);
  border-radius: 4px 0 0 4px;
}
.pedido-item.est-pendiente::before  { background: var(--warn); }
.pedido-item.est-en_proceso::before { background: var(--info); }
.pedido-item.est-atendido::before   { background: var(--success); }
.pedido-item.est-cancelado::before  { background: var(--danger); opacity: 0.5; }
.pedido-item.est-atendido           { opacity: 0.65; }
.pedido-item.est-cancelado          { opacity: 0.45; }
.pedido-item:last-child             { margin-bottom: 0; }

.ped-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}
.ped-name { font-size: 16px; font-weight: 600; line-height: 1.3; }
.ped-qty  { font-size: 13px; color: var(--muted); margin-top: 4px; font-weight: 500; }
.ped-time { font-size: 12px; color: var(--muted); white-space: nowrap; flex-shrink: 0; font-family: 'Space Mono', monospace; }

.ped-bot  { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ped-nota { font-size: 13px; color: var(--muted); font-style: italic; }

.estado {
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 20px;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.estado.pendiente  { background: rgba(245,158,11,0.16); color: #fbbf24; border: 1px solid rgba(245,158,11,0.25); }
.estado.en_proceso { background: rgba(96,165,250,0.16); color: #93c5fd; border: 1px solid rgba(96,165,250,0.25); }
.estado.atendido   { background: rgba(34,197,94,0.14);  color: #4ade80; border: 1px solid rgba(34,197,94,0.25); }
.estado.cancelado  { background: rgba(239,68,68,0.12);  color: #f87171; border: 1px solid rgba(239,68,68,0.2); }

.hist-day-sep {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  padding: 18px 0 8px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.hist-day-sep:first-child { border-top: none; margin-top: 0; padding-top: 4px; }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (min-width: 600px) {
  main { padding: 28px 24px 60px; }
  .card { padding: 24px 28px; }
}
