/* ==========================================================================
   Design tokens -- tema claro por defecto, overrides bajo [data-bs-theme=dark]
   ========================================================================== */
:root {
  --brand: #0a3d91;
  --brand-2: #008ecf;
  --brand-soft: rgba(10, 61, 145, 0.1);
  --accent: #ff9f1c;
  --success: #0b7f68;
  --success-soft: rgba(0, 179, 143, 0.12);
  --warning: #a35d00;
  --warning-soft: rgba(255, 159, 28, 0.14);
  --danger: #b42318;
  --danger-soft: rgba(202, 52, 51, 0.12);

  --bg: #f0f4fb;
  --surface: #ffffff;
  --surface-2: #f7fafe;
  --border: #dbe4f1;
  --text: #102a43;
  --text-muted: #5c7390;
  --shadow-sm: 0 6px 18px rgba(16, 42, 67, 0.06);
  --shadow-md: 0 16px 32px rgba(16, 42, 67, 0.12);

  --sidebar-bg: linear-gradient(190deg, #0a2a63 0%, #0a3d91 55%, #0b4f96 100%);
  --sidebar-text: rgba(255, 255, 255, 0.82);
  --sidebar-text-strong: #ffffff;
  --sidebar-active-bg: rgba(255, 255, 255, 0.16);
  --sidebar-hover-bg: rgba(255, 255, 255, 0.08);
  --sidebar-border: rgba(255, 255, 255, 0.14);
}

:root[data-bs-theme="dark"] {
  --bg: #0b1220;
  --surface: #121a2c;
  --surface-2: #17213a;
  --border: #263349;
  --text: #e7edf7;
  --text-muted: #93a3bd;
  --brand-soft: rgba(76, 141, 255, 0.16);
  --success-soft: rgba(16, 185, 129, 0.16);
  --warning-soft: rgba(251, 191, 36, 0.16);
  --danger-soft: rgba(239, 68, 68, 0.18);
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 16px 34px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   Base
   ========================================================================== */
* { scrollbar-color: rgba(54, 91, 135, 0.35) transparent; }

body {
  font-family: 'Space Grotesk', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 0.95rem;
  transition: background-color .2s ease, color .2s ease;
}

a { color: var(--brand-2); }
:root[data-bs-theme="dark"] a { color: #7db8ff; }

.fade-in { animation: fadeInUp 0.5s ease both; }
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   App shell: sidebar + topbar + content
   ========================================================================== */
.app-shell {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

.app-sidebar {
  width: 264px;
  flex: 0 0 264px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 1.15rem 1rem 1.5rem;
  display: flex;
  flex-direction: column;
}

@media (max-width: 991.98px) {
  .app-sidebar { display: none; }
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  color: var(--sidebar-text-strong);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.02rem;
  padding: .35rem .3rem 1.1rem;
  border-bottom: 1px solid var(--sidebar-border);
  margin-bottom: 1rem;
  line-height: 1.15;
}

.sidebar-brand-sub {
  display: block;
  font-size: .68rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
  letter-spacing: .03em;
}

.sidebar-brand .brand-badge {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: .65rem;
  background: rgba(255, 255, 255, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
}

.sidebar-nav { list-style: none; margin: 0; padding: 0; display: grid; gap: .15rem; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem .7rem;
  border-radius: .65rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 600;
  font-size: .86rem;
  transition: background-color .15s ease, color .15s ease;
}

.sidebar-link i { font-size: 1rem; width: 1.15rem; text-align: center; flex-shrink: 0; }

.sidebar-link:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-text-strong); }

.sidebar-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-strong);
  box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar-section-label {
  font-size: .66rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255, 255, 255, 0.45);
  margin: 1.1rem 0 .35rem .7rem;
  font-weight: 700;
}

.sidebar-subnav {
  display: grid;
  gap: .1rem;
  margin: 0 0 0 1.05rem;
  padding-left: .6rem;
  border-left: 1px solid var(--sidebar-border);
}

.sidebar-subnav .sidebar-link { font-size: .81rem; padding: .42rem .6rem; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--sidebar-border);
  font-size: .74rem;
  color: rgba(255, 255, 255, 0.55);
}

/* Offcanvas (mobile sidebar) reuses the same visual language */
.offcanvas.app-offcanvas {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  width: 280px;
}
.offcanvas.app-offcanvas .btn-close { filter: invert(1) grayscale(1) brightness(2); }

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: .7rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.topbar-title { font-weight: 700; font-size: 1.02rem; display: flex; align-items: center; gap: .5rem; }
.topbar-title .text-muted { font-weight: 500; }

.icon-btn {
  width: 2.3rem;
  height: 2.3rem;
  border-radius: .65rem;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all .15s ease;
}
.icon-btn:hover { border-color: var(--brand-2); color: var(--brand-2); }

.app-content {
  padding: 1.1rem 1.25rem 2rem;
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
}

/* ==========================================================================
   Cards / surfaces (custom, layered on top of Bootstrap's card)
   ========================================================================== */
.glass-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: var(--shadow-sm);
}

.card { border-radius: .9rem; background: var(--surface); border-color: var(--border); color: var(--text); }
.card .card-body { padding: 1rem; }

.hero {
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  color: #fff;
  border-radius: 1rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, 0.12); }
.hero::before { width: 220px; height: 220px; left: -80px; bottom: -100px; }
.hero::after { width: 340px; height: 340px; right: -90px; top: -120px; }
.hero h1 { font-size: clamp(1.3rem, 2.2vw, 1.8rem); margin-bottom: .4rem; }
.hero p { line-height: 1.35; position: relative; }

.hero-kicker {
  display: inline-flex;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  padding: .3rem .65rem;
  font-size: .8rem;
  letter-spacing: .03em;
  margin-bottom: .65rem;
  background: rgba(255, 255, 255, 0.12);
  position: relative;
}

.hero-metrics { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .8rem; position: relative; }
.hero-metric { border: 1px solid rgba(255, 255, 255, 0.35); background: rgba(255, 255, 255, 0.12); padding: .28rem .6rem; border-radius: 999px; font-size: .76rem; font-weight: 600; display: inline-flex; align-items: center; gap: .35rem; }

.empty-state {
  border: 1px dashed var(--border);
  border-radius: .9rem;
  padding: 1.4rem 1.2rem;
  background: var(--surface-2);
  text-align: center;
}
.empty-state .empty-icon { font-size: 1.9rem; color: var(--brand-2); margin-bottom: .5rem; }
.empty-state h2 { font-size: 1rem; margin-bottom: .35rem; }
.empty-state p { font-size: .86rem; color: var(--text-muted); margin-bottom: 0; }

/* ==========================================================================
   Stepper (wizard)
   ========================================================================== */
.stepper { display: flex; align-items: stretch; gap: .6rem; margin-bottom: 1.1rem; }

.stepper-step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem .8rem;
  border-radius: .8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: default;
  opacity: .6;
  transition: all .15s ease;
}

.stepper-step.is-reachable { cursor: pointer; opacity: 1; }
.stepper-step.is-reachable:hover { border-color: var(--brand-2); }

.stepper-index {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 2px solid var(--border);
  flex-shrink: 0;
}

.stepper-step.active { opacity: 1; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.stepper-step.active .stepper-index { background: var(--brand); color: #fff; border-color: var(--brand); }
.stepper-step.done { opacity: 1; }
.stepper-step.done .stepper-index { background: var(--success); color: #fff; border-color: var(--success); }
.stepper-step .stepper-index i { font-size: .95rem; }

.stepper-label { font-weight: 700; font-size: .84rem; color: var(--text); display: block; line-height: 1.15; }
.stepper-sub { font-size: .71rem; color: var(--text-muted); }

@media (max-width: 767.98px) {
  .stepper { flex-direction: column; }
  .stepper-sub { display: none; }
}

.wizard-step { display: none; }
.wizard-step.active { display: block; }

.wizard-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

/* ==========================================================================
   Feature browser (category pills + search + grid)
   ========================================================================== */
.category-pills { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .65rem; }

.category-pill {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: .74rem;
  font-weight: 700;
  padding: .32rem .7rem;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  transition: all .15s ease;
}
.category-pill:hover { border-color: var(--brand-2); color: var(--brand-2); }
.category-pill.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.category-pill .pill-count { opacity: .75; margin-left: .3rem; }

.selected-chip-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
  padding: .55rem .6rem;
  border: 1px dashed var(--border);
  border-radius: .75rem;
  margin-bottom: .75rem;
  min-height: 2.5rem;
  background: var(--surface-2);
}
.selected-chip-bar .chip-bar-hint { font-size: .78rem; color: var(--text-muted); }

.selected-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: var(--surface);
  border: 1px solid var(--brand-2);
  color: var(--brand);
  border-radius: 999px;
  padding: .22rem .3rem .22rem .62rem;
  font-size: .72rem;
  font-weight: 700;
}
:root[data-bs-theme="dark"] .selected-chip { color: #cfe3ff; }

.selected-chip button {
  border: 0;
  background: rgba(10, 61, 145, 0.12);
  color: inherit;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .68rem;
  line-height: 1;
}

.feature-grid {
  display: grid;
  gap: .7rem;
  max-height: 56vh;
  overflow: auto;
  padding-right: .2rem;
}
.feature-grid::-webkit-scrollbar { width: 8px; }
.feature-grid::-webkit-scrollbar-thumb { background: rgba(54, 91, 135, 0.28); border-radius: 999px; }

.feature-group {
  border: 1px solid var(--border);
  border-radius: .8rem;
  padding: .7rem;
  background: var(--surface-2);
}

.feature-group-title {
  font-size: .82rem;
  font-weight: 700;
  color: var(--brand-2);
  letter-spacing: .02em;
  margin-bottom: .55rem;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: .4rem;
}

.feature-cards { display: grid; gap: .55rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.feature-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .7rem;
  padding: .6rem .65rem;
  transition: all .15s ease;
  min-height: 100%;
}
.feature-item:hover { border-color: var(--brand-2); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.feature-item.is-selected { border-color: var(--brand); background: var(--brand-soft); }

.feature-summary {
  font-size: .76rem;
  color: var(--text-muted);
  margin: .35rem 0 0;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.priority-row { display: flex; align-items: center; justify-content: space-between; gap: .45rem; margin-top: .45rem; }
.priority-row label { font-size: .66rem; text-transform: uppercase; color: var(--text-muted); letter-spacing: .03em; font-weight: 700; }
.priority-select { width: 112px; font-size: .72rem; padding-top: .2rem; padding-bottom: .2rem; }

.feature-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .55rem; }
.feature-toolbar .form-control { flex: 1 1 260px; }

.selection-pill {
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
  font-size: .74rem;
  padding: .35rem .65rem;
  align-self: center;
  white-space: nowrap;
}
:root[data-bs-theme="dark"] .selection-pill { color: #cfe3ff; }

/* ==========================================================================
   Buttons / chips / badges
   ========================================================================== */
.btn { border-radius: .65rem; font-weight: 600; }
.btn-sm { padding: .3rem .58rem; font-size: .78rem; }
.btn-lg { padding: .68rem 1.2rem; font-size: .92rem; border-radius: .8rem; }
.btn.disabled, .btn:disabled { pointer-events: none; opacity: .5; }

.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover { background: #082f6e; border-color: #082f6e; }
.btn-outline-primary { color: var(--brand); border-color: var(--brand); }
:root[data-bs-theme="dark"] .btn-outline-primary { color: #7db8ff; border-color: #7db8ff; }

.result-highlight { border-left: 6px solid var(--accent); background: var(--surface); }

.price-chip {
  font-size: .85rem;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  padding: .25rem .7rem;
  display: inline-block;
  font-weight: 700;
}
:root[data-bs-theme="dark"] .price-chip { color: #cfe3ff; }

.table { color: var(--text); }
.table thead th { background: var(--surface-2); font-size: .78rem; white-space: nowrap; padding: .55rem .6rem; border-color: var(--border); }
.table td { font-size: .82rem; padding: .48rem .6rem; border-color: var(--border); }
.table > :not(caption) > * > * { background: transparent; }

.sticky-col { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 10px 0 18px rgba(16, 42, 67, 0.05); }
.table thead .sticky-col { z-index: 2; background: var(--surface-2); }

.coverage-badge { display: inline-flex; align-items: center; gap: .28rem; border-radius: 999px; padding: .2rem .5rem; font-size: .72rem; font-weight: 700; }
.coverage-high { background: var(--success-soft); color: var(--success); }
.coverage-mid { background: var(--warning-soft); color: var(--warning); }
.coverage-low { background: var(--danger-soft); color: var(--danger); }

.metric-tile-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .55rem; margin: .8rem 0; }
.metric-tile { border: 1px solid var(--border); border-radius: .8rem; background: var(--surface-2); padding: .65rem .75rem; }
.metric-tile-label { display: block; font-size: .7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: .18rem; }
.metric-tile-value { font-size: 1rem; font-weight: 700; color: var(--brand); }
:root[data-bs-theme="dark"] .metric-tile-value { color: #cfe3ff; }

.stack-list { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .35rem; }
.stack-chip { display: inline-flex; align-items: center; border-radius: 999px; padding: .18rem .5rem; font-size: .7rem; font-weight: 700; background: var(--brand-soft); color: var(--brand); }
:root[data-bs-theme="dark"] .stack-chip { color: #cfe3ff; }
.stack-chip.miss { background: var(--danger-soft); color: var(--danger); }

.product-title { font-weight: 700; color: var(--text); }
.product-subtle { color: var(--text-muted); font-size: .74rem; margin-top: .15rem; }

.modal-content { background: var(--surface); color: var(--text); }
.modal-feature-list li { margin-bottom: .35rem; }

.info-btn { white-space: nowrap; font-size: .71rem; padding: .12rem .46rem; }

.form-check-label { font-size: .84rem; line-height: 1.2; }
.form-control, .form-select { background: var(--surface); color: var(--text); border-color: var(--border); }
.form-control:focus, .form-select:focus { border-color: var(--brand-2); box-shadow: 0 0 0 .2rem var(--brand-soft); }

.alert { margin-bottom: 0; padding: .55rem .75rem; }

/* ==========================================================================
   Quote builder / proposal panel
   ========================================================================== */
.proposal-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .55rem; margin-bottom: .8rem; }
.proposal-note { font-size: .74rem; color: var(--text-muted); margin-top: .25rem; }

.export-actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.export-btn { display: inline-flex; align-items: center; gap: .55rem; font-size: .86rem; }
.export-btn i { font-size: 1.05rem; }

.cta-panel {
  border: 1px solid var(--success);
  background: var(--success-soft);
  border-radius: .9rem;
  padding: .9rem 1.1rem;
}

/* ==========================================================================
   Admin quick-link cards
   ========================================================================== */
.admin-quick-link {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: 1rem;
  border-radius: .9rem;
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
  transition: all .15s ease;
  height: 100%;
}
.admin-quick-link:hover { border-color: var(--brand-2); box-shadow: var(--shadow-sm); transform: translateY(-2px); color: var(--text); }
.admin-quick-link .quick-link-icon {
  width: 2.7rem;
  height: 2.7rem;
  border-radius: .75rem;
  background: var(--brand-soft);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}
:root[data-bs-theme="dark"] .admin-quick-link .quick-link-icon { color: #cfe3ff; }
.admin-quick-link .quick-link-title { font-weight: 700; font-size: .92rem; }
.admin-quick-link .quick-link-desc { font-size: .76rem; color: var(--text-muted); }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 767.98px) {
  .app-content { padding: .9rem .9rem 1.6rem; }
  .feature-grid { max-height: none; overflow: visible; }
  .hero { border-radius: .85rem; }
  .feature-cards { grid-template-columns: 1fr; }
  .proposal-grid { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 992px) {
  .border-start-lg { border-left: 1px solid var(--border); }
}

/* ==========================================================================
   Accesibilidad de teclado: skip link + foco visible en controles custom
   ========================================================================== */
.skip-link {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2000;
  padding: .65rem 1.1rem;
  background: var(--brand);
  color: #fff;
  border-radius: 0 0 .6rem 0;
  font-weight: 700;
  text-decoration: none;
}

.category-pill:focus-visible,
.icon-btn:focus-visible,
.selected-chip button:focus-visible,
.info-btn:focus-visible {
  outline: 2px solid var(--brand-2);
  outline-offset: 2px;
}

.stepper-step:focus-visible {
  outline: 2px solid var(--brand-2);
  outline-offset: 2px;
}

.sidebar-link:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -2px;
}

/* Los pasos del stepper ahora son <button>; se resetean estilos nativos que
   no aplicaban cuando eran <div>. */
button.stepper-step {
  text-align: left;
  font: inherit;
  width: 100%;
}
button.stepper-step:disabled { cursor: default; }
