/* =========================================
   PLAN ESTRATÉGICO DE ESTUDIOS - CSS MAESTRO
   ========================================= */
:root {
    --uja-red: #A6192E;
    --text-main: #333333;
    --bg-color: #f4f6f8;
    --paper-color: #ffffff;
    --accent-blue: #0056b3;
    --accent-green: #28a745;
    --uja-gold: #FFD700;
}

/* --- REGLAS BASE (Móvil Primero) --- */
body {
    font-family: '-apple-system', BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    margin: 0;
    padding: 15px 10px;
}

.document-container {
    width: 100%;
    box-sizing: border-box;
    background-color: var(--paper-color);
    padding: 25px 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    border-radius: 12px;
}

h1, h2, h3, h4 { font-family: 'Arial', sans-serif; color: var(--uja-red); line-height: 1.2; }
h1 { text-align: center; border-bottom: 3px solid var(--uja-red); padding-bottom: 15px; margin-bottom: 30px; font-size: 1.6em; }
h2 { border-bottom: 1px solid #ccc; padding-bottom: 5px; margin-top: 35px; font-size: 1.3em; }

.phase-title { background-color: #e9ecef; padding: 10px; border-radius: 6px; text-align: center; font-size: 1.1em; color: #444; margin-top: 40px;}

/* --- CAJAS DE CONTENIDO --- */
.chuleta-box {
    background-color: #fffbcc; border: 2px dashed #f1c40f; padding: 15px; margin: 20px 0; border-radius: 8px; font-size: 0.95em;
}
.chuleta-box h4 { margin-top: 0; color: #b8860b; font-weight: bold; margin-bottom: 10px; }

.prereq-box { background-color: #e8f4f8; border-left: 4px solid var(--accent-blue); padding: 15px; margin: 20px 0; font-size: 0.9em; border-radius: 0 8px 8px 0; }
.concept-box { background-color: #f8f9fa; border-left: 4px solid var(--uja-red); padding: 15px; margin: 20px 0; border-radius: 0 8px 8px 0; }

.math-block {
    overflow-x: auto; text-align: center; margin: 20px 0; padding: 15px; background-color: #fdfdfd; border-radius: 6px; border: 1px solid #eee; font-size: 0.9em;
}

/* --- GRILLAS Y TARJETAS --- */
.day-grid { display: grid; grid-template-columns: 1fr; gap: 15px; margin-top: 20px; }
.day-card {
    background-color: #f8f9fa; border: 1px solid #ddd; border-left: 6px solid var(--uja-red); padding: 20px; border-radius: 8px; text-decoration: none; color: inherit; transition: background-color 0.2s; display: block;
}
.day-card:active { background-color: #e2e6ea; }
.day-card h3 { margin-top: 0; margin-bottom: 8px; font-size: 1.2em; }
.day-card p { margin: 0; font-size: 0.9em; color: #555; }

/* --- BOTONES Y NAVEGACIÓN --- */
.sub-buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 15px; }
.sub-btn { text-align: center; background-color: #f0f0f0; border: 1px solid #ccc; padding: 12px; border-radius: 6px; text-decoration: none; color: var(--uja-red); font-size: 0.95em; font-weight: bold; }
.nav-buttons { display: flex; flex-direction: column; gap: 15px; margin-top: 40px; border-top: 1px solid #ccc; padding-top: 20px; }
.btn { text-decoration: none; background-color: var(--uja-red); color: white; padding: 12px 20px; border-radius: 6px; font-weight: bold; text-align: center; cursor: pointer; border: none; }
.btn-action { background-color: var(--accent-green); display: block; text-align: center; margin: 20px 0; padding: 14px; border-radius: 6px; }

footer { font-size: 0.8em; color: #666; text-align: justify; line-height: 1.4; margin-top: 40px; }

/* --- ESCRITORIO --- */
@media (min-width: 768px) {
    body { padding: 40px 20px; }
    .document-container { max-width: 850px; margin: 0 auto; padding: 50px 70px; }
    .day-grid { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 25px; }
    .nav-buttons { flex-direction: row; justify-content: space-between; }
    .btn:hover, .sub-btn:hover { transform: translateY(-2px); opacity: 0.9; }
    .day-card:hover { transform: translateY(-5px); box-shadow: 0 5px 15px rgba(0,0,0,0.1); background-color: #fff; }
}

/* =========================================
   REGLAS DE IMPRESIÓN PROFESIONAL (PDF)
   ========================================= */
@media print {
    /* 1. Limpieza total */
    body { background-color: white !important; color: black !important; padding: 0 !important; }
    .nav-buttons, .btn, .sub-buttons, .sub-btn, .btn-action { display: none !important; }
    .document-container { 
        box-shadow: none !important; max-width: 100% !important; 
        padding: 0 !important; margin: 0 !important; border: none !important;
    }

    /* 2. SUPERPEGAMENTO: Títulos siempre unidos a su contenido */
    h1, h2, h3, h4, h5 {
        display: block !important;
        page-break-after: avoid !important;
        break-after: avoid-page !important; /* Estándar moderno */
        margin-bottom: 5px !important;
    }

    /* 3. BLOQUES ATÓMICOS: No se parten a la mitad */
    .chuleta-box, .concept-box, .math-block, .prereq-box, .day-card { 
        display: block !important;
        page-break-inside: avoid !important; 
        break-inside: avoid !important;
        border: 1px solid #eee !important; 
        background-color: transparent !important;
        margin-bottom: 1.5em !important;
    }

    /* 4. Saltos de página lógicos */
    h1 { 
        page-break-before: always !important; 
        break-before: page !important;
        margin-top: 0 !important;
    }

    /* 5. Evitar líneas huérfanas en párrafos */
    p, li { 
        widows: 3; 
        orphans: 3; 
    }
}