/* ==========================================================================
   Calculadora de comisiones de cobro - Estilos Canónicos
   Fijate Tools
   ========================================================================== */

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

  /* Modo oscuro por defecto */
  --bg-app: #0a0e17;
  --bg-card: #111726;
  --bg-card-hover: #162035;
  --bg-input: #0d1322;
  --bg-secondary: #1a2238;
  --border-color: #232f48;
  --border-focus: #3b82f6;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-light: #64748b;

  --accent-green: #10b981;
  --accent-green-bg: rgba(16, 185, 129, 0.12);
  --accent-green-border: rgba(16, 185, 129, 0.35);

  --accent-blue: #3b82f6;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 14px 34px rgba(0, 0, 0, 0.45);
}

html[data-theme="light"] {
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #ffffff;
  --bg-secondary: #f1f5f9;
  --border-color: #e2e8f0;
  --border-focus: #2563eb;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-light: #94a3b8;

  --accent-green-bg: rgba(16, 185, 129, 0.08);

  --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 20px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 14px 34px rgba(15, 23, 42, 0.12);
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.6;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text-main);
  font-weight: 700;
  line-height: 1.25;
}

/* Layout y Contención */
.tool-layout {
  max-width: 1200px;
  width: 100%;
  margin: 1.5rem auto 3.5rem;
  padding: 0 1.25rem;
  flex: 1 0 auto;
}

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

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

.card-main {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 2.5rem;
}

/* Navegación por Pestañas (Modo de cálculo) */
.calc-mode-nav {
  display: flex;
  gap: 0.5rem;
  background-color: var(--bg-secondary);
  padding: 0.35rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: 1.25rem;
}

.tab-btn {
  flex: 1 1 0%;
  height: 44px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.92rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  background-color: var(--bg-card);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

/* Tira de metadatos y personalización */
.pricing-meta-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px dashed var(--border-color);
}

.meta-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.meta-tag svg {
  color: var(--accent-green);
}

.btn-text-action {
  background: transparent;
  border: none;
  font-family: var(--font-main);
  font-size: 0.82rem;
  color: var(--accent-blue);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background-color 0.15s ease;
}

.btn-text-action:hover {
  background-color: var(--bg-secondary);
  text-decoration: underline;
}

/* Formulario de Entradas Principales */
.calc-inputs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.input-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.field-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

.field-hint {
  font-size: 0.78rem;
  color: var(--text-light);
  margin-top: -0.2rem;
}

/* Input con Sufijo de Divisa (Regla 10: flex 1 1 0%) */
.currency-input-wrapper {
  display: flex;
  align-items: center;
  background-color: var(--bg-input);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  height: 48px;
}

.currency-input-wrapper:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.currency-input-wrapper.compact {
  height: 42px;
}

.currency-input {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 700;
  padding: 0 0.85rem;
  color: var(--text-main);
}

.currency-input-wrapper.compact .currency-input {
  font-size: 1.1rem;
}

.currency-symbol {
  padding: 0 1rem;
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-muted);
  background-color: var(--bg-secondary);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-left: 1px solid var(--border-color);
}

/* Desplegables Select Canónicos (Regla 10 y 5) */
.select-wrapper {
  position: relative;
  width: 100%;
}

.form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  height: 44px;
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0 40px 0 0.85rem;
  font-family: var(--font-main);
  font-size: 0.88rem;
  appearance: none;
  cursor: pointer;
  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='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  transition: border-color 0.2s ease;
}

.form-select:focus {
  border-color: var(--border-focus);
  outline: none;
}

.form-select option {
  background-color: var(--bg-card);
  color: var(--text-main);
  padding: 8px;
}

/* Chips de valores rápidos */
.chips-presets-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.35rem;
}

.chip-val {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip-val:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--border-focus);
}

.chip-val.active {
  background-color: var(--accent-blue);
  color: #ffffff;
  border-color: var(--accent-blue);
  font-weight: 700;
}

/* Tarjeta de la Opción Ganadora */
.best-gateway-card {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(16, 185, 129, 0.08) 100%);
  border: 1.5px solid var(--accent-green-border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  animation: fadeIn 0.3s ease;
}

.best-gateway-badge {
  background-color: var(--accent-green);
  color: #ffffff;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.best-gateway-content {
  flex: 1 1 0%;
  min-width: 0;
}

.best-gateway-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.best-gw-title {
  font-size: 1.2rem;
  color: var(--text-main);
}

.best-gw-amount {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--accent-green);
}

.best-gw-text {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Tabla de Comparativa */
.comparison-section {
  margin-bottom: 2.25rem;
}

.section-header-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.section-title {
  font-size: 1.15rem;
  color: var(--text-main);
}

.section-legend {
  font-size: 0.8rem;
  color: var(--text-light);
}

.table-responsive-box {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-card);
}

.gateway-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.gateway-table th,
.gateway-table td {
  padding: 0.9rem 1.15rem;
  border-bottom: 1px solid var(--border-color);
}

.gateway-table th {
  background-color: var(--bg-secondary);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.gateway-table tr:last-child td {
  border-bottom: none;
}

.gateway-table tr.is-winner {
  background-color: var(--accent-green-bg);
}

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

.mono-cell {
  font-family: var(--font-mono);
  font-weight: 600;
}

.net-amount-cell {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
}

.is-winner .net-amount-cell {
  color: var(--accent-green);
}

.fee-cell {
  font-family: var(--font-mono);
  color: var(--accent-red);
  font-weight: 600;
}

.gateway-badge-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--text-main);
}

.badge-winner-tag {
  background-color: var(--accent-green);
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

/* Barras visuales */
.visual-bars-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.35rem 1.5rem;
  margin-bottom: 2.25rem;
}

.bars-card-title {
  font-size: 1rem;
  margin-bottom: 1.15rem;
  color: var(--text-main);
}

.bars-container {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.bar-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.bar-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.bar-track {
  height: 12px;
  width: 100%;
  background-color: rgba(239, 68, 68, 0.4);
  border-radius: var(--radius-full);
  overflow: hidden;
  display: flex;
}

.bar-fill-net {
  height: 100%;
  background: linear-gradient(90deg, #10b981 0%, #34d399 100%);
  border-radius: var(--radius-full) 0 0 var(--radius-full);
  transition: width 0.35s ease;
}

/* Simulador de Proyección Mensual y Anual */
.projection-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.projection-title {
  font-size: 1.15rem;
}

.projection-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.projection-inputs-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0 1.5rem;
  background-color: var(--bg-secondary);
  padding: 1.15rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  align-items: center;
}

.proj-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.35rem;
  display: block;
}

.proj-static-val {
  height: 42px;
  display: flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-blue);
}

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

.annual-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  transition: border-color 0.15s ease;
}

.annual-card.highlight {
  border-color: var(--accent-green-border);
  background: linear-gradient(180deg, var(--bg-secondary) 0%, rgba(16, 185, 129, 0.08) 100%);
}

.annual-gw-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
}

.annual-fee-amount {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--accent-red);
}

.annual-card.highlight .annual-fee-amount {
  color: var(--accent-green);
}

.annual-card-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Modales */
.custom-modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

.custom-modal-backdrop.active {
  display: flex;
}

.custom-modal-dialog {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.custom-modal-dialog.modal-wide {
  max-width: 680px;
}

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

.custom-modal-title {
  font-size: 1.1rem;
  color: var(--text-main);
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.btn-close-modal:hover {
  color: var(--text-main);
}

.custom-modal-body {
  padding: 1.35rem;
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.6;
  max-height: 65vh;
  overflow-y: auto;
}

.custom-modal-footer {
  padding: 1rem 1.35rem;
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
}

.btn-action-primary,
.btn-action-secondary {
  height: 42px;
  padding: 0 1.25rem;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
}

.btn-action-primary {
  background-color: var(--accent-blue);
  color: #ffffff;
}

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

.btn-action-secondary {
  background-color: var(--bg-secondary);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

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

/* Tabla de Tarifas Personalizadas en Modal */
.custom-rates-table {
  width: 100%;
  border-collapse: collapse;
}

.custom-rates-table th,
.custom-rates-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
}

.rate-input-cell {
  width: 110px;
}

.input-rate-num {
  width: 100%;
  height: 36px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  padding: 0 0.5rem;
  text-align: right;
}

.input-rate-num:focus {
  border-color: var(--border-focus);
  outline: none;
}

/* Animaciones */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsividad Móvil */
@media (max-width: 768px) {
  .tool-layout {
    padding: 0 0.85rem;
    margin: 1rem auto 2.5rem;
  }

  .card-main {
    padding: 1.15rem;
    border-radius: var(--radius-md);
  }

  .calc-mode-nav {
    flex-direction: column;
  }

  .tab-btn {
    width: 100%;
  }

  .best-gateway-card {
    flex-direction: column;
    gap: 0.85rem;
  }

  .best-gw-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .currency-input {
    font-size: 1.15rem;
  }

  .gateway-table th,
  .gateway-table td {
    padding: 0.65rem 0.75rem;
  }
}
