/* =============================================================================
   MyG · Panel de Órdenes de Trabajo
   Paleta: navy (marca), papel frío, semáforo industrial desaturado
   Tipografía: Nunito (interfaz) + JetBrains Mono (datos: códigos, teléfonos, horas)
   ============================================================================= */

:root {
  --navy:        #1F3864;
  --navy-dark:   #142647;
  --navy-soft:   #E7ECF4;
  --paper:       #F4F5F3;
  --panel:       #FFFFFF;
  --ink:         #23262B;
  --ink-soft:    #6B6F76;
  --line:        #DFE2E6;
  --line-strong: #C7CBD1;

  --rojo:        #C0392B;
  --rojo-soft:   #FBEAE8;
  --amarillo:    #C77800;
  --amarillo-soft: #FCF1DD;
  --verde:       #2F7D5C;
  --verde-soft:  #E7F3EE;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --font-ui:   'Nunito', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; }

/* ---------- estructura general ---------- */

.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--navy);
  color: #fff;
  padding: 0 24px;
  height: 64px;
  flex-shrink: 0;
  box-shadow: 0 1px 0 rgba(0,0,0,.08);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { color: #7FA3D9; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 800; font-size: 15px; letter-spacing: .2px; }
.brand-sub  { font-weight: 400; font-size: 12.5px; color: #AFC2E0; }

.topbar-meta { display: flex; align-items: center; gap: 16px; }
.clock {
  font-family: var(--font-mono);
  font-size: 13px;
  color: #AFC2E0;
  letter-spacing: .5px;
  min-width: 72px;
  text-align: right;
}

.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.18);
  color: #fff;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease;
}
.btn-ghost:hover { background: rgba(255,255,255,.16); }
.btn-ghost svg { flex-shrink: 0; }

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 0;
}

/* ---------- filtros ---------- */

.filters {
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  overflow-y: auto;
}

.filters-group { display: flex; flex-direction: column; gap: 8px; }
.filters-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--ink-soft);
}

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-row--vert { flex-direction: column; align-items: flex-start; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .12s ease;
}
.chip:hover { border-color: var(--line-strong); }
.chip.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }

.chip--rojo.is-active     { background: var(--rojo); border-color: var(--rojo); }
.chip--amarillo.is-active { background: var(--amarillo); border-color: var(--amarillo); }
.chip--verde.is-active    { background: var(--verde); border-color: var(--verde); }

.filters-summary {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--ink-soft);
}
.filters-summary #countBadge { font-weight: 800; color: var(--navy); font-size: 14px; }

/* ---------- LED de prioridad (elemento firma) ---------- */

.led {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.led--rojo     { background: var(--rojo);     box-shadow: 0 0 0 3px var(--rojo-soft); }
.led--amarillo { background: var(--amarillo); box-shadow: 0 0 0 3px var(--amarillo-soft); }
.led--verde    { background: var(--verde);    box-shadow: 0 0 0 3px var(--verde-soft); }

.led--pulse { animation: ledPulse 1.8s ease-in-out infinite; }
@keyframes ledPulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--rojo-soft); }
  50%      { box-shadow: 0 0 0 6px var(--rojo-soft); }
}

@media (prefers-reduced-motion: reduce) {
  .led--pulse { animation: none; }
}

/* ---------- listado de órdenes ---------- */

.board { padding: 20px 24px; overflow-y: auto; }

.list-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-soft);
  font-size: 14px;
}

.order-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.order-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line-strong);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  cursor: pointer;
  display: grid;
  grid-template-columns: auto 100px 1fr auto auto;
  align-items: center;
  gap: 16px;
  transition: border-color .12s ease, transform .08s ease, box-shadow .12s ease;
}
.order-card:hover {
  border-color: var(--line-strong);
  box-shadow: 0 2px 8px rgba(31,56,100,.08);
  transform: translateY(-1px);
}
.order-card--rojo     { border-left-color: var(--rojo); }
.order-card--amarillo { border-left-color: var(--amarillo); }
.order-card--verde    { border-left-color: var(--verde); }

.order-card-led { display: flex; align-items: center; }

.order-card-code {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13.5px;
  color: var(--navy);
}
.order-card-fabrica {
  font-size: 11.5px;
  color: var(--ink-soft);
  margin-top: 2px;
}

.order-card-desc {
  font-size: 13.5px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-card-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

.status-pill {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.status-pill--recibida { background: var(--navy-soft); color: var(--navy); }
.status-pill--asignada { background: #EEE7F8; color: #5B3E9E; }
.status-pill--en_curso { background: var(--amarillo-soft); color: var(--amarillo); }
.status-pill--cerrada  { background: var(--verde-soft); color: var(--verde); }

.order-card-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-soft);
}

.order-card-fotos {
  font-size: 11px;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ---------- overlay + drawer ---------- */

.overlay {
  position: fixed; inset: 0;
  background: rgba(20,26,40,.35);
  z-index: 40;
}

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(460px, 100vw);
  background: var(--panel);
  z-index: 50;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 24px rgba(0,0,0,.14);
  animation: drawerIn .18s ease-out;
}
@keyframes drawerIn { from { transform: translateX(24px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--line);
}
.drawer-code { font-family: var(--font-mono); font-weight: 700; font-size: 17px; color: var(--navy); }
.drawer-sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; }

.btn-icon {
  background: none; border: none; color: var(--ink-soft);
  cursor: pointer; padding: 4px; border-radius: 6px;
  display: flex;
}
.btn-icon:hover { background: var(--paper); color: var(--ink); }

.drawer-body { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 22px; }

.dsection-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: var(--ink-soft); margin: 0 0 8px;
}

.dsection-desc { font-size: 14px; line-height: 1.5; }

.badge-row { display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700;
  padding: 5px 10px; border-radius: 999px;
}
.badge--rojo     { background: var(--rojo-soft); color: var(--rojo); }
.badge--amarillo { background: var(--amarillo-soft); color: var(--amarillo); }
.badge--verde    { background: var(--verde-soft); color: var(--verde); }
.badge--info     { background: var(--navy-soft); color: var(--navy); }

.meta-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px;
  font-size: 13px;
}
.meta-grid dt { color: var(--ink-soft); font-size: 11.5px; margin-bottom: 2px; }
.meta-grid dd { margin: 0; font-family: var(--font-mono); font-size: 12.5px; }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-grid img {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  cursor: pointer;
}
.photo-empty { font-size: 13px; color: var(--ink-soft); }

.timeline { display: flex; flex-direction: column; gap: 10px; }
.timeline-item {
  display: flex; gap: 10px; font-size: 12.5px; padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
}
.timeline-item:last-child { border-bottom: none; padding-bottom: 0; }
.timeline-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--navy); margin-top: 5px; flex-shrink: 0; }
.timeline-text strong { font-weight: 700; }
.timeline-time { font-family: var(--font-mono); color: var(--ink-soft); font-size: 11px; margin-top: 2px; }

/* ---------- formularios de acción ---------- */

.action-block {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.action-block-title { font-size: 13px; font-weight: 700; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11.5px; color: var(--ink-soft); font-weight: 600; }
.field input, .field select, .field textarea {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  font-family: var(--font-ui);
  background: #fff;
  color: var(--ink);
}
.field textarea { resize: vertical; min-height: 56px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--navy);
  outline-offset: 1px;
  border-color: var(--navy);
}

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.btn-primary {
  background: var(--navy); color: #fff; border: none;
  padding: 9px 14px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 700; cursor: pointer;
  transition: background .12s ease;
}
.btn-primary:hover { background: var(--navy-dark); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-danger {
  background: var(--rojo); color: #fff; border: none;
  padding: 9px 14px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 700; cursor: pointer;
}
.btn-danger:hover { background: #A22E22; }

/* ---------- toast ---------- */

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: var(--radius-md);
  font-size: 13px; font-weight: 600;
  z-index: 100;
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
.toast--error { background: var(--rojo); }
.toast--ok { background: var(--verde); }

/* ---------- responsive ---------- */

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .filters {
    border-right: none; border-bottom: 1px solid var(--line);
    flex-direction: row; flex-wrap: wrap; padding: 14px 16px;
  }
  .filters-summary { display: none; }
  .order-card { grid-template-columns: auto 1fr; grid-template-areas: "led code" "led desc" "led meta"; row-gap: 4px; }
  .order-card-fabrica-wrap { grid-area: code; }
  .drawer { width: 100vw; }
}

/* ---------- accesibilidad: foco visible ---------- */

button:focus-visible, .chip:focus-visible, .order-card:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

/* ===== Pantalla de login (3940AG-MD-DISENO_FASE1_SEGURIDAD-revA, 5.5) ===== */
.login-body {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: var(--navy-dark);
  font-family: var(--font-ui);
}
.login-card {
  width: 100%; max-width: 360px;
  background: var(--panel);
  border-radius: var(--radius-lg);
  padding: 28px 26px 24px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; color: var(--navy); }
.login-brand .brand-mark { color: var(--navy); }
.login-title { font-weight: 800; font-size: 16px; color: var(--ink); }
.login-sub   { font-size: 13px; color: var(--ink-soft); }
.login-form  { display: flex; flex-direction: column; }
.login-label { font-size: 12.5px; font-weight: 700; color: var(--ink-soft); margin: 10px 0 6px; }
.login-input {
  font: inherit; font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
}
.login-input:focus { outline: 2px solid var(--navy); outline-offset: 1px; border-color: var(--navy); }
.login-error {
  margin: 14px 0 0;
  padding: 9px 11px;
  background: var(--rojo-soft);
  color: var(--rojo);
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
}
.login-btn {
  margin-top: 18px;
  padding: 11px;
  background: var(--navy);
  color: #fff;
  border: 0;
  border-radius: var(--radius-sm);
  font: inherit; font-size: 15px; font-weight: 700;
  cursor: pointer;
}
.login-btn:hover { background: var(--navy-dark); }
.login-btn:disabled { opacity: .6; cursor: default; }
