/* ═══════════════════════════════════════════════════════════
   ADDD.HOC Cotizador — Styles
   Dark-themed, mobile-first
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #242424;
  --border: #333;
  --text: #e8e8e8;
  --text-dim: #999;
  --accent: #f97316;
  --accent-dim: #c2410c;
  --green: #22c55e;
  --blue: #3b82f6;
  --radius: 10px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

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

/* ── Navbar ── */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: #ffffff;
}
.nav-links { display: flex; gap: 0.3rem; }
.nav-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-dim);
  padding: 0.45rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.nav-btn:hover { color: var(--text); background: var(--surface2); }
.nav-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(249,115,22,0.08);
}

/* ── Container ── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ── Views ── */
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

h1 { font-size: 1.5rem; margin-bottom: 1.2rem; font-weight: 700; }
h2 { font-size: 1.1rem; margin-bottom: 1rem; color: var(--text-dim); font-weight: 600; }
h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); margin: 1.2rem 0 0.6rem; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.card-results { background: var(--surface2); }

/* ── Calculator Grid ── */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 768px) {
  .calc-grid { grid-template-columns: 1fr; }
}

/* ── Fields ── */
.field { margin-bottom: 0.8rem; }
.field label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
}
.field-row {
  display: flex;
  gap: 0.8rem;
}
.field-row .field { flex: 1; }

input, textarea, select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font);
  transition: border-color 0.2s;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
input[type=number] { -moz-appearance: textfield; }

/* ── Input with select (time unit) ── */
.input-with-select {
  display: flex;
  gap: 0;
}
.input-with-select input {
  border-radius: 6px 0 0 6px;
  border-right: none;
  flex: 1;
}
.input-with-select select {
  width: 65px;
  border-radius: 0 6px 6px 0;
  background: var(--surface2);
  cursor: pointer;
  flex-shrink: 0;
}
.input-with-select select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Material row ── */
.material-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  align-items: end;
}
.material-row .field { margin-bottom: 0; }
.material-row .btn-remove {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.4rem;
  flex-shrink: 0;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.btn:hover { border-color: var(--text-dim); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-dim); }
.btn-block { width: 100%; justify-content: center; margin-top: 1rem; }

/* ── Results ── */
.result-section { margin-bottom: 1.2rem; }
.result-line {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.result-line.total {
  font-weight: 700;
  font-size: 1rem;
  border-bottom: none;
  padding-top: 0.6rem;
  color: var(--accent);
}

/* ── Price cards ── */
.price-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.7rem;
}
.price-card .label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
}
.price-card .price {
  display: block;
  font-size: 1.6rem;
  font-weight: 800;
  margin: 0.2rem 0;
}
.price-card .sub { font-size: 0.8rem; color: var(--green); }
.price-card.menudeo .price { color: var(--accent); }
.price-card.mayoreo .price { color: var(--blue); }

/* ── Margin bar ── */
.margin-bar {
  height: 6px;
  background: var(--surface);
  border-radius: 3px;
  margin-top: 0.5rem;
  overflow: hidden;
}
.margin-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
  width: 0%;
}
.menudeo .margin-fill { background: var(--accent); }
.mayoreo .margin-fill { background: var(--blue); }

/* ── Total display ── */
.total-display {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  padding: 0.4rem 0;
}

/* ── Search ── */
.search-bar {
  margin-bottom: 1rem;
}
.search-bar input {
  max-width: 400px;
}

/* ── History list ── */
.history-list { display: flex; flex-direction: column; gap: 0.6rem; }
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  transition: border-color 0.2s;
}
.history-item:hover { border-color: var(--accent); }
.history-meta { flex: 1; }
.history-meta .folio {
  font-weight: 700;
  color: var(--accent);
  font-size: 0.9rem;
}
.history-meta .cliente {
  font-size: 0.95rem;
}
.history-meta .date {
  font-size: 0.78rem;
  color: var(--text-dim);
}
.history-total {
  font-weight: 700;
  font-size: 1.1rem;
  margin-right: 1rem;
  white-space: nowrap;
}
.history-actions { display: flex; gap: 0.4rem; }
.history-ganancia {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--green);
  font-weight: 600;
  margin-left: 0.3rem;
}

.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 3rem 1rem;
  font-size: 0.95rem;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--green);
  color: #fff;
  padding: 0.7rem 1.5rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  transition: bottom 0.3s ease;
  z-index: 999;
}
.toast.show { bottom: 2rem; }

/* ── Quote items (multi-product) ── */
.quote-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  margin-bottom: 0.6rem;
}
.quote-item .field-row {
  align-items: end;
}
.quote-item .qi-remove {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  flex-shrink: 0;
  align-self: center;
}
.subtotal-display {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  padding: 0.55rem 0;
}

/* ── Profit summary (private, screen only) ── */
.profit-summary {
  background: linear-gradient(135deg, #1a2e1a, #1a1a1a);
  border: 1px solid #22c55e33;
  border-radius: 8px;
  padding: 0.9rem 1rem;
  margin-top: 1rem;
}
.profit-line {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  font-size: 0.9rem;
  color: var(--text-dim);
}
.profit-line.ganancia {
  font-weight: 700;
  font-size: 1rem;
  color: var(--green);
  border-top: 1px solid #22c55e33;
  padding-top: 0.5rem;
  margin-top: 0.2rem;
}

/* ── Responsive tweaks ── */
@media (max-width: 600px) {
  .navbar { flex-direction: column; gap: 0.5rem; }
  .field-row { flex-direction: column; gap: 0; }
  .history-item { flex-direction: column; align-items: flex-start; gap: 0.6rem; }
  .history-actions { width: 100%; }
  .history-actions .btn { flex: 1; justify-content: center; }
}
