/* ==========================================================================
   mitemario.org - Estilos Principales
   ========================================================================== */

:root {
    /* Paleta de Colores Alegre e Infantil */
    --primary-color: #4A90E2;      /* Azul principal */
    --primary-hover: #357ABD;
    --secondary-color: #6C5CE7;    /* Púrpura secundario */
    --success-color: #00B894;      /* Verde acierto */
    --success-bg: #E6F9F5;
    --warning-color: #FDCB6E;      /* Amarillo aviso */
    --danger-color: #FF7675;       /* Rojo error */
    --danger-bg: #FFEAEA;
    
    /* Fondos y Asignaturas */
    --bg-main: #F4F7FE;
    --card-bg: #FFFFFF;
    --math-color: #00CEC9;
    --math-gradient: linear-gradient(135deg, #00CEC9 0%, #0984E3 100%);
    --lang-color: #FF7675;
    --science-color: #A29BFE;
    --english-color: #FD79A8;

    /* Textos y Bordes */
    --text-dark: #2D3436;
    --text-muted: #636E72;
    --border-color: #DFE6E9;
    --shadow-soft: 0 10px 25px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 15px 30px rgba(74, 144, 226, 0.15);
    
    /* Tipografía y Radios */
    --font-heading: 'Fredoka', cursive, sans-serif;
    --font-body: 'Nunito', sans-serif;
    --radius-large: 24px;
    --radius-medium: 16px;
    --radius-small: 10px;
}

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-main);
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   Encabezado / Header
   ========================================================================== */
.app-header {
    background: #FFFFFF;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.04);
    padding: 16px 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.brand-logo {
    font-size: 2.2rem;
    background: #EBF3FA;
    padding: 8px;
    border-radius: 16px;
}

.brand-text h1 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    color: var(--primary-color);
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.domain-dot {
    color: var(--secondary-color);
}

.brand-tagline {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

.breadcrumb-nav {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-muted);
}

.breadcrumb-nav a {
    color: var(--primary-color);
    text-decoration: none;
}

.breadcrumb-nav a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Contenedor Principal y Vistas
   ========================================================================== */
.main-container {
    max-width: 1000px;
    width: 90%;
    margin: 30px auto;
    flex: 1;
}

.view {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Tarjetas Generales y Botones
   ========================================================================== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-large);
    padding: 28px;
    box-shadow: var(--shadow-soft);
    border: 2px solid #F0F4F8;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: 14px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background-color: var(--primary-color);
    color: #FFFFFF;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 6px 16px rgba(74, 144, 226, 0.4);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: #FFFFFF;
}

.btn-secondary:hover {
    background-color: #5B4BC4;
}

.btn-success {
    background-color: var(--success-color);
    color: #FFFFFF;
    box-shadow: 0 4px 12px rgba(0, 184, 148, 0.3);
}

.btn-success:hover {
    background-color: #00A383;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-dark);
}

.btn-outline:hover {
    background: #F8FAFC;
    border-color: #CBD5E1;
}

.btn-disabled {
    background-color: #DFE6E9;
    color: #B2BEC3;
    cursor: not-allowed;
}

.btn-large {
    padding: 16px 32px;
    font-size: 1.25rem;
}

/* ==========================================================================
   Vista 1: Inicio / Asignaturas
   ========================================================================== */
.welcome-banner {
    text-align: center;
    margin-bottom: 32px;
}

.welcome-banner h2 {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.welcome-banner p {
    font-size: 1.1rem;
    color: var(--text-muted);
}

.subjects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
}

.subject-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 32px 20px;
    cursor: pointer;
}

.subject-card.active-subject:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-hover);
    border-color: var(--primary-color);
}

.subject-card.coming-soon {
    opacity: 0.75;
    cursor: default;
    background: #FAFCFE;
}

.card-badge {
    position: absolute;
    top: 16px;
    right: 16px;
    background: #E1F5FE;
    color: #0288D1;
    font-size: 0.75rem;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 20px;
    text-transform: uppercase;
}

.badge-soon {
    background: #F1F2F6;
    color: #747D8C;
}

.card-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.8rem;
    margin-bottom: 16px;
}

.math-bg { background: #E0F7FA; }
.lang-bg { background: #FFEBEE; }
.science-bg { background: #EDE7F6; }
.english-bg { background: #FCE4EC; }

.subject-card h3 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.subject-card p {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    flex: 1;
}

.card-btn {
    width: 100%;
}

/* ==========================================================================
   Vista 2: Menú de Matemáticas
   ========================================================================== */
.section-title {
    margin-bottom: 24px;
}

.section-title h2 {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--text-dark);
}

.activities-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 30px;
}

.activity-card {
    display: flex;
    align-items: center;
    padding: 20px 24px;
    gap: 20px;
    cursor: pointer;
}

.activity-card:hover {
    transform: translateX(6px);
    border-color: var(--math-color);
}

.activity-icon {
    font-size: 2.2rem;
    background: #E0F7FA;
    width: 60px;
    height: 60px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.activity-info {
    flex: 1;
}

.activity-info h3 {
    font-family: var(--font-heading);
    font-size: 1.3rem;
}

.activity-info p {
    font-size: 0.95rem;
    color: var(--text-muted);
}

.activity-arrow {
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: bold;
}

.badge-soon-pill {
    background: #F1F2F6;
    color: #747D8C;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 700;
}

/* ==========================================================================
   Vista 3: Configuración de Tablas
   ========================================================================== */
.config-card h2 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    color: var(--text-dark);
}

.config-subtitle {
    color: var(--text-muted);
    margin-bottom: 24px;
}

.config-group {
    margin-bottom: 28px;
}

.group-title {
    display: block;
    font-family: var(--font-heading);
    font-size: 1.15rem;
    margin-bottom: 14px;
    color: var(--text-dark);
}

.tables-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 10px;
}

.table-btn {
    background: #F8FAFC;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-medium);
    padding: 14px 8px;
    font-family: var(--font-heading);
    font-size: 1.25rem;
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.2s ease;
}

.table-btn:hover {
    border-color: var(--primary-color);
    background: #EBF3FA;
}

.table-btn.selected {
    background: var(--primary-color);
    color: #FFFFFF;
    border-color: var(--primary-color);
    box-shadow: 0 4px 10px rgba(74, 144, 226, 0.3);
}

.modes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.mode-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-medium);
    padding: 18px;
    cursor: pointer;
    background: #F8FAFC;
    position: relative;
    transition: all 0.2s ease;
}

.mode-card:hover {
    border-color: var(--secondary-color);
}

.mode-card.selected {
    border-color: var(--secondary-color);
    background: #F3F0FF;
}

.mode-icon {
    font-size: 1.8rem;
}

.mode-content h4 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.mode-content p {
    font-size: 0.88rem;
    color: var(--text-muted);
}

.radio-indicator {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #FFFFFF;
    font-size: 0.8rem;
}

.mode-card.selected .radio-indicator {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
}

.config-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 32px;
    gap: 16px;
}

/* ==========================================================================
   Vista 4: Ejercicio de Multiplicación
   ========================================================================== */
.exercise-card {
    max-width: 650px;
    margin: 0 auto;
    text-align: center;
}

.exercise-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.exercise-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-heading);
    font-size: 1.4rem;
}

.mode-tag {
    background: #F0EDFF;
    color: var(--secondary-color);
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 12px;
}

.exercise-stats {
    display: flex;
    gap: 16px;
}

.stat-box {
    font-size: 0.95rem;
    font-weight: 700;
}

.correct-color { color: var(--success-color); font-size: 1.1rem; }
.wrong-color { color: var(--danger-color); font-size: 1.1rem; }

/* Barra de progreso */
.progress-bar-container {
    width: 100%;
    height: 12px;
    background: #E2E8F0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #00CEC9, #00B894);
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 30px;
}

/* Operación */
.question-display {
    background: #FAF9FE;
    border: 3px dashed #E2E8F0;
    border-radius: var(--radius-large);
    padding: 36px 20px;
    margin-bottom: 24px;
}

.equation {
    font-family: var(--font-heading);
    font-size: 4rem;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 20px;
}

.operator, .equals {
    color: var(--secondary-color);
}

.answer-input {
    font-family: var(--font-heading);
    font-size: 3rem;
    width: 140px;
    text-align: center;
    padding: 10px;
    border: 3px solid var(--primary-color);
    border-radius: var(--radius-medium);
    outline: none;
    background: #FFFFFF;
    color: var(--text-dark);
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.15);
}

.answer-input:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.2);
}

/* Ocultar flechitas del input number */
.answer-input::-webkit-outer-spin-button,
.answer-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.answer-input[type=number] {
    -moz-appearance: textfield;
}

/* Banner de Feedback */
.feedback-banner {
    padding: 14px 20px;
    border-radius: var(--radius-medium);
    font-size: 1.2rem;
    font-weight: 800;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.feedback-banner.correct {
    background: var(--success-bg);
    color: #00876C;
    border: 2px solid #B2F2E5;
}

.feedback-banner.wrong {
    background: var(--danger-bg);
    color: #D63031;
    border: 2px solid #FFC9C9;
}

@keyframes popIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.shake {
    animation: shakeAnim 0.4s ease;
}

@keyframes shakeAnim {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-10px); }
    40%, 80% { transform: translateX(10px); }
}

.exercise-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

/* ==========================================================================
   Vista 5: Resultados / Resumen
   ========================================================================== */
.results-card {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}

.trophy-icon {
    font-size: 4rem;
    margin-bottom: 12px;
    animation: bounce 1s infinite alternate;
}

@keyframes bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-10px); }
}

.results-header h2 {
    font-family: var(--font-heading);
    font-size: 2.2rem;
}

.results-subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 20px;
}

.stars-container {
    display: flex;
    justify-content: center;
    gap: 12px;
    font-size: 2.5rem;
    margin-bottom: 24px;
}

.score-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 30px;
}

.summary-box {
    background: #F8FAFC;
    padding: 16px;
    border-radius: var(--radius-medium);
    border: 1px solid var(--border-color);
}

.summary-value {
    display: block;
    font-family: var(--font-heading);
    font-size: 1.8rem;
    color: var(--primary-color);
}

.summary-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 700;
}

.details-section {
    text-align: left;
    margin-bottom: 30px;
}

.details-section h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    margin-bottom: 12px;
}

.details-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 6px;
}

.detail-item {
    background: #FFFFFF;
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: var(--radius-small);
    font-size: 0.95rem;
    text-align: center;
    font-weight: bold;
}

.detail-item.item-correct {
    border-color: #B2F2E5;
    background: var(--success-bg);
    color: #00876C;
}

.detail-item.item-wrong {
    border-color: #FFC9C9;
    background: var(--danger-bg);
    color: #D63031;
}

.results-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.app-footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
    background: #FFFFFF;
    margin-top: 40px;
}

/* Responsivo */
@media (max-width: 600px) {
    .header-container {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .equation {
        font-size: 2.8rem;
    }
    
    .answer-input {
        font-size: 2.2rem;
        width: 110px;
    }
    
    .score-summary-grid {
        grid-template-columns: 1fr;
    }
    
    .config-actions, .exercise-actions {
        flex-direction: column-reverse;
    }
    
    .btn {
        width: 100%;
    }
}

/* Estilos específicos para el Modo Pro */
.mode-pro-card.selected {
    border-color: #FF7675;
    background: #FFF5F5;
}

.mode-pro-card.selected .radio-indicator {
    background: #D63031;
    border-color: #D63031;
}
