/* ============================================================
   Sistema de Cotizaciones — hoja de estilos
   Paleta: tinta profunda + verde taller, tipografía mono para cifras
   ============================================================ */

:root {
  --ink: #16202A;
  --ink-soft: #2A3947;
  --paper: #F4F5F2;
  --paper-card: #FFFFFF;
  --line: #DDE1DC;
  --line-soft: #E9EBE7;
  --teal: #2F6F63;
  --teal-dark: #244F46;
  --teal-tint: #E7F0EE;
  --amber: #C1791F;
  --amber-tint: #FBF0DF;
  --red: #B4432E;
  --red-tint: #FBEAE6;
  --muted: #6C7A72;
  --shadow: 0 1px 2px rgba(22,32,42,0.04), 0 4px 14px rgba(22,32,42,0.05);

  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--teal-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: var(--teal-tint); color: var(--ink); }

/* ---------- Layout ---------- */
.app-shell {
  display: grid;
  grid-template-columns: 224px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--ink);
  color: #E7ECE9;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar__brand {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.01em;
  color: #fff;
  padding: 0 8px 22px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 18px;
}
.sidebar__brand small {
  display: block;
  font-weight: 400;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #93A39A;
  letter-spacing: 0.04em;
  margin-top: 3px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 8px;
  color: #C7D1CB;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--teal); color: #fff; }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.9; }

.sidebar__footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 13px;
}
.sidebar__footer .user {
  color: #93A39A;
  margin-bottom: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
}
.btn-logout {
  color: #E7ECE9;
  opacity: 0.75;
}
.btn-logout:hover { opacity: 1; }

.main {
  padding: 28px 36px 60px 36px;
  max-width: 1180px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header h1 {
  font-size: 22px;
  margin: 0 0 4px 0;
  letter-spacing: -0.01em;
}
.page-header .subtitle { color: var(--muted); font-size: 13.5px; }

/* ---------- Cards ---------- */
.card {
  background: var(--paper-card);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 20px;
}
.card h2, .card h3 {
  margin-top: 0;
  font-size: 15px;
  color: var(--ink);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--paper-card);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat-card .label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.stat-card .value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 600;
  color: var(--ink);
}
.stat-card .value.teal { color: var(--teal-dark); }

/* ---------- Forms ---------- */
label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 5px;
  letter-spacing: 0.01em;
}
input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 14px;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
  border-color: var(--teal);
}
textarea { resize: vertical; min-height: 60px; }
.field { margin-bottom: 14px; }
.field-row {
  display: grid;
  gap: 12px;
}
.field-row.cols-2 { grid-template-columns: 1fr 1fr; }
.field-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.field-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

.help-text { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  transition: filter 0.12s ease, background 0.12s ease;
}
.btn:hover { text-decoration: none; filter: brightness(0.96); }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-danger { background: var(--red-tint); color: var(--red); }
.btn-ghost { background: transparent; color: var(--muted); border-color: transparent; }
.btn-ghost:hover { background: var(--line-soft); color: var(--ink); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  font-weight: 600;
}
tbody td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
tbody tr:hover { background: var(--paper); }
.mono { font-family: var(--font-mono); }
.text-right { text-align: right; }
.text-muted { color: var(--muted); }

/* ---------- Badges (estatus, estilo sello) ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-family: var(--font-mono);
}
.badge-pendiente { background: var(--amber-tint); color: var(--amber); }
.badge-aceptada { background: var(--teal-tint); color: var(--teal-dark); }
.badge-rechazada { background: var(--red-tint); color: var(--red); }

/* ---------- Folio tag ---------- */
.folio-tag {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 3px solid var(--teal);
  padding: 4px 10px;
  border-radius: 4px;
  display: inline-block;
}

/* ---------- Filtros ---------- */
.filters-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 18px;
}
.filters-bar .field { margin-bottom: 0; min-width: 160px; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  padding: 20px;
}
.login-card {
  background: var(--paper-card);
  border-radius: 14px;
  padding: 36px 34px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.login-card .brand-mark {
  font-family: var(--font-mono);
  color: var(--teal);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.login-card h1 { font-size: 20px; margin: 0 0 22px 0; }
.login-error {
  background: var(--red-tint);
  color: var(--red);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ---------- Cotizador (líneas dinámicas) ---------- */
.items-table th, .items-table td { padding: 8px 6px; }
.items-table input { padding: 7px 9px; font-size: 13.5px; }
.items-table .col-desc { width: 46%; }
.items-table .col-qty { width: 10%; }
.items-table .col-price { width: 16%; }
.items-table .col-sub { width: 16%; }
.items-table .col-del { width: 40px; }

.totals-box {
  margin-left: auto;
  width: 300px;
  margin-top: 12px;
}
.totals-box .row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
}
.totals-box .row.total {
  border-top: 1px solid var(--line);
  margin-top: 6px;
  padding-top: 10px;
  font-weight: 700;
  font-size: 17px;
  font-family: var(--font-mono);
}
.totals-box .row .val { font-family: var(--font-mono); }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--muted);
}
.empty-state svg { width: 40px; height: 40px; opacity: 0.4; margin-bottom: 10px; }

/* ---------- Preview modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(22,32,42,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 14px;
  max-width: 640px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.3);
}
.modal-box .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}
.modal-close { cursor: pointer; color: var(--muted); font-size: 20px; background: none; border: none; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  z-index: 200;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; flex-direction: row; overflow-x: auto; align-items: center; }
  .sidebar__brand, .sidebar__footer { display: none; }
  .nav-item { white-space: nowrap; }
  .main { padding: 20px; }
  .field-row.cols-2, .field-row.cols-3, .field-row.cols-4 { grid-template-columns: 1fr; }
  .totals-box { width: 100%; }
}

/* Accessibility: visible focus */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
