/* ==========================================================
   ALPHA AUTOMOTRIZ · COTIZADOR
   Mismos tokens visuales que la web pública de Alpha Automotriz
   ========================================================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #050608;
  --bg2: #080B0F;
  --card: #0C1018;
  --card2: #10141d;
  --accent: #3DEA24;
  --accent2: #2FC41B;
  --glow: rgba(61, 234, 36, 0.55);
  --glass: rgba(8, 12, 20, 0.72);
  --border: rgba(61, 234, 36, 0.22);
  --border-h: rgba(61, 234, 36, 0.6);
  --text: #EDF2F9;
  --muted: #7A8699;
  --dim: #3E4550;
  --danger: #ea3d3d;
  --danger-bg: rgba(234, 61, 61, 0.12);
  --warn: #eac33d;
  --warn-bg: rgba(234, 195, 61, 0.12);
  --ok: #3DEA24;
  --ok-bg: rgba(61, 234, 36, 0.12);
  --fh: 'Orbitron', monospace;
  --fb: 'Poppins', sans-serif;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--fb);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
  mix-blend-mode: overlay;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 99px; }

a { color: inherit; }

/* ---------- Layout ---------- */
.app { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 500;
  background: rgba(5, 6, 8, 0.92);
  backdrop-filter: blur(24px) saturate(200%);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.7rem 1.8rem;
  gap: 1rem; flex-wrap: wrap;
}
.topbar .brand { display: flex; align-items: center; gap: 12px; }
.topbar .brand img { max-height: 42px; width: auto; filter: drop-shadow(0 0 5px rgba(61,234,36,0.3)); }
.topbar .brand-fallback {
  font-family: var(--fh); font-weight: 900; font-size: 1.1rem; letter-spacing: 1px;
  color: var(--accent); text-shadow: 0 0 14px rgba(61,234,36,0.4);
}
.topbar nav { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.topbar nav a {
  font-size: 0.82rem; font-weight: 600; letter-spacing: 0.3px; color: var(--muted);
  text-decoration: none; padding: 0.5rem 0.9rem; border-radius: 99px; transition: 0.2s;
}
.topbar nav a:hover, .topbar nav a.active { color: var(--text); background: rgba(61,234,36,0.1); }
.topbar .userbox { display: flex; align-items: center; gap: 10px; font-size: 0.82rem; color: var(--muted); }
.topbar .userbox b { color: var(--text); }

.main { flex: 1; max-width: 1400px; width: 100%; margin: 0 auto; padding: 2rem 1.8rem 4rem; position: relative; z-index: 1; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.8rem; flex-wrap: wrap; }
.page-head h1 { font-family: var(--fh); font-size: 1.7rem; font-weight: 900; letter-spacing: 0.5px; }
.page-head h1 span { color: var(--accent); }
.page-head p { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 18px;
  padding: 1.5rem;
  position: relative;
}
.card.hl { border-color: var(--border); }
.card + .card { margin-top: 1.4rem; }
.card h2, .card h3 {
  font-family: var(--fh); font-weight: 800; letter-spacing: 0.4px;
  font-size: 1.02rem; margin-bottom: 1rem; display: flex; align-items: center; gap: 8px;
}
.card h2 i, .card h3 i { color: var(--accent); }

.grid { display: grid; gap: 1.2rem; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

/* ---------- Forms ---------- */
label { display: block; font-size: 0.72rem; letter-spacing: 0.5px; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field { margin-bottom: 1rem; }
input, select, textarea {
  width: 100%; background: var(--bg2); border: 1px solid rgba(255,255,255,0.08);
  color: var(--text); border-radius: 10px; padding: 0.65rem 0.9rem; font-family: var(--fb);
  font-size: 0.88rem; transition: border-color 0.2s, box-shadow 0.2s; outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--border-h); box-shadow: 0 0 0 3px rgba(61,234,36,0.12);
}
input[readonly] { opacity: 0.65; }
textarea { resize: vertical; min-height: 80px; }
.input-with-btn { display: flex; gap: 8px; }
.input-with-btn input { flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  font-family: var(--fh); font-weight: 800; font-size: 0.78rem; letter-spacing: 0.8px;
  padding: 0.68rem 1.4rem; border-radius: 99px; border: none; cursor: pointer;
  text-decoration: none; transition: box-shadow 0.2s, transform 0.15s, opacity 0.2s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover:not(:disabled) { box-shadow: 0 0 22px var(--glow); transform: translateY(-2px); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid rgba(61,234,36,0.4); }
.btn-ghost:hover:not(:disabled) { background: rgba(61,234,36,0.1); border-color: var(--border-h); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(234,61,61,0.4); }
.btn-danger:hover:not(:disabled) { background: rgba(234,61,61,0.22); }
.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.68rem; }
.btn-wa { background: #25D366; color: #04170a; }
.btn-wa:hover { box-shadow: 0 0 18px rgba(37,211,102,0.5); }
.btn-block { width: 100%; }
.btn-icon { padding: 0.5rem; border-radius: 10px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: 14px; border: 1px solid rgba(255,255,255,0.06); }
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
thead th {
  background: rgba(61,234,36,0.06); color: var(--accent); text-align: left;
  padding: 0.7rem 0.8rem; font-family: var(--fh); font-size: 0.68rem; letter-spacing: 0.6px;
  text-transform: uppercase; white-space: nowrap; border-bottom: 1px solid var(--border);
}
tbody td { padding: 0.6rem 0.8rem; border-bottom: 1px solid rgba(255,255,255,0.05); vertical-align: middle; }
tbody tr:hover { background: rgba(61,234,36,0.03); }
tbody tr:last-child td { border-bottom: none; }
table input, table select { padding: 0.4rem 0.6rem; font-size: 0.8rem; min-width: 70px; }

/* ---------- Badges / pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 0.25rem 0.7rem;
  border-radius: 99px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-muted { background: rgba(255,255,255,0.06); color: var(--muted); }

select.cond-select { border: none; font-weight: 700; font-size: 0.72rem; text-transform: uppercase; border-radius: 99px; padding: 0.3rem 0.6rem; }
select.cond-select.aprobado { background: var(--ok-bg); color: var(--ok); }
select.cond-select.desaprobado { background: var(--danger-bg); color: var(--danger); }
select.cond-select.pendiente { background: var(--warn-bg); color: var(--warn); }

/* ---------- Stats ---------- */
.stat-box { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 1.2rem 1.4rem; }
.stat-box .n { font-family: var(--fh); font-size: 1.7rem; font-weight: 900; color: var(--accent); text-shadow: 0 0 14px rgba(61,234,36,0.35); }
.stat-box .l { font-size: 0.68rem; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; margin-top: 4px; }
.stat-box.neg .n { color: var(--danger); text-shadow: none; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; position: relative; z-index: 1; }
.login-card {
  width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--border);
  border-radius: 22px; padding: 2.4rem 2rem; box-shadow: 0 30px 80px rgba(0,0,0,0.6);
}
.login-card .logo { display: flex; justify-content: center; margin-bottom: 1.6rem; }
.login-card .logo img { max-height: 60px; }
.login-card h1 { font-family: var(--fh); font-size: 1.15rem; text-align: center; margin-bottom: 0.4rem; font-weight: 800; }
.login-card p.sub { text-align: center; color: var(--muted); font-size: 0.8rem; margin-bottom: 1.6rem; }
.login-error { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(234,61,61,0.35); border-radius: 10px; padding: 0.6rem 0.9rem; font-size: 0.78rem; margin-bottom: 1rem; display: none; }

/* ---------- Modal ---------- */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.82); backdrop-filter: blur(6px);
  z-index: 3000; align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: var(--card); border: 1px solid rgba(61,234,36,0.25); border-radius: 20px;
  width: 100%; max-width: 640px; max-height: 90vh; overflow-y: auto; padding: 1.8rem;
  box-shadow: 0 30px 80px rgba(0,0,0,0.7);
}
.modal-box.wide { max-width: 900px; }
.modal-close { position: absolute; top: 1.2rem; right: 1.4rem; background: none; border: none; color: var(--muted); font-size: 1.2rem; cursor: pointer; }
.modal-close:hover { color: var(--text); }

/* ---------- Toast ---------- */
#toast-wrap { position: fixed; top: 1.2rem; right: 1.2rem; z-index: 5000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--card); border: 1px solid var(--border-h); border-radius: 12px; padding: 0.8rem 1.1rem;
  font-size: 0.82rem; box-shadow: 0 10px 30px rgba(0,0,0,0.5); min-width: 240px;
  animation: toastIn 0.25s ease;
}
.toast.err { border-color: rgba(234,61,61,0.5); color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- Utility ---------- */
.muted { color: var(--muted); }
.mt-1 { margin-top: 0.6rem; } .mt-2 { margin-top: 1.2rem; } .mt-3 { margin-top: 2rem; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.flex-wrap { flex-wrap: wrap; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.small { font-size: 0.75rem; }
.tag-tipo { font-size: 0.68rem; padding: 0.2rem 0.55rem; border-radius: 6px; background: rgba(255,255,255,0.06); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 700; }
.tag-tipo.mano_obra { color: #7cc7ff; background: rgba(124,199,255,0.12); }
.tag-tipo.repuesto { color: var(--accent); background: rgba(61,234,36,0.12); }
.tag-tipo.insumo { color: #e2a6ff; background: rgba(226,166,255,0.12); }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state i { font-size: 2.4rem; color: var(--dim); margin-bottom: 0.8rem; display: block; }

.loading-spin { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(61,234,36,0.25); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Impresión (orden / informes) ---------- */
.print-sheet { max-width: 820px; margin: 0 auto; background: #fff; color: #111; border-radius: 4px; padding: 1.2rem 1.6rem; overflow-x: auto; }
.print-sheet, .print-sheet * { font-family: var(--fb); }
.print-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--accent); padding-bottom: 0.5rem; margin-bottom: 0.6rem; }
.print-head img { max-height: 34px; max-width: 140px; object-fit: contain; }
.print-head .doc-title { text-align: right; }
.print-head .doc-title h1 { font-family: var(--fh); font-size: 0.92rem; letter-spacing: 0.3px; color: #0a3d05; line-height: 1.2; }
.print-head .doc-title span { font-size: 0.66rem; color: #555; }
.print-sheet table { font-size: 0.76rem; border-collapse: collapse; width: 100%; }
.print-sheet thead th { background: #eaf9e6; color: #0a3d05; border-bottom: 1px solid var(--accent2); padding: 0.3rem 0.5rem; }
.print-sheet tbody td { border-bottom: 1px solid #e5e5e5; padding: 0.25rem 0.5rem; }
.print-sheet .doc-info-tabla td { padding: 0.15rem 0.5rem; font-size: 0.78rem; }
.fila-aprobado { background: #e6f9e0 !important; }
.fila-desaprobado { background: #fbe6e6 !important; }
.logo-preview-box { background: var(--bg2); border: 1px dashed rgba(255,255,255,0.15); border-radius: 10px; height: 70px; display: flex; align-items: center; justify-content: center; margin-bottom: 6px; overflow: hidden; }
.logo-preview-box img { max-height: 60px; max-width: 90%; object-fit: contain; }
.print-photo-slot {
  border: 2px dashed #ccc; border-radius: 12px; min-height: 200px; display: flex;
  align-items: center; justify-content: center; color: #999; font-size: 0.85rem; overflow: hidden;
}
.print-photo-slot img { width: 100%; height: 100%; object-fit: cover; }
.solo-print { display: none; }

@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .solo-print { display: table-cell !important; }
  .print-sheet { box-shadow: none; padding: 0; max-width: 100%; }
}

@media (max-width: 700px) {
  .topbar { padding: 0.6rem 1rem; }
  .topbar nav { order: 3; width: 100%; overflow-x: auto; gap: 0.2rem; }
  .topbar .brand img { max-height: 32px; }
  .main { padding: 1.2rem 1rem 3rem; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 0.8rem; }
  .page-head h1 { font-size: 1.35rem; }
  .modal-box { padding: 1.3rem; max-height: 85vh; }
  .login-card { padding: 1.8rem 1.4rem; }
  .card { padding: 1.1rem; }
  .btn { white-space: normal; }
  .stat-box .n { font-size: 1.35rem; }
  .print-sheet { padding: 1rem 0.9rem; }
  .doc-card { padding: 0.85rem; }
  table input, table select { min-width: 60px; }
  .input-with-btn { flex-wrap: wrap; }
  .input-with-btn input { min-width: 140px; }
}

@media (max-width: 480px) {
  .page-head h1 { font-size: 1.15rem; }
  .stat-box { padding: 0.9rem 1rem; }
  .stat-box .n { font-size: 1.2rem; }
  .userbox span#userbox-nombre { display: none; } /* en pantallas muy chicas se prioriza espacio; el botón de salir sigue visible */
  .modal-box { padding: 1rem; }
  .flex.flex-wrap > .btn { flex: 1 1 auto; }
}

@media (max-width: 900px) {
  .mano-obra-fila .flex-between { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .mano-obra-fila .flex-between > .flex { width: 100%; flex-wrap: wrap; }
  .repuesto-fila { margin-left: 0.6rem; }
}
