/* =========================================================================
   Save Fleet CRM — hoja de estilos base (tema claro/oscuro con variables)
   ========================================================================= */
:root {
  --sidebar-bg: #0f172a;
  --sidebar-fg: #cbd5e1;
  --sidebar-fg-muted: #64748b;
  --sidebar-active: #29abe2;
  --brand: #1b74c4;              /* azul Innovaria */
  --brand-cyan: #29abe2;         /* cian Innovaria */
  --brand-navy: #1b3a73;         /* azul marino Innovaria */
  --brand-gray: #4d4d4f;         /* gris carbón (texto del logo) */

  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --radius: 12px;

  --blue: #2563eb;   --blue-bg: #dbeafe;
  --amber: #b45309;  --amber-bg: #fef3c7;
  --green: #15803d;  --green-bg: #dcfce7;
  --red: #b91c1c;    --red-bg: #fee2e2;
  --slate: #475569;  --slate-bg: #e2e8f0;
}
html[data-theme="dark"] {
  --sidebar-bg: #0b1220;
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #172033;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: #334155;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  --blue-bg:#1e3a8a; --amber-bg:#78350f; --green-bg:#14532d; --red-bg:#7f1d1d; --slate-bg:#334155;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--brand); text-decoration: none; }

/* ---- Layout ---- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; flex-shrink: 0;
  background: var(--sidebar-bg); color: var(--sidebar-fg);
  display: flex; flex-direction: column;
  position: fixed; inset: 0 auto 0 0; height: 100vh; overflow-y: auto;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 20px 16px; font-weight  : 800; letter-spacing: .5px; color: #fff;
  background-color: var(--bg); /* Un fondo oscuro hace que la sombra blanca resalte más */
}
.sidebar__logo {
  width: 90%;
}
/* Marca de palabra INNOVARIA (INN en azules, OVARIA en gris) */
.wordmark { font-weight: 800; letter-spacing: .5px; }
.wordmark .c1 { color: var(--brand-cyan); }
.wordmark .c2 { color: var(--brand); }
.wordmark .c3 { color: var(--brand-navy); }
.wordmark .c4 { color: var(--brand-gray); }
.sidebar__section { padding: 14px 20px 6px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--sidebar-fg-muted); }
.sidebar__link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 20px; color: var(--sidebar-fg); font-size: 14.5px; border-left: 3px solid transparent;
}
.sidebar__link:hover { background: rgba(255,255,255,.05); color: #fff; }
.sidebar__link.active { background: rgba(37,99,235,.16); color: #fff; border-left-color: var(--sidebar-active); }
.sidebar__link svg { width: 18px; height: 18px; opacity: .9; }

.main { margin-left: 250px; flex: 1; display: flex; flex-direction: column; min-width: 0; }
.header {
  height: 62px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
  position: sticky; top: 0; z-index: 10;
}
.header__title { font-weight: 700; font-size: 17px; }
.header__right { display: flex; align-items: center; gap: 14px; }
.user-chip { display: flex; align-items: center; gap: 9px; }
.user-chip__avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--blue-bg); color: var(--blue);
  display: grid; place-items: center; font-weight: 700;
}
.user-chip__meta small { color: var(--text-muted); display: block; font-size: 12px; }

.content { padding: 26px 24px; }

/* ---- Botones ---- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 14px; cursor: pointer; font-weight: 600;
}
.btn:hover { background: var(--surface-2); }
.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--primary:hover { filter: brightness(1.05); }
.btn--danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn--sm { padding: 6px 11px; font-size: 13px; }
.btn--ghost { background: transparent; }
.icon-btn { background: transparent; border: 0; cursor: pointer; color: var(--text-muted); padding: 6px; border-radius: 8px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---- Tarjetas ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card__body { padding: 20px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--text-muted); font-size: 14px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { padding: 18px 20px; }
.stat__label { color: var(--text-muted); font-size: 13px; font-weight: 600; }
.stat__value { font-size: 30px; font-weight: 800; margin-top: 4px; }

/* ---- Tablas ---- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
table.data th { color: var(--text-muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; }
table.data tbody tr:hover, table.data tbody tr:hover { background: var(--surface-2); }

/* ---- Badges ---- */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge--blue  { background: var(--blue-bg);  color: var(--blue); }
.badge--amber { background: var(--amber-bg); color: var(--amber); }
.badge--green { background: var(--green-bg); color: var(--green); }
.badge--red   { background: var(--red-bg);   color: var(--red); }
.badge--slate { background: var(--slate-bg); color: var(--slate); }

/* ---- Formularios ---- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 13.5px; font-weight: 600; }
input, select {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text); font-size: 14.5px; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }
.hint { color: var(--text-muted); font-size: 12.5px; }

/* ---- Flash ---- */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-weight: 600; font-size: 14px; }
.flash--success { background: var(--green-bg); color: var(--green); }
.flash--error { background: var(--red-bg); color: var(--red); }

/* ---- Login ---- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; background:
  radial-gradient(1200px 500px at 10% -10%, rgba(37,99,235,.18), transparent),
  var(--bg); padding: 20px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .card__body { padding: 30px; }
.auth-logo { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 6px; font-weight: 800; font-size: 20px; }
.auth-sub { text-align: center; color: var(--text-muted); margin: 0 0 22px; font-size: 14px; }

/* ---- Roles matrix ---- */
.role-card { margin-bottom: 16px; }
.role-card h3 { margin: 0 0 4px; }
.perm-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.perm-tag { font-size: 12px; padding: 3px 9px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); }

/* ---- Responsive ---- */
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; z-index: 30; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .menu-toggle { display: inline-flex !important; }
}
.menu-toggle { display: none; }

/* ===== Órdenes: lista compacta de unidades (compactar/desplegar) ===== */
.units-toolbar { display:flex; justify-content:space-between; align-items:center; gap:10px; flex-wrap:wrap; margin:6px 0 10px; }
table.units { width:100%; border-collapse:collapse; }
table.units th { color: var(--text-muted); font-weight:600; font-size:12px; text-transform:uppercase; letter-spacing:.03em; text-align:left; padding:8px 10px; border-bottom:1px solid var(--border); }
table.units td { padding:9px 10px; border-bottom:1px solid var(--border); vertical-align:middle; font-size:13.5px; }
tr.unit-row { cursor:pointer; }
tr.unit-row:hover { background: var(--surface-2); }
tr.unit-row.is-open { background: var(--surface-2); }
tr.unit-row td.caret { width:26px; color: var(--text-muted); }
tr.unit-row .caret span { display:inline-block; transition: transform .15s ease; }
tr.unit-row.is-open .caret span { transform: rotate(90deg); }
.unit-detail > td { background: var(--surface-2); padding:0; border-bottom:1px solid var(--border); }
.unit-detail .detail-inner { padding:14px 16px 18px; }
.prod-chip { display:inline-block; background: var(--brand); color:#fff; font-weight:700; font-size:12px; padding:3px 9px; border-radius:7px; white-space:nowrap; }
.speed-chip { display:inline-flex; align-items:center; gap:4px; background: var(--amber-bg); color: var(--amber); font-weight:800; font-size:13.5px; padding:3px 10px; border-radius:999px; white-space:nowrap; }
.vin-strong { font-weight:700; letter-spacing:.02em; }
.units-done table.units td { opacity:.85; }

/* Filas de unidad no desplegables (p.ej. completadas para el técnico) */
tr.unit-row.not-expandable { cursor: default; }
tr.unit-row.not-expandable:hover { background: transparent; }
/* El campo de motivo de cancelación se muestra solo al elegir "Cancelada" */
[data-cancel-reason] { display: none; }
[data-cancel-reason].show { display: block; }
