/* ================================================================
   main.css – Shared design tokens, base styles, and components
   for Cotizador Vibrocompactados (Joben).
   ================================================================ */

/* ── Design tokens ─────────────────────────────────────────────── */
:root {
  --bg: #f5f6f7;
  --card: #ffffff;
  --border: #e0e3e7;
  --text: #1f2933;
  --muted: #52606d;
  --primary: #0d6efd;
  --primary-hover: #0b5ed7;

  --success-bg: #e8f5e9;
  --success-fg: #2e7d32;
  --success-border: #4caf50;
  --error-bg: #fdecea;
  --error-fg: #c62828;
  --error-border: #d33;
  --warning-bg: #fff8e1;
  --warning-fg: #8d6e63;

  --radius: 10px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.05);
  --shadow: 0 2px 6px rgba(0,0,0,0.04);

  --navbar-bg: #0b1727;
  --navbar-height: 52px;

  --font: "Inter", system-ui, -apple-system, sans-serif;
}

/* ── Reset & base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 2px; }
img { max-width: 100%; height: auto; }

/* ── Navbar ────────────────────────────────────────────────────── */
.navbar {
  background: var(--navbar-bg);
  color: #fff;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--navbar-height);
  position: relative;
  z-index: 100;
}
.navbar a {
  color: #fff;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background 0.15s;
  white-space: nowrap;
}
.navbar a:hover {
  background: rgba(255,255,255,0.1);
  text-decoration: none;
}

.navbar__links {
  display: flex;
  align-items: center;
  gap: 2px;
  /* `overflow-x: auto` removed: implícitamente convertía overflow-y en auto
     y clipeaba los dropdowns posicionados con position: absolute. */
}

.navbar__right {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-left: 12px;
}

/* hamburger toggle – hidden on desktop */
.navbar__toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 8px;
  margin-left: -8px;
  border-radius: 6px;
  line-height: 1;
}
.navbar__toggle:hover { background: rgba(255,255,255,0.1); }
.navbar__toggle svg { display: block; }

/* mobile navbar */
@media (max-width: 768px) {
  .navbar { flex-wrap: wrap; padding: 0 16px; }
  .navbar__toggle { display: block; }

  .navbar__links {
    display: none;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    order: 3;
    padding: 8px 0 12px;
    gap: 0;
    overflow-x: visible;
  }
  .navbar__links.open { display: flex; }
  .navbar__links a {
    padding: 10px 12px;
    border-radius: 8px;
  }
  .navbar__links a:hover { background: rgba(255,255,255,0.08); }

  .navbar__brand {
    flex: 1;
    display: flex;
    align-items: center;
    min-height: var(--navbar-height);
  }
  .navbar__right { min-height: var(--navbar-height); }
}

/* ── Nav dropdowns ─────────────────────────────────────────────── */
.nav-group {
  position: relative;
  display: inline-block;
}
.nav-group__btn {
  background: transparent;
  border: 0;
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s;
  white-space: nowrap;
}
.nav-group__btn:hover,
.nav-group__btn[aria-expanded="true"] {
  background: rgba(255,255,255,0.10);
}
.nav-group--active > .nav-group__btn {
  background: rgba(255,255,255,0.18);
  box-shadow: inset 0 -2px 0 var(--primary);
}
.nav-group__caret {
  font-size: 0.65em;
  opacity: 0.75;
  margin-left: 2px;
}
.nav-group__menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  padding: 4px 0;
  z-index: 200;
  margin-top: 4px;
}
.nav-group:hover > .nav-group__menu,
.nav-group__btn[aria-expanded="true"] + .nav-group__menu {
  display: block;
}
.nav-group__menu a {
  display: block;
  padding: 8px 14px;
  color: var(--text);
  font-weight: 500;
  font-size: 0.875rem;
  white-space: nowrap;
  border-radius: 0;
}
.nav-group__menu a:hover {
  background: rgba(0,0,0,0.05);
  color: var(--text);
  text-decoration: none;
}

/* Direct link in navbar (Admin) — same active treatment */
.navbar__link--active {
  background: rgba(255,255,255,0.18);
  box-shadow: inset 0 -2px 0 var(--primary);
}

@media (max-width: 768px) {
  /* Dropdowns colapsan inline dentro del menú hamburguesa */
  .nav-group { display: block; width: 100%; }
  .nav-group__btn {
    display: flex;
    width: 100%;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 8px;
  }
  .nav-group--active > .nav-group__btn { box-shadow: none; }
  .nav-group__menu {
    position: static;
    min-width: 0;
    box-shadow: none;
    border: 0;
    background: transparent;
    margin: 0 0 4px 0;
    padding: 0 0 4px 18px;
  }
  /* En móvil sólo se abre con click (aria-expanded) — desactivamos hover */
  .nav-group:hover > .nav-group__menu { display: none; }
  .nav-group__btn[aria-expanded="true"] + .nav-group__menu { display: block; }
  .nav-group__menu a {
    color: #fff;
    padding: 8px 10px;
    border-radius: 6px;
  }
  .nav-group__menu a:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
  }
}

/* ── Layout containers ─────────────────────────────────────────── */
.container {
  max-width: 1080px;
  margin: 24px auto;
  padding: 0 20px;
}
.page-wrapper {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px 40px;
}

/* ── Card ──────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--primary);
  color: #fff;
  background: var(--primary);
  cursor: pointer;
  font-weight: 600;
  font-size: inherit;
  font-family: inherit;
  line-height: 1.25;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  text-decoration: none;
}
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:disabled, .btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn.secondary { background: transparent; color: var(--primary); }
.btn.secondary:hover { background: rgba(13,110,253,0.06); }
.btn.plain { background: transparent; color: var(--text); border-color: var(--border); }
.btn.plain:hover { background: rgba(0,0,0,0.04); }
.btn.danger { background: var(--error-fg); border-color: var(--error-fg); }
.btn.danger:hover { opacity: 0.85; }
.btn.btn-link {
  background: none;
  border: none;
  color: #fff;
  padding: 6px 10px;
  font-size: 0.875rem;
  border-radius: 6px;
}
.btn.btn-link:hover { background: rgba(255,255,255,0.1); text-decoration: none; }

/* ── Tables ────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.table th, .table td { padding: 10px; border-bottom: 1px solid var(--border); text-align: left; }
.table th { font-weight: 600; }

@media (max-width: 600px) {
  .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ── Status pills / badges ─────────────────────────────────────── */
.status-pill, .badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}
.status-pill.ok, .badge.ok { background: var(--success-bg); color: var(--success-fg); }
.status-pill.error, .badge.error { background: var(--error-bg); color: var(--error-fg); }
.status-pill.warn, .badge.warn { background: var(--warning-bg); color: var(--warning-fg); }
.badge.muted { background: #eceff1; color: #455a64; }

/* ── Messages / alerts ─────────────────────────────────────────── */
.messages {
  margin-bottom: 16px;
  display: grid;
  gap: 8px;
  list-style: none;
  padding: 0;
}
.messages li, .alert {
  padding: 10px 12px;
  border-radius: var(--radius);
  font-weight: 600;
}
.messages .error, .alert.error {
  background: var(--error-bg);
  color: var(--error-fg);
  border: 1px solid var(--error-border);
}
.messages .success, .alert.success {
  background: var(--success-bg);
  color: var(--success-fg);
  border: 1px solid var(--success-border);
}
.messages .warning, .alert.warning {
  background: var(--warning-bg);
  color: var(--warning-fg);
}

/* ── Form controls ─────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.form-grid .full { grid-column: 1 / -1; }

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: inherit;
}
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(13,110,253,0.15);
}

.field-error input,
.field-error select,
.field-error textarea {
  border-color: var(--error-border);
  box-shadow: 0 0 0 1px rgba(211,51,51,0.2);
}
.errorlist {
  color: var(--error-fg);
  font-weight: 600;
  margin: 6px 0 0 0;
  padding-left: 18px;
}

/* ── Binary choice (radio/checkbox groups) ─────────────────────── */
.binary-choice {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}
.binary-option {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f8fafc;
}
.binary-option input { margin: 0; }

/* ── Step cards (request capture) ──────────────────────────────── */
.steps { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }
.step-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--step-accent, var(--primary));
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.step-card:focus-within {
  box-shadow: 0 4px 14px rgba(13, 110, 253, 0.08);
}
.step-card--one   { --step-accent: #3b82f6; }  /* blue   */
.step-card--two   { --step-accent: #6366f1; }  /* indigo */
.step-card--three { --step-accent: #14b8a6; }  /* teal   */
.step-card--four  { --step-accent: #f59e0b; }  /* amber  */
.step-title {
  margin: 0 0 12px 0;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.step-title__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--step-accent, var(--primary)) 14%, white);
  color: var(--step-accent, var(--primary));
  flex-shrink: 0;
}
.step-title__icon svg { width: 16px; height: 16px; }

/* ── Progress stepper (top of request capture) ─────────────────── */
.stepper {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 18px 0 22px 0;
  padding: 0;
  list-style: none;
  flex-wrap: wrap;
}
.stepper__item {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 140px;
  min-width: 0;
}
.stepper__item + .stepper__item::before {
  content: "";
  flex: 0 0 24px;
  height: 2px;
  background: var(--border);
  margin: 0 4px;
  border-radius: 2px;
  transition: background 0.25s ease;
}
.stepper__circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--border);
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.stepper__label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stepper__item.is-active .stepper__circle {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.12);
}
.stepper__item.is-active .stepper__label {
  color: var(--text);
}
.stepper__item.is-complete .stepper__circle {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
}
.stepper__item.is-complete .stepper__label {
  color: #16a34a;
}
.stepper__item.is-complete + .stepper__item::before,
.stepper__item.is-active + .stepper__item::before { background: var(--primary); }

@media (max-width: 700px) {
  .stepper { gap: 4px; }
  .stepper__item { flex: 1 1 0; gap: 4px; }
  .stepper__label { display: none; }
  .stepper__item + .stepper__item::before { flex: 1 1 auto; margin: 0 2px; }
}

/* ── Choice cards (large radio buttons) ────────────────────────── */
.choice-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.choice-card {
  position: relative;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.choice-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.choice-card__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #f1f5f9;
  color: var(--muted);
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.choice-card__icon svg { width: 18px; height: 18px; }
.choice-card__title { font-weight: 600; color: var(--text); display: block; }
.choice-card__subtitle { font-size: 13px; color: var(--muted); display: block; margin-top: 2px; }
.choice-card:hover { border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); }
.choice-card.is-selected {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 6%, white);
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.08);
}
.choice-card.is-selected .choice-card__icon {
  background: var(--primary);
  color: #fff;
}
.choice-card:focus-within {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.18);
}

/* ── Sticky submit bar ─────────────────────────────────────────── */
.submit-bar {
  position: sticky;
  bottom: 0;
  margin-top: 20px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  z-index: 10;
}
.submit-bar__summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 14px;
  color: var(--muted);
  min-width: 0;
}
.submit-bar__summary strong { color: var(--text); font-weight: 600; }
.submit-bar__summary span::before { content: "·"; margin-right: 10px; color: var(--border); }
.submit-bar__summary span:first-child::before { content: none; margin-right: 0; }
.submit-bar .btn { padding: 12px 22px; font-size: 15px; }

/* ── Product picker cards (request capture forms) ──────────────── */
.item-form-card {
  background: #ffffff;
  padding: 16px 18px 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.item-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--border);
}
.item-card__number {
  font-weight: 700;
  font-size: 13px;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.item-card__badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.item-card__primary,
.item-card__secondary {
  display: grid;
  gap: 12px;
  align-items: end;
}
.item-card__primary--bloc    { grid-template-columns: 1fr 2fr; }
.item-card__primary--pbq     { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.item-card__secondary        { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.item-card__secondary--bloc  { grid-template-columns: 0.9fr 0.7fr 1fr 1fr; }
.item-card__secondary--pbq   { grid-template-columns: 0.9fr 1fr 1fr; }
.item-form-card .field label { font-weight: 600; font-size: 13px; }
.item-form-card .field select,
.item-form-card .field input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: inherit;
}
.item-form-card .field select:focus,
.item-form-card .field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(13,110,253,0.15);
}
.item-card__hint {
  font-size: 13px;
  color: #1e3a8a;
  background: color-mix(in srgb, var(--primary) 8%, white);
  border-left: 3px solid var(--primary);
  padding: 9px 12px;
  border-radius: 8px;
  line-height: 1.35;
}
.item-card__hint:empty { display: none; }
.item-card__hint[hidden] { display: none; }
.item-card__empty {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 8px 12px;
  background: #fffaeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  color: #8a5d00;
  font-size: 13px;
}
.item-card__empty::before {
  content: "";
  flex: 0 0 14px;
  width: 14px; height: 14px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238a5d00' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='10'/><line x1='12' y1='8' x2='12' y2='12'/><line x1='12' y1='16' x2='12.01' y2='16'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
}
@media (max-width: 900px) {
  .item-card__primary--bloc,
  .item-card__primary--pbq,
  .item-card__secondary--bloc,
  .item-card__secondary--pbq { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}

/* ── Business-line badge (BLOC / PBQ) ──────────────────────────── */
.bl-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  vertical-align: middle;
  margin-left: 10px;
}
.bl-badge--bloc { background: #1e4f91; }
.bl-badge--pbq  { background: #0d9488; }

.hero__subtitle {
  color: var(--muted);
  font-size: 14px;
  margin: 6px auto 0 auto;
  max-width: 460px;
}

/* ── Hero (public pages) ───────────────────────────────────────── */
.hero { text-align: center; margin-bottom: 20px; }
.hero-logo { display: block; max-width: min(220px, 60vw); width: 100%; height: auto; margin: 0 auto 12px; }
.hero h1 { margin: 0; font-size: 28px; }
.hero p { margin: 8px 0 0 0; color: var(--muted); }

/* ── Layout helpers ────────────────────────────────────────────── */
.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: 1fr 1fr; }
.grid--sidebar { grid-template-columns: 1.2fr 0.8fr; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.metric { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.metric .card { padding: 14px; }
.actions { display: flex; gap: 10px; margin-top: 12px; }
.muted { color: var(--muted); }
.hidden { display: none; }
.intro-text { margin-top: 6px; color: var(--muted); }

/* ── Code / pre ────────────────────────────────────────────────── */
pre {
  background: var(--navbar-bg);
  color: #e8edf3;
  padding: 12px;
  border-radius: var(--radius);
  overflow-x: auto;
}

/* ── Footer (public) ───────────────────────────────────────────── */
footer { margin-top: 32px; text-align: center; color: var(--muted); font-size: 14px; }

/* ── Responsive breakpoints ────────────────────────────────────── */
@media (max-width: 900px) {
  .grid--2, .grid--sidebar, .metric { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .step-card { padding: 14px; }
  .container { padding: 0 16px; margin: 16px auto; }
}
