/* ==========================================================================
   Calculadora de margen real para reventa en redes sociales - Estilos
   Cumplimiento con los estándares canónicos de fijate.com
   ========================================================================== */

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

  /* Tema claro */
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-alt: #f1f5f9;
  --bg-input: #ffffff;
  --border-color: #e2e8f0;
  --border-focus: #e11d48;
  
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-light: #64748b;
  
  --primary: #e11d48;
  --primary-hover: #be123c;
  --primary-light: #fff1f2;
  --primary-border: #fecdd3;
  
  --accent-purple: #7c3aed;
  --accent-purple-light: #f5f3ff;
  --accent-purple-border: #ddd6fe;

  --success: #059669;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;

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

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

  --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.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --radius: 12px;
}

[data-theme="dark"] {
  --bg-body: #090d16;
  --bg-card: #131b2e;
  --bg-card-alt: #1a253c;
  --bg-input: #0e1526;
  --border-color: #243452;
  --border-focus: #f43f5e;

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

  --primary: #f43f5e;
  --primary-hover: #fb7185;
  --primary-light: #3f121d;
  --primary-border: #881337;

  --accent-purple: #a78bfa;
  --accent-purple-light: #2e1065;
  --accent-purple-border: #5b21b6;

  --success: #10b981;
  --success-bg: #064e3b;
  --success-border: #047857;

  --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.5);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

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

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

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

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

.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3.5rem;
  padding: 0 1rem;
  width: 100%;
  flex: 1;
}

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

.tool-main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Navegación por pestañas */
.nav-tabs-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 0.35rem;
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
  scrollbar-width: none;
}

.nav-tabs-wrapper::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  flex: 1;
  min-width: 130px;
  min-height: 44px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 0.85rem;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-main);
  background: var(--bg-card-alt);
}

.tab-btn.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(225, 29, 72, 0.3);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

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

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

.section-title {
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.badge-pill {
  font-size: 0.75rem;
  font-family: var(--font-heading);
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-pink {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-border);
}

.badge-purple {
  background: var(--accent-purple-light);
  color: var(--accent-purple);
  border: 1px solid var(--accent-purple-border);
}

/* Cuadrículas de formulario */
.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.form-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.label-hint {
  font-size: 0.78rem;
  color: var(--text-light);
  font-weight: 400;
}

/* Inputs táctiles >= 40px */
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-suffix {
  position: absolute;
  right: 12px;
  color: var(--text-light);
  font-weight: 600;
  font-size: 0.9rem;
  pointer-events: none;
}

.input-wrapper .form-input {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
}

.form-input {
  width: 100%;
  height: 44px;
  min-height: 44px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0 2.5rem 0 0.85rem;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.15);
}

/* Desplegables con estilo canónico */
.form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 44px;
  min-height: 44px;
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0 40px 0 0.85rem;
  font-family: var(--font-main);
  font-size: 0.92rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  appearance: none;
  -webkit-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%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.15);
}

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

/* Tarjetas resumen con métricas clave */
.metrics-hero {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.metric-box {
  background: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  position: relative;
  overflow: hidden;
}

.metric-box.highlight {
  background: var(--success-bg);
  border: 2px solid var(--success);
}

.metric-box.highlight .metric-title {
  color: var(--success);
}

.metric-box.highlight .metric-value {
  color: var(--success);
}

.metric-title {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--text-main);
}

.metric-sub {
  font-size: 0.78rem;
  color: var(--text-light);
}

/* Cascada interactiva de costes */
.cost-breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

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

.cost-info {
  display: flex;
  flex-direction: column;
}

.cost-label {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.cost-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.cost-amount {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  text-align: right;
  white-space: nowrap;
}

.cost-row.cost-negative .cost-amount {
  color: var(--danger);
}

.cost-row.cost-profit {
  background: var(--success-bg);
  border: 2px solid var(--success);
  padding: 1.15rem 1.25rem;
}

.cost-row.cost-profit .cost-label {
  font-size: 1.1rem;
  color: var(--success);
}

.cost-row.cost-profit .cost-amount {
  font-size: 1.55rem;
  color: var(--success);
}

/* Comparador de canales de venta (Grid) */
.channels-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
}

.channel-card {
  background: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  transition: transform 0.2s, box-shadow 0.2s;
}

.channel-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.channel-card.top-profit {
  border: 2px solid var(--success);
  background: var(--bg-card);
}

.channel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.channel-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.channel-profit-num {
  font-family: var(--font-mono);
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--success);
}

.channel-details {
  font-size: 0.84rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* Editor de comisiones en tarjeta de canal */
.channel-commission-editor {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.editor-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.micro-inputs-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.micro-input-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.micro-input-field label {
  font-size: 0.72rem;
  color: var(--text-light);
  font-weight: 600;
}

.micro-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.micro-input {
  width: 100%;
  height: 36px;
  padding: 0.3rem 1.5rem 0.3rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 700;
  text-align: right;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-main);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.micro-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.micro-input-wrapper span {
  position: absolute;
  right: 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  pointer-events: none;
}

/* Banner explicativo de campos editables */
.form-hint-banner {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: var(--bg-card-alt);
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  margin-bottom: 1.25rem;
}

.form-hint-banner svg {
  flex-shrink: 0;
  color: var(--primary);
}

/* Barra de herramientas del comparador de canales */
.channels-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  background: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.85rem 1.15rem;
  margin: 1.25rem 0 1.5rem;
}

.toolbar-hint {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex: 1 1 280px;
}

.toolbar-hint svg {
  flex-shrink: 0;
  color: var(--accent-purple);
}

.btn-outline-sm {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-outline-sm:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* Medidor de markup multiplicador */
.markup-gauge {
  background: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.gauge-bar-track {
  height: 12px;
  background: #cbd5e1;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

[data-theme="dark"] .gauge-bar-track {
  background: #1e293b;
}

.gauge-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.4s ease, background-color 0.4s ease;
  width: 0%;
}

.gauge-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--text-light);
  font-family: var(--font-mono);
}

/* Botones de acción */
.btn-primary {
  width: 100%;
  min-height: 44px;
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  transition: background-color 0.2s, transform 0.1s;
}

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

.btn-primary:active {
  transform: scale(0.99);
}

/* Modal canónico */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  max-width: 550px;
  width: 100%;
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: var(--shadow-lg);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

/* Responsividad táctil */
@media (max-width: 992px) {
  .tool-with-sidebar {
    flex-direction: column;
  }
  .metrics-hero {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .channels-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .tool-layout {
    padding: 0 0.75rem;
    margin: 1rem auto 2.5rem;
  }
  .card-main {
    padding: 1.25rem;
  }
  .metrics-hero {
    grid-template-columns: 1fr;
  }
  .form-grid-2, .form-grid-3 {
    grid-template-columns: 1fr;
  }
  .cost-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }
  .cost-amount {
    text-align: left;
  }
}
