/* --- Estilos Generales --- */
body {
    font-family: -apple-system, BlinkMacMacFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background-color: #f4f7f6;
    color: #333;
}

/* --- Barra de Navegación Superior --- */
.navbar {
    background-color: #2c3e50;
    padding: 1rem 2rem;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar h1 {
    margin: 0;
    font-size: 1.8rem;
}

/* --- Contenedor Principal --- */
.container {
    max-width: 900px;
    margin: 2rem auto;
    padding: 2rem;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* ===== ESTILO PARA EL BLOQUE DE INTRODUCCIÓN ===== */
.explanation-intro {
    background-color: #eaf2f8; /* Un celeste muy claro */
    border-left: 4px solid #3498db; /* Un borde que coincide con el color de la grilla */
    padding: 1rem 1.5rem;
    margin-bottom: 2rem;
    border-radius: 5px;
}
.explanation-intro h3 {
    margin-top: 0;
    color: #2980b9;
}
.explanation-intro p {
    line-height: 1.6;
}
.explanation-intro ul {
    list-style: disc; /* Vuelvo a poner el estilo de lista por defecto */
    padding-left: 20px;
}
.explanation-intro li {
    margin-bottom: 0.5rem;
}


/* --- Grid de Tarjetas (para finanzas.html) --- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    padding: 0;
    list-style: none;
}

.card {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    text-align: center;
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.card h2 {
    margin-top: 0;
    color: #2c3e50;
}

.card p {
    color: #555;
    flex-grow: 1;
}

/* --- Formularios y Botones --- */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.form-group input, .form-group-select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
    font-size: 1rem;
    background-color: white;
}

.btn {
    display: inline-block;
    width: 100%;
    background-color: #27ae60;
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 5px;
    text-decoration: none;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
    font-size: 1.1rem;
    text-align: center;
    box-sizing: border-box; /* <-- ESTA ES LA LÍNEA QUE ARREGLA EL PROBLEMA */
}

.btn:hover {
    background-color: #229954;
}

/* NUEVO ESTILO PARA BOTONES DE ANCHO COMPLETO */
.full-width-btn {
    width: 100%;
    display: block; /* Asegura que ocupe todo el ancho disponible */
    box-sizing: border-box; /* Incluye padding y border en el ancho */
}


/* --- Estilos para el Visualizador Gráfico Interés Simple y Rendimiento Acciones --- */
.visualizer-section {
    padding: 2rem;
    background-color: #ecf0f1;
    border-radius: 8px;
}

.visualizer-section h2 {
    margin-top: 0;
}

.visualizer-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.visualizer-inputs .form-group {
    flex-grow: 1;
    min-width: 0; 
}

.helper-text {
    font-size: 0.9em;
    font-style: italic;
    color: #555;
    text-align: center;
    margin-top: -1rem;
    margin-bottom: 1.5rem;
    height: 1.2em; /* Asegura un espacio constante */
}

/* NUEVOS ESTILOS PARA LAS BARRAS VISUALES (REUTILIZADAS) */
#visual-bars-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem; /* Espacio entre las barras */
    margin-bottom: 2rem;
    padding: 1rem;
    background-color: #fdfdfd;
    border-radius: 8px;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.05);
}

.bar-label {
    width: 100%;
    text-align: left;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 0.25rem;
    font-size: 0.95em;
}

.visual-bar {
    width: 90%; /* Ancho máximo para la visualización */
    height: 30px; /* Altura de la barra */
    background-color: #d1d5db; /* Color base */
    border-radius: 5px;
    overflow: hidden; /* Asegura que el contenido no se desborde */
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: bold;
    transition: all 0.5s ease-out; /* Transición suave para cambios de tamaño y color */
}

.visual-bar.capital {
    background-color: #3498db; /* Azul para el capital / inversión inicial */
    color: white;
    justify-content: flex-start; /* Alinea el texto a la izquierda */
    padding-left: 10px;
}

.visual-bar.total {
    background-color: #8e44ad; /* Púrpura para el total / valor de venta */
    color: white;
    justify-content: flex-start; /* Alinea el texto a la izquierda */
    padding-left: 10px;
}

/* Colores para la barra de rendimiento (interés) */
.visual-bar.gain { /* Para ganancias */
    background-color: #27ae60; /* Verde */
    color: white;
}

.visual-bar.loss { /* Para pérdidas */
    background-color: #e74c3c; /* Rojo */
    color: white;
}


/* Estilos para los valores dentro de las barras */
.visual-bar span {
    white-space: nowrap; /* Evita que el texto se rompa */
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}


#visual-explanation {
    padding: 1rem 1.5rem;
    background-color: #fff;
    border-radius: 5px;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column; /* Asegura que los elementos se apilen si hay más de uno */
    text-align: center; /* Centra el texto por defecto */
}

#visual-explanation ul {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
    text-align: left;
}

#visual-explanation li {
    padding: 0.3rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1rem;
    border-bottom: 1px solid #ecf0f1;
}

#visual-explanation li:last-child {
    border-bottom: none;
    font-weight: bold;
    font-size: 1.1rem;
}

/* Estilo específico para las líneas de fórmula */
.formula-line {
    font-style: italic;
    color: #555;
    font-size: 0.9em !important; /* Más pequeño para diferenciar */
    border-bottom: none !important; /* No tener borde inferior */
    margin-top: 0.5rem; /* Espacio extra arriba */
    margin-bottom: 0.25rem; /* Espacio extra abajo */
}
.formula-line .explanation-value {
    color: #555 !important;
    font-weight: normal !important;
}


#visual-explanation .explanation-value {
    font-weight: bold;
    color: #2c3e50;
    margin-left: 1rem;
}

/* Colores para el texto de rendimiento en la explicación */
.gain-text {
    color: #27ae60; /* Verde para ganancia */
    font-weight: bold;
}
.loss-text {
    color: #e74c3c; /* Rojo para pérdida */
    font-weight: bold;
}
.neutral-text {
    color: #555; /* Gris para neutral */
    font-weight: bold;
}

/* ===== ESTILOS PARA INTERÉS COMPUESTO Y SISTEMA FRANCÉS ===== */
.result-section {
    display: none; 
}

.summary-container {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.summary-box {
    flex-grow: 1;
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
    min-width: 200px;
}

.summary-box h4 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1rem;
    color: #555;
}

.summary-box p {
    margin: 0;
    font-size: 2rem;
    font-weight: bold;
}

.summary-simple {
    background-color: #eaf2f8; 
    border-bottom: 4px solid #3498db;
}

.summary-compuesto {
    background-color: #e8f6ef; 
    border-bottom: 4px solid #27ae60;
}

.summary-prestamo {
    background-color: #f9e79f;
    border-bottom: 4px solid #f1c40f;
}

.table-container {
    margin-top: 2rem;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 5px;
}

.amortizacion-table, #tabla-comparacion {
    width: 100%;
    border-collapse: collapse;
}

.amortizacion-table th, #tabla-comparacion th, .amortizacion-table td, #tabla-comparacion td {
    padding: 0.75rem;
    text-align: right;
    border-bottom: 1px solid #ddd;
    vertical-align: top; 
}

.amortizacion-table th, #tabla-comparacion th {
    background-color: #ecf0f1;
    font-weight: bold;
    position: sticky;
    top: 0;
    z-index: 10;
}

.amortizacion-table td:first-child, #tabla-comparacion td:first-child {
    text-align: center;
    font-weight: bold;
}

.formula-detail {
    display: block;
    font-size: 0.8em;
    color: #7f8c8d;
    font-style: italic;
    margin-top: 0.25rem;
}

.grafico-container {
    margin-top: 2rem;
    max-width: 100%; /* Ajuste para el gráfico de barras */
    margin-left: auto;
    margin-right: auto;
}

/* Estilos específicos para la sección de Volatilidad */
.chart-container {
    position: relative;
    height: 400px; /* Altura fija para el gráfico */
    width: 100%;
    margin-bottom: 2rem;
    background-color: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.mt-20 {
    margin-top: 20px;
}