/* Calculadora de Amortización - Estilos */

.amortization-calculator {
  max-width: 950px;
  margin: 2rem auto;
  padding: 2rem;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Títulos de Sección */
.section-title {
  font-size: 1.3rem;
  font-weight: 600;
  color: #1a365d;
  margin: 1.5rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #e0e0e0;
}

.section-title:first-child {
  margin-top: 0;
}

/* Grupos de Formulario */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #333;
  font-size: 0.95rem;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 1rem;
  transition: border-color 0.3s ease;
  background: #fff;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #1a365d;
  box-shadow: 0 0 0 3px rgba(26, 54, 93, 0.1);
}

.form-group input::placeholder {
  color: #999;
}

/* Campo de Fecha de Inicio - Centrado */
.start-date-field {
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

/* Toggle de Pago Extra */
.extra-payment-toggle {
  margin: 1rem 0;
  text-align: center;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  padding: 0.75rem 1.5rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  transition: all 0.3s ease;
  background: #f9f9f9;
}

.checkbox-label:hover {
  border-color: #1a365d;
  background: #f0f4f8;
}

.checkbox-label input[type="checkbox"] {
  margin-right: 0.5rem;
  cursor: pointer;
  width: 18px;
  height: 18px;
}

.checkbox-label span {
  font-size: 1rem;
  color: #333;
  font-weight: 500;
}

/* Sección de Pagos Extras */
.extra-payment-section {
  display: none;
  padding: 1.5rem;
  background: #f8f9fa;
  border-radius: 8px;
  margin-top: 1rem;
  border-left: 4px solid #1a365d;
}

.extra-payment-section.active {
  display: block;
  animation: slideDown 0.4s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    max-height: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    max-height: 1000px;
    transform: translateY(0);
  }
}

#extraPaymentDateGroup,
#extraPaymentStartGroup {
  display: none;
}

#extraPaymentDateGroup.active,
#extraPaymentStartGroup.active {
  display: block;
}

/* Contenedor del Botón */
.button-container {
  text-align: center;
  margin: 2rem 0;
}

#calculateBtn {
  background-color: #1a365d;
  color: white;
  border: none;
  padding: 1rem 3rem;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 6px rgba(26, 54, 93, 0.2);
}

#calculateBtn:hover {
  background-color: #2d4a7c;
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(26, 54, 93, 0.3);
}

#calculateBtn:active {
  transform: translateY(0);
}

/* Sección de Resultados */
.results-section {
  display: none;
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 3px solid #1a365d;
  animation: fadeIn 0.5s ease;
}

.results-section.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Tarjetas de Resultado */
.result-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.result-card {
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
  padding: 1.5rem;
  border-radius: 10px;
  text-align: center;
  border: 2px solid #1a365d;
}

.result-label {
  font-size: 0.95rem;
  color: #555;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.result-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: #1a365d;
  margin: 0;
  word-break: break-word;
}

/* Resumen de Pagos Extras */
.extra-summary {
  display: none;
  margin: 2rem 0;
  padding: 1.5rem;
  background: #d4edda;
  border-radius: 8px;
  border-left: 4px solid #28a745;
}

.extra-summary.active {
  display: block;
  animation: fadeIn 0.5s ease;
}

.comparison-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.comparison-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.comparison-label {
  font-size: 0.9rem;
  color: #555;
  font-weight: 500;
}

.comparison-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: #1a365d;
}

.comparison-value.savings {
  color: #28a745;
}

/* Controles de Tabla */
.table-section {
  margin-top: 2rem;
}

.table-controls {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.toggle-btn,
.download-btn {
  background-color: #6c757d;
  color: white;
  border: none;
  padding: 0.75rem 2rem;
  font-size: 1rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.download-btn {
  background-color: #28a745;
}

.toggle-btn:hover {
  background-color: #5a6268;
  transform: translateY(-2px);
}

.download-btn:hover {
  background-color: #218838;
  transform: translateY(-2px);
}

/* Tabla de Amortización */
.schedule-table {
  display: none;
  overflow-x: auto;
  margin-top: 1rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  max-height: 600px;
  overflow-y: auto;
}

.schedule-table.active {
  display: block;
  animation: fadeIn 0.4s ease;
}

.schedule-table table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

.schedule-table thead {
  background-color: #1a365d;
  color: white;
  position: sticky;
  top: 0;
  z-index: 10;
}

.schedule-table th {
  padding: 1rem 0.75rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
}

.schedule-table td {
  padding: 0.75rem;
  border-bottom: 1px solid #e0e0e0;
  font-size: 0.875rem;
  white-space: nowrap;
}

.schedule-table tbody tr:hover {
  background-color: #f8f9fa;
}

.schedule-table tbody tr:nth-child(even) {
  background-color: #f9f9f9;
}

.schedule-table tbody tr:nth-child(even):hover {
  background-color: #f0f0f0;
}

.schedule-table tbody tr.final-row {
  font-weight: 600;
  background-color: #d4edda;
}

.schedule-table tbody tr.extra-payment {
  background-color: #fff3cd;
}

/* Sección de Gráfico */
.chart-section {
  margin-top: 2rem;
  padding: 1.5rem;
  background: #f8f9fa;
  border-radius: 8px;
}

.payment-breakdown-chart {
  margin-top: 1rem;
}

.chart-bar {
  display: flex;
  height: 60px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.chart-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  position: relative;
}

.chart-segment.principal {
  background-color: #1a365d;
}

.chart-segment.interest {
  background-color: #dc3545;
}

.chart-segment:hover {
  filter: brightness(1.1);
  cursor: pointer;
}

.chart-label {
  color: white;
  font-weight: 600;
  font-size: 0.9rem;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.chart-legend {
  display: flex;
  gap: 2rem;
  justify-content: center;
  margin-top: 1rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.legend-color {
  width: 20px;
  height: 20px;
  border-radius: 4px;
}

.legend-color.principal {
  background-color: #1a365d;
}

.legend-color.interest {
  background-color: #dc3545;
}

/* Responsive Design */
@media (max-width: 768px) {
  .amortization-calculator {
    padding: 1.5rem;
    margin: 1rem;
  }

  .section-title {
    font-size: 1.1rem;
  }

  .result-cards {
    grid-template-columns: 1fr;
  }

  .result-value {
    font-size: 1.5rem;
  }

  .comparison-grid {
    grid-template-columns: 1fr;
  }

  #calculateBtn {
    width: 100%;
    padding: 1rem 2rem;
  }

  .table-controls {
    flex-direction: column;
  }

  .toggle-btn,
  .download-btn {
    width: 100%;
  }

  .schedule-table {
    font-size: 0.8rem;
  }

  .schedule-table th,
  .schedule-table td {
    padding: 0.5rem 0.3rem;
  }

  .chart-legend {
    flex-direction: column;
    gap: 0.75rem;
  }
}

@media (max-width: 480px) {
  .amortization-calculator {
    padding: 1rem;
    margin: 0.5rem;
  }

  .section-title {
    font-size: 1rem;
    margin: 1rem 0 0.75rem;
  }

  .form-group label {
    font-size: 0.9rem;
  }

  .form-group input,
  .form-group select {
    padding: 0.6rem;
    font-size: 0.95rem;
  }

  .result-card {
    padding: 1rem;
  }

  .result-label {
    font-size: 0.85rem;
  }

  .result-value {
    font-size: 1.3rem;
  }

  .comparison-value {
    font-size: 1.1rem;
  }

  #calculateBtn {
    font-size: 1rem;
    padding: 0.875rem 1.5rem;
  }

  .toggle-btn,
  .download-btn {
    font-size: 0.9rem;
    padding: 0.6rem 1.5rem;
  }

  .schedule-table th,
  .schedule-table td {
    padding: 0.4rem 0.2rem;
    font-size: 0.75rem;
  }

  .chart-bar {
    height: 40px;
  }

  .chart-label {
    font-size: 0.75rem;
  }
}

/* Animación de pulso para resultado principal */
@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
  }
}

.result-cards .result-card:first-child {
  animation: pulse 2s ease-in-out infinite;
}
