/* ==========================================================================
   Calculadora de franquicias aduaneras y compras de viaje sin impuestos
   Estilos corporativos y semáforo aduanero interactivo
   ========================================================================== */

:root {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Paleta cromática corporativa (Tema claro) */
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-input: #ffffff;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;

  --success: #16a34a;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;

  --warning: #d97706;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;

  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
  --bg-page: #090d16;
  --bg-card: #111827;
  --bg-card-subtle: #1f2937;
  --bg-input: #1a2234;
  --border-color: #273549;
  --border-focus: #60a5fa;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: #1e293b;

  --success: #22c55e;
  --success-bg: #052e16;
  --success-border: #14532d;

  --warning: #f59e0b;
  --warning-bg: #451a03;
  --warning-border: #78350f;

  --danger: #ef4444;
  --danger-bg: #450a0a;
  --danger-border: #7f1d1d;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
}

/* Base obligatoria */
body {
  font-family: var(--font-main);
  background-color: var(--bg-page);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6,
.brand-title,
.section-title,
.card-title {
  font-family: var(--font-heading);
}

.text-mono,
.font-mono {
  font-family: var(--font-mono);
}

.font-bold {
  font-weight: 700;
}

.text-right {
  text-align: right;
}

.text-success {
  color: var(--success);
}

.text-warning {
  color: var(--warning);
}

.text-danger {
  color: var(--danger);
}

/* Layout canónico */
.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  box-sizing: border-box;
  flex: 1 0 auto;
}

.tool-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  width: 100%;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
}

/* Cabecera de la herramienta */
.tool-hero-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.hero-header-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.tool-hero-title {
  font-size: 1.6rem;
  line-height: 1.25;
  margin: 0 0 0.5rem 0;
  color: var(--text-primary);
}

.tool-hero-subtitle {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-secondary);
  margin: 0;
}

/* Escenarios rápidos */
.scenarios-toolbar {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border-color);
}

.scenarios-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.scenarios-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-scenario-load {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-md);
  background: var(--bg-card-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 38px;
}

.btn-scenario-load:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

/* Grid principal de la herramienta */
.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 900px) {
  .tool-grid {
    grid-template-columns: 1fr;
  }
}

/* Tarjetas */
.card-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.card-panel-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Controles de formulario */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.form-select,
.form-input {
  width: 100%;
  min-height: 42px;
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  font-family: var(--font-main);
  background-color: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

.form-select:focus,
.form-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.travelers-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

@media (max-width: 600px) {
  .travelers-row {
    grid-template-columns: 1fr;
  }
}

/* SEMÁFORO ADUANERO BIOMECÁNICO */
.traffic-light-card {
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: all 0.3s ease;
}

.traffic-light-card.status-green {
  border-color: var(--success);
  background: linear-gradient(180deg, var(--success-bg) 0%, var(--bg-card) 60%);
}

.traffic-light-card.status-yellow {
  border-color: var(--warning);
  background: linear-gradient(180deg, var(--warning-bg) 0%, var(--bg-card) 60%);
}

.traffic-light-card.status-red {
  border-color: var(--danger);
  background: linear-gradient(180deg, var(--danger-bg) 0%, var(--bg-card) 60%);
}

.traffic-head-container {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

/* Caja física del semáforo con lámparas */
.traffic-housing {
  background: #1e293b;
  border-radius: var(--radius-md);
  padding: 0.5rem 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6), 0 4px 6px rgba(0, 0, 0, 0.2);
  border: 2px solid #0f172a;
}

.light-circle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  opacity: 0.25;
  transition: all 0.3s ease;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}

.light-red {
  background: #ef4444;
}

.light-yellow {
  background: #f59e0b;
}

.light-green {
  background: #22c55e;
}

.light-circle.active.light-red {
  opacity: 1;
  box-shadow: 0 0 14px #ef4444, inset 0 0 4px #ffffff;
}

.light-circle.active.light-yellow {
  opacity: 1;
  box-shadow: 0 0 14px #f59e0b, inset 0 0 4px #ffffff;
}

.light-circle.active.light-green {
  opacity: 1;
  box-shadow: 0 0 14px #22c55e, inset 0 0 4px #ffffff;
}

.traffic-info-area {
  flex: 1;
  min-width: 0;
}

.traffic-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.25rem;
}

.badge-green {
  background: var(--success);
  color: #ffffff;
}

.badge-yellow {
  background: var(--warning);
  color: #ffffff;
}

.badge-red {
  background: var(--danger);
  color: #ffffff;
}

.traffic-status-title {
  font-size: 1.25rem;
  margin: 0 0 0.3rem 0;
  color: var(--text-primary);
}

.traffic-status-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin: 0;
}

/* Medidores y barras de progreso */
.gauges-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.gauge-block {
  background: var(--bg-card-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.gauge-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.gauge-title {
  font-weight: 600;
  color: var(--text-primary);
}

.gauge-val-badge {
  font-size: 0.8rem;
  font-weight: 700;
}

.progress-bar-track {
  width: 100%;
  height: 8px;
  background: var(--border-color);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: var(--radius-full);
  transition: width 0.4s ease, background-color 0.3s ease;
}

.fill-green {
  background-color: var(--success);
}

.fill-yellow {
  background-color: var(--warning);
}

.fill-red {
  background-color: var(--danger);
}

.gauge-details-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.25rem;
}

.quota-pill {
  font-size: 0.72rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.2rem 0.45rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

/* Alertas aduaneras */
.customs-alerts-container {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.customs-alert-card {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  line-height: 1.4;
}

.alert-warning {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: var(--warning);
}

.alert-danger {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
}

.alert-icon {
  flex-shrink: 0;
}

.alert-content p {
  margin: 0.2rem 0 0 0;
  color: var(--text-primary);
}

/* Liquidación estimada (Canal rojo) */
.tax-settlement-box {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.settlement-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  color: var(--danger);
  margin-bottom: 0.35rem;
}

.settlement-title {
  font-size: 1.1rem;
  margin: 0 0 0.35rem 0;
  color: var(--text-primary);
}

.settlement-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0 0 1rem 0;
}

.settlement-table-wrapper {
  overflow-x: auto;
  margin-bottom: 1rem;
}

.settlement-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.settlement-table tr td {
  padding: 0.5rem 0.25rem;
  border-bottom: 1px solid var(--border-color);
}

.settlement-table tr.row-highlight td {
  background: var(--bg-card);
  font-weight: 600;
}

.settlement-table tr.row-total td {
  font-size: 1rem;
  border-top: 2px solid var(--border-color);
  border-bottom: none;
  padding-top: 0.75rem;
}

.settlement-advice {
  display: flex;
  gap: 0.6rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  border-top: 1px dashed var(--border-color);
  padding-top: 0.75rem;
}

/* Catálogo rápido de artículos */
.preset-catalog-box {
  margin-bottom: 1.5rem;
}

.preset-quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.btn-preset-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 40px;
}

.btn-preset-card:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-1px);
}

.preset-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 0.2rem;
}

.preset-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.3rem;
  line-height: 1.2;
}

.preset-price {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* Carrito de compras */
.cart-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.cart-empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
}

.cart-empty-icon {
  margin-bottom: 0.75rem;
  opacity: 0.6;
}

.cart-empty-text {
  font-size: 0.9rem;
  margin: 0;
}

.cart-items-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.cart-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  gap: 1rem;
}

.cart-item-info {
  flex: 1;
  min-width: 0;
}

.cart-item-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
  word-break: break-word;
}

.cart-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.badge-cat,
.badge-currency,
.badge-spec {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.cart-item-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.quantity-control {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.btn-qty-minus,
.btn-qty-plus {
  background: none;
  border: none;
  padding: 0.25rem 0.5rem;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text-primary);
  min-height: 32px;
  min-width: 32px;
}

.btn-qty-minus:hover,
.btn-qty-plus:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.qty-num {
  font-size: 0.85rem;
  padding: 0 0.4rem;
  min-width: 20px;
  text-align: center;
}

.cart-item-price {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 75px;
  text-align: right;
}

.btn-remove-item {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.3rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  min-width: 32px;
}

.btn-remove-item:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

/* Botones principales */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-md);
  background-color: var(--primary);
  color: #ffffff;
  border: none;
  cursor: pointer;
  min-height: 42px;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  min-height: 40px;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: var(--bg-card-subtle);
  color: var(--text-primary);
}

/* Modales accesibles */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: scale(0.96);
  transition: transform 0.2s ease;
}

.modal-overlay.is-open .modal-dialog {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: 1.15rem;
  margin: 0;
  color: var(--text-primary);
}

.btn-modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
}

.btn-modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-card-subtle);
}

.modal-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-card-subtle);
}

/* Guía técnica y acordeones SEO */
.customs-seo-guide {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-top: 2rem;
  margin-bottom: 2rem;
}

.guide-section-title {
  font-size: 1.4rem;
  margin: 0 0 0.5rem 0;
  color: var(--text-primary);
}

.guide-section-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.faq-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.faq-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.faq-question {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: none;
  text-align: left;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  min-height: 44px;
}

.faq-item[open] .faq-question {
  background: var(--bg-card-subtle);
}

.faq-answer {
  padding: 1rem 1.25rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
}

.faq-answer p {
  margin: 0 0 0.75rem 0;
}

.faq-answer ul {
  margin: 0 0 0.75rem 1.25rem;
  padding: 0;
}

.faq-answer li {
  margin-bottom: 0.35rem;
}

/* Impresión optimizada */
@media print {
  .app-header,
  .fijate-footer,
  .tool-ad-sidebar,
  .tools-ad-banner-section,
  .btn-scenario-load,
  .scenarios-toolbar,
  .cart-actions-bar,
  .btn-preset-card,
  .preset-catalog-box,
  .amazon-affiliate-section,
  .customs-seo-guide,
  .btn-remove-item,
  .quantity-control button {
    display: none !important;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .tool-layout {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .card-panel {
    box-shadow: none !important;
    border: 1px solid #cccccc !important;
  }

  .traffic-light-card {
    border: 2px solid #000000 !important;
    background: #ffffff !important;
  }
}
