/* Variables de colores corporativos PreparaPau */
:root {
    --azul-intenso: #00509D;
    --verde-turquesa: #30C48D;
    --blanco-puro: #FFFFFF;
    --gris-claro: #F4F6F8;
    --negro-grisaceo: #333333;
}

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

body {
    font-family: 'Lato', sans-serif;
    background-color: var(--gris-claro);
    color: var(--negro-grisaceo);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background-color: var(--azul-intenso);
    color: var(--blanco-puro);
    padding: 1rem 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.logo h1 {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 2rem;
    margin-bottom: 0.2rem;
}

.logo span {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Main Content */
.main-content {
    padding: 2rem 0;
}

.input-section {
    background: var(--blanco-puro);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.function-input {
    margin-bottom: 1.5rem;
}

.function-input label {
    display: block;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    color: var(--azul-intenso);
    margin-bottom: 0.5rem;
}

.function-input input {
    width: 70%;
    padding: 0.8rem;
    border: 2px solid var(--gris-claro);
    border-radius: 8px;
    font-size: 1rem;
    margin-right: 1rem;
    transition: border-color 0.3s ease;
}

.function-input input:focus {
    outline: none;
    border-color: var(--verde-turquesa);
}

.btn-primary {
    background-color: var(--verde-turquesa);
    color: var(--blanco-puro);
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(48, 196, 141, 0.3);
}

.btn-primary:hover {
    background-color: #28a876;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(48, 196, 141, 0.4);
}

.range-controls {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.range-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.range-group label {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    color: var(--azul-intenso);
}

.range-group input {
    width: 80px;
    padding: 0.5rem;
    border: 2px solid var(--gris-claro);
    border-radius: 8px;
    text-align: center;
}

.content-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    align-items: start;
}

.graph-section {
    background: var(--blanco-puro);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.analysis-section {
    background: var(--blanco-puro);
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.analysis-card {
    padding: 1.5rem;
}

.analysis-card h3 {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    color: var(--azul-intenso);
    margin-bottom: 1.5rem;
    text-align: center;
}

.analysis-item {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--gris-claro);
}

.analysis-item:last-child {
    border-bottom: none;
}

/* Nuevos estilos para headers con botones */
.analysis-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.analysis-item h4 {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    color: var(--verde-turquesa);
    margin: 0;
    font-size: 0.9rem;
}

.analysis-item p {
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--negro-grisaceo);
}

/* Estilos para botones de visualización */
.toggle-btn {
    background: var(--blanco-puro);
    border: 2px solid var(--gris-claro);
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.toggle-btn:hover {
    border-color: var(--verde-turquesa);
    transform: scale(1.1);
    background-color: var(--blanco-puro);
}

.toggle-btn.active {
    background-color: var(--verde-turquesa);
    border-color: var(--verde-turquesa);
    color: var(--blanco-puro);
}

.toggle-btn.active .eye-icon {
    filter: brightness(0) invert(1);
}

.toggle-btn:not(.active) {
    background-color: var(--blanco-puro);
    border-color: var(--gris-claro);
    color: var(--negro-grisaceo);
}

.toggle-btn:not(.active) .eye-icon {
    opacity: 0.7;
}

.eye-icon {
    transition: all 0.3s ease;
    pointer-events: none; /* Evita problemas con clics en el icono */
}

#functionChart {
    width: 100%;
    height: auto;
    border-radius: 8px;
}

/* Responsive */
@media (max-width: 768px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
    
    .function-input input {
        width: 100%;
        margin-bottom: 1rem;
    }
    
    .range-controls {
        flex-direction: column;
        gap: 1rem;
    }
    
    .analysis-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

.shade-legend {
    display: none;              /* Se muestra solo cuando haya algo que enseñar */
    margin-top: 8px;
    gap: 16px;
    flex-wrap: wrap;
    align-items: center;
}
.shade-legend .legend-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.shade-legend .legend-item {
    display: inline-flex;
    align-items: center;
    font-size: 0.9rem;
    color: #2c3e50;
}
.shade-legend .swatch {
    width: 14px;
    height: 10px;
    display: inline-block;
    margin-right: 6px;
    border-radius: 2px;
    border: 1px solid rgba(0,0,0,0.2);
}
/* Colores coherentes con el sombreado del gráfico */
.swatch-inc  { background: rgba(48, 196, 141, 0.35); border-color: rgba(48, 196, 141, 0.8); }
.swatch-dec  { background: rgba(231, 76, 60, 0.35);  border-color: rgba(231, 76, 60, 0.8); }
.swatch-up   { background: rgba(0, 80, 157, 0.28);   border-color: rgba(0, 80, 157, 0.65); }
.swatch-down { background: rgba(142, 68, 173, 0.28); border-color: rgba(142, 68, 173, 0.65); }

/* Estilos para ejemplos predefinidos */
.examples-section {
    margin: 15px 0;
}

.examples-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
}

.examples-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.example-btn {
    padding: 6px 12px;
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.example-btn:hover {
    background: linear-gradient(135deg, #2980b9, #1f5f8b);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
}

/* Estilos para historial */
.history-section {
    margin: 15px 0;
}

.history-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 120px;
    overflow-y: auto;
}

.history-item {
    padding: 8px 12px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item:hover {
    background: #e3f2fd;
    border-color: #3498db;
}

.history-item .remove-btn {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-item .remove-btn:hover {
    background: #c0392b;
}

/* Botón de exportar */
.btn-secondary {
    background: linear-gradient(135deg, #27ae60, #229954);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    margin-left: 10px;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #229954, #1e7e34);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(39, 174, 96, 0.3);
}

/* Responsive para móviles */
@media (max-width: 768px) {
    .examples-buttons {
        justify-content: center;
    }
    
    .example-btn {
        flex: 1;
        min-width: 80px;
    }
    
    .btn-secondary {
        margin-left: 0;
        margin-top: 10px;
        width: 100%;
    }
}

/* Mejoras adicionales para responsive */

/* Para tablets (max-width: 1024px) */
@media (max-width: 1024px) {
    .container {
        padding: 0 10px; /* Reducir padding en tablets */
    }
    
    .content-grid {
        grid-template-columns: 1fr 1fr; /* Mantener dos columnas en tablets, pero más compactas */
        gap: 1.5rem;
    }
    
    .function-input input {
        width: 60%; /* Ajustar input en tablets */
    }
    
    .range-controls {
        gap: 1rem;
    }
    
    .analysis-card {
        padding: 1rem; /* Reducir padding */
    }
    
    #functionChart {
        height: 300px; /* Altura fija para mejor control en tablets */
    }
}

/* Para móviles pequeños (max-width: 480px) */
@media (max-width: 480px) {
    body {
        font-size: 14px; /* Reducir tamaño de fuente general para móviles */
    }
    
    .header {
        padding: 0.5rem 0; /* Menos padding en header */
    }
    
    .logo h1 {
        font-size: 1.5rem;
    }
    
    .input-section {
        padding: 1rem; /* Padding más pequeño */
    }
    
    .function-input input {
        width: 100%; /* Input full-width */
        margin-right: 0;
        margin-bottom: 0.5rem;
    }
    
    .btn-primary {
        width: 100%; /* Botones full-width */
        padding: 0.7rem;
    }
    
    .range-controls {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .content-grid {
        grid-template-columns: 1fr; /* Una sola columna en móviles pequeños */
        gap: 1rem;
    }
    
    .toggle-btn {
        width: 28px;
        height: 28px; /* Botones más pequeños */
    }
    
    .history-item {
        font-size: 12px; /* Texto más pequeño en historial */
    }
    
    #functionChart {
        height: 250px; /* Altura ajustada para móviles */
    }
}