/* ============================================
   COMPONENTS — Componentes reutilizables
   Enfoque: mobile-first (base = móvil,
   min-width para pantallas mayores)
   calculadorainversion.com
   ============================================ */


/* ==========================================
   CARDS
   ========================================== */

.card {
  background:    var(--color-bg-card);
  border:        1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding:       var(--s-6);
}

.card--soft {
  background:   var(--color-bg-soft);
  border-color: var(--color-border-soft);
}

.card--accent {
  border-color: var(--green);
  border-width: 2px;
}


/* ==========================================
   BUTTONS
   ========================================== */

.btn {
  display:         inline-flex;
  align-items:     center;
  gap:             var(--s-2);
  padding:         var(--s-3) var(--s-5);
  font-size:       var(--text-sm);
  font-weight:     var(--weight-medium);
  border-radius:   var(--radius);
  border:          1px solid transparent;
  cursor:          pointer;
  transition:      background var(--transition), color var(--transition), border-color var(--transition);
  text-decoration: none;
  white-space:     nowrap;
}

.btn--primary {
  background:   var(--color-accent);
  color:        #fff;
  border-color: var(--color-accent);
}

.btn--primary:hover {
  background:      var(--color-accent-hover);
  border-color:    var(--color-accent-hover);
  color:           #fff;
  text-decoration: none;
}

.btn--outline {
  background:   transparent;
  color:        var(--color-accent);
  border-color: var(--color-accent);
}

.btn--outline:hover {
  background:      var(--green-light);
  text-decoration: none;
}

.btn--ghost {
  background:   transparent;
  color:        var(--color-text-muted);
  border-color: var(--color-border);
}

.btn--ghost:hover {
  background:      var(--color-bg-soft);
  color:           var(--color-text);
  text-decoration: none;
}

.btn--lg {
  padding:   var(--s-4) var(--s-8);
  font-size: var(--text-base);
}


/* ==========================================
   FORM FIELDS
   ========================================== */

.field {
  margin-bottom: var(--s-5);
}

.field label {
  display:       block;
  font-size:     var(--text-sm);
  font-weight:   var(--weight-medium);
  color:         var(--color-text-soft);
  margin-bottom: var(--s-2);
}

.field input[type="number"],
.field input[type="text"],
.field select {
  width:         100%;
  padding:       var(--s-3) var(--s-4);
  font-size:     var(--text-base);
  color:         var(--color-text);
  background:    var(--color-bg);
  border:        1px solid var(--color-border);
  border-radius: var(--radius);
  transition:    border-color var(--transition);
  appearance:    none;
}

.field input:focus,
.field select:focus {
  outline:      none;
  border-color: var(--color-accent);
  box-shadow:   0 0 0 3px rgba(29, 158, 117, 0.12);
}

/* --- Prefijo € dentro del input ---
   El wrapper .input-prefix rodea SOLO al input,
   así el símbolo se centra respecto al input y no
   respecto al conjunto label+input (bug anterior) */
.input-prefix {
  position: relative;
}

.input-prefix::before {
  content:        '€';
  position:       absolute;
  left:           var(--s-4);
  top:            50%;
  transform:      translateY(-50%);
  color:          var(--color-text-muted);
  font-size:      var(--text-base);
  pointer-events: none;
}

.input-prefix input {
  padding-left: var(--s-8);
}

/* --- Range slider --- */
.range-field {
  margin-bottom: var(--s-5);
}

.range-field label {
  display:       block;
  font-size:     var(--text-sm);
  font-weight:   var(--weight-medium);
  color:         var(--color-text-soft);
  margin-bottom: var(--s-2);
}

.range-field__row {
  display:     flex;
  align-items: center;
  gap:         var(--s-3);
}

.range-field input[type="range"] {
  flex:          1;
  height:        4px;
  appearance:    none;
  background:    var(--color-border);
  border-radius: 2px;
  cursor:        pointer;
}

.range-field input[type="range"]::-webkit-slider-thumb {
  appearance:    none;
  width:         18px;
  height:        18px;
  border-radius: 50%;
  background:    var(--color-accent);
  border:        2px solid var(--white);
  box-shadow:    var(--shadow-sm);
  cursor:        pointer;
}

.range-field input[type="range"]::-moz-range-thumb {
  width:         18px;
  height:        18px;
  border-radius: 50%;
  background:    var(--color-accent);
  border:        2px solid var(--white);
  cursor:        pointer;
}

.range-field__value {
  font-size:   var(--text-sm);
  font-weight: var(--weight-medium);
  min-width:   56px;
  text-align:  right;
  color:       var(--color-text);
}


/* ==========================================
   CALCULATOR LAYOUT (mobile-first)
   Base: una columna. ≥768px: dos columnas
   ========================================== */

.calc-grid {
  display:               grid;
  grid-template-columns: 1fr;
  gap:                   var(--s-6);
}

.calc-panel {
  background:    var(--color-bg-card);
  border:        1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding:       var(--s-5);
}

.calc-panel__title {
  font-size:      var(--text-xs);
  font-weight:    var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color:          var(--color-text-muted);
  margin-bottom:  var(--s-5);
}

/* --- Métricas de resultado --- */
.metrics {
  display:               grid;
  grid-template-columns: 1fr 1fr;
  gap:                   var(--s-3);
  margin-bottom:         var(--s-5);
}

.metric {
  background:    var(--color-bg-soft);
  border-radius: var(--radius);
  padding:       var(--s-4);
}

.metric__label {
  font-size:     var(--text-xs);
  color:         var(--color-text-muted);
  margin-bottom: var(--s-1);
}

.metric__value {
  font-size:   var(--text-xl);
  font-weight: var(--weight-bold);
  color:       var(--color-text);
  line-height: 1.1;
}

.metric__value--accent {
  color: var(--color-accent);
}

/* --- Barra de proporción aportado vs ganado --- */
.ratio-bar {
  margin: var(--s-4) 0;
}

.ratio-bar__header {
  display:         flex;
  justify-content: space-between;
  font-size:       var(--text-xs);
  color:           var(--color-text-muted);
  margin-bottom:   var(--s-1);
}

.ratio-bar__track {
  height:        8px;
  background:    var(--color-border);
  border-radius: 4px;
  overflow:      hidden;
  margin:        var(--s-2) 0;
}

.ratio-bar__fill {
  height:        100%;
  background:    var(--color-accent);
  border-radius: 4px;
  transition:    width 400ms ease;
}

.ratio-bar__labels {
  display:         flex;
  justify-content: space-between;
  font-size:       var(--text-xs);
  color:           var(--color-text-muted);
}

/* --- Contenedor del gráfico --- */
.chart-wrapper {
  position:   relative;
  width:      100%;
  height:     220px;
  margin-top: var(--s-5);
}


/* ==========================================
   AFFILIATE CTA
   ========================================== */

.affiliate-cta {
  background:    var(--green-light);
  border:        1px solid rgba(29, 158, 117, 0.2);
  border-radius: var(--radius-lg);
  padding:       var(--s-5);
  margin-top:    var(--s-5);
}

.affiliate-cta__tag {
  font-size:      var(--text-xs);
  font-weight:    var(--weight-medium);
  color:          var(--green-text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom:  var(--s-2);
}

.affiliate-cta__text {
  font-size:     var(--text-sm);
  color:         var(--color-text-soft);
  margin-bottom: var(--s-4);
  line-height:   1.5;
}

/* --- CTA inline dentro de artículo --- */
.inline-cta {
  border-left:   3px solid var(--color-accent);
  padding:       var(--s-4) var(--s-5);
  background:    var(--color-bg-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin:        var(--s-6) 0;
}

.inline-cta p {
  margin-bottom: var(--s-3);
  color:         var(--color-text-soft);
}


/* ==========================================
   FAQ ACCORDION (accesible)
   El toggle es un <button> real dentro del <h3>
   ========================================== */

.faq {
  margin-top: var(--s-12);
}

.faq h2 {
  font-size:     var(--text-2xl);
  font-weight:   var(--weight-bold);
  margin-bottom: var(--s-6);
}

.faq-item {
  border-bottom: 1px solid var(--color-border-soft);
}

.faq-item:first-of-type {
  border-top: 1px solid var(--color-border-soft);
}

.faq-item h3 {
  margin: 0;
}

.faq-item__toggle {
  width:           100%;
  display:         flex;
  justify-content: space-between;
  align-items:     center;
  gap:             var(--s-4);
  padding:         var(--s-5) 0;
  background:      none;
  border:          none;
  cursor:          pointer;
  text-align:      left;
  font-size:       var(--text-base);
  font-weight:     var(--weight-medium);
  color:           var(--color-text);
  font-family:     inherit;
}

.faq-item__toggle::after {
  content:     '+';
  font-size:   var(--text-xl);
  font-weight: var(--weight-normal);
  color:       var(--color-text-muted);
  flex-shrink: 0;
  transition:  transform var(--transition);
}

.faq-item.open .faq-item__toggle::after {
  transform: rotate(45deg);
}

.faq-item__answer {
  display:        none;
  padding-bottom: var(--s-5);
  color:          var(--color-text-soft);
  font-size:      var(--text-sm);
  line-height:    1.7;
  max-width:      65ch;
}

.faq-item.open .faq-item__answer {
  display: block;
}


/* ==========================================
   COMPARISON TABLE (brokers)
   ========================================== */

.table-wrapper {
  overflow-x: auto;
  margin:     var(--s-8) 0;
}

.comparison-table {
  width:     100%;
  font-size: var(--text-sm);
}

.comparison-table th {
  text-align:    left;
  padding:       var(--s-3) var(--s-4);
  font-weight:   var(--weight-medium);
  color:         var(--color-text-muted);
  border-bottom: 2px solid var(--color-border);
  white-space:   nowrap;
}

.comparison-table td {
  padding:        var(--s-4);
  border-bottom:  1px solid var(--color-border-soft);
  vertical-align: middle;
}

.comparison-table tr:hover td {
  background: var(--color-bg-soft);
}

.comparison-table tr.featured td {
  background: var(--green-light);
}

/* --- Badges --- */
.badge {
  display:       inline-block;
  font-size:     var(--text-xs);
  font-weight:   var(--weight-medium);
  padding:       2px 8px;
  border-radius: var(--radius-sm);
}

.badge--green {
  background: var(--green-light);
  color:      var(--green-text);
}

.badge--gray {
  background: var(--color-bg-soft);
  color:      var(--color-text-muted);
}


/* ==========================================
   BLOG — Listado y tarjetas
   ========================================== */

.blog-grid {
  display:               grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap:                   var(--s-6);
  margin-top:            var(--s-8);
}

.blog-card {
  display:         block;
  background:      var(--color-bg-card);
  border:          1px solid var(--color-border);
  border-radius:   var(--radius-lg);
  padding:         var(--s-6);
  transition:      box-shadow var(--transition), border-color var(--transition);
  text-decoration: none;
}

.blog-card:hover {
  box-shadow:      var(--shadow);
  text-decoration: none;
}

.blog-card__category {
  font-size:      var(--text-xs);
  font-weight:    var(--weight-medium);
  color:          var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom:  var(--s-3);
}

.blog-card__title {
  font-size:     var(--text-lg);
  font-weight:   var(--weight-bold);
  color:         var(--color-text);
  margin-bottom: var(--s-3);
  line-height:   1.35;
}

.blog-card__excerpt {
  font-size:   var(--text-sm);
  color:       var(--color-text-muted);
  line-height: 1.6;
}


/* ==========================================
   DISCLAIMER LEGAL
   ========================================== */

.disclaimer {
  font-size:     var(--text-xs);
  color:         var(--color-text-muted);
  line-height:   1.6;
  padding:       var(--s-4);
  border:        1px solid var(--color-border-soft);
  border-radius: var(--radius);
  margin-top:    var(--s-8);
}


/* ==========================================
   PANTALLAS MEDIANAS Y GRANDES (≥768px)
   ========================================== */

@media (min-width: 768px) {

  /* Calculadora a dos columnas */
  .calc-grid {
    grid-template-columns: 1fr 1fr;
  }

  .calc-panel {
    padding: var(--s-6);
  }

  /* Métricas más grandes con más espacio disponible */
  .metric__value {
    font-size: var(--text-2xl);
  }

}
