/* style.css - Curriculum Plan Template Editor Style */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #102E5C; /* UPEU Navy Blue */
    --primary-light: #eff4fb;
    --primary-hover: #081d3c;
    --accent-orange: #FDC82F; /* UPEU Gold/Yellow */
    --accent-orange-light: #fffcf0;
    --dark-bg: #0b182d; /* Dark Navy for editor panel */
    --light-bg: #f3f6fa; /* Slate 50 for content background */
    --border-color: #cbd5e1; /* Slate 300 */
    --text-main: #1e293b; /* Slate 800 */
    --text-muted: #64748b; /* Slate 500 */
    
    /* Competency Levels Colors */
    --level-1: #2ecc71; /* Initial - Green */
    --level-2: #ffd32a; /* Intermediate - Yellow */
    --level-3: #3498db; /* Expected - Blue */
    --level-4: #9b59b6; /* Final - Purple */
    
    --level-1-light: rgba(46, 204, 113, 0.15);
    --level-2-light: rgba(255, 211, 42, 0.15);
    --level-3-light: rgba(52, 152, 219, 0.15);
    --level-4-light: rgba(155, 89, 182, 0.15);
}

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

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    background-color: var(--light-bg);
    overflow-x: hidden;
    height: 100vh;
    display: flex;
}

/* Layout Structure */
#app-container {
    display: flex;
    width: 100%;
    height: 100vh;
}

/* Sidebar Controls Panel */
#editor-panel {
    width: 340px;
    background-color: var(--dark-bg);
    color: #f1f5f9;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    box-shadow: 4px 0 10px rgba(0,0,0,0.1);
    z-index: 10;
    flex-shrink: 0;
}

#editor-panel h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    border-bottom: 2px solid #334155;
    padding-bottom: 12px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-bottom: 1px solid #1e293b;
    padding-bottom: 16px;
}

.panel-section-title {
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

/* Styled Inputs & Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 6px;
    font-weight: 550;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    width: 100%;
    font-family: 'Outfit', sans-serif;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #334155;
    color: white;
    border: 1px solid #475569;
}

.btn-secondary:hover {
    background-color: #475569;
    color: #fff;
}

.btn-danger {
    background-color: #ef4444;
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.file-input-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
    width: 100%;
}

.file-input-wrapper input[type=file] {
    font-size: 100px;
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    cursor: pointer;
}

/* Preview Canvas Pane */
#preview-pane {
    flex-grow: 1;
    overflow-y: auto;
    padding: 40px 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* Document Page (Simulating A4 or custom layout) */
.document-page {
    width: 950px; /* High fidelity desktop width, fits details */
    background: white;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05), 0 2px 6px rgba(0,0,0,0.03);
    border-radius: 4px;
    padding: 30px;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-sizing: border-box;
}

/* Header Styles */
.doc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid var(--primary-color);
    padding-bottom: 12px;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-img {
    height: 48px;
    object-fit: contain;
}

.logo-text {
    font-family: 'Outfit', sans-serif;
    color: var(--text-main);
}

.logo-title {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1;
}

.logo-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 1px;
}

.header-banner-right {
    background-color: var(--primary-color);
    color: white;
    padding: 12px 24px;
    border-radius: 4px;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: 0.5px;
}

/* Top Sections Info Row */
.doc-top-info {
    display: grid;
    grid-template-columns: 1.2fr 1.8fr;
    gap: 30px;
}

.program-details {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.section-indicator {
    font-size: 0.75rem;
    color: var(--primary-color);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.section-indicator::before {
    content: "▲";
    font-size: 0.6rem;
}

.program-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--primary-color);
    line-height: 1.1;
    margin-top: 2px;
}

.program-subtitle {
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.competencies-info {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.competency-group-title {
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 6px;
}

.competency-group-title::before {
    content: "•";
    color: var(--primary-color);
    font-size: 1.2rem;
}

.competency-list {
    list-style: none;
    padding-left: 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.competency-list li {
    font-size: 0.75rem;
    color: var(--text-main);
    line-height: 1.2;
}

.competency-list li span {
    font-weight: 600;
}

/* Certificaciones and illustration area */
.right-info-block {
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: #fafafa;
    border-radius: 6px;
    padding: 15px;
    border: 1px solid #f1f5f9;
}

.right-title {
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary-color);
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 4px;
}

.certifications-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.certifications-list li {
    font-size: 0.7rem;
    line-height: 1.3;
}

.cert-num {
    font-weight: 700;
    color: var(--primary-color);
}

.cert-desc {
    font-weight: 600;
}

.cert-cond {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-style: italic;
    display: block;
}

/* Legend section */
.legend-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background-color: #fff;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}

.legend-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    font-weight: 600;
}

.legend-color-box {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.1);
}

.color-l1 { background-color: var(--level-1); }
.color-l2 { background-color: var(--level-2); }
.color-l3 { background-color: var(--level-3); }
.color-l4 { background-color: var(--level-4); }

.legend-text-row {
    display: flex;
    gap: 15px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.legend-text-item span {
    font-weight: 700;
    color: var(--text-main);
}

/* Curriculum Table Styles */
.table-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.curriculum-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

/* Headers */
.curriculum-table th {
    border: 1px solid var(--border-color);
    background-color: var(--primary-color);
    color: white;
    font-weight: 700;
    text-align: center;
    padding: 6px;
}

.curriculum-table th.table-header-prereq {
    background-color: var(--accent-orange);
    color: #1e293b;
}

.curriculum-table th.header-group-title {
    background-color: #0b1a33;
    font-family: 'Outfit', sans-serif;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    padding: 4px;
}

/* Vertical Text Header Cell */
.vertical-header-cell {
    position: relative;
    height: 150px;
    min-width: 25px;
    max-width: 32px;
    vertical-align: bottom;
    padding: 0 !important;
}

.vertical-text-wrapper {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    white-space: nowrap;
    text-align: left;
    font-size: 0.65rem;
    font-weight: 600;
    line-height: 1.1;
    display: inline-block;
    width: 100%;
    padding: 10px 4px;
    box-sizing: border-box;
}

/* Rows & Cells */
.curriculum-table td {
    border: 1px solid var(--border-color);
    padding: 4px 6px;
    vertical-align: middle;
}

/* Ciclo Header Row */
.ciclo-header-row {
    background-color: #1a355e;
    color: white;
}

.ciclo-header-row td {
    padding: 6px 10px !important;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}

.ciclo-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ciclo-title-edit {
    cursor: text;
}

/* Course Styling */
.course-row {
    transition: background-color 0.15s ease;
}

.course-row:hover {
    background-color: #f8fafc;
}

.course-name-cell {
    font-weight: 500;
    min-width: 220px;
}

.text-center {
    text-align: center;
}

/* Competency Grid Cells */
.comp-cell {
    text-align: center;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s ease;
    padding: 0 !important;
    width: 28px;
    height: 28px;
}

.comp-cell:hover {
    filter: brightness(0.95);
    background-color: #e2e8f0;
}

.comp-val-1 { background-color: var(--level-1); color: #1e293b; }
.comp-val-2 { background-color: var(--level-2); color: #1e293b; }
.comp-val-3 { background-color: var(--level-3); color: white; }
.comp-val-4 { background-color: var(--level-4); color: white; }

/* Prerequisite Cell */
.prereq-cell {
    font-size: 0.7rem;
    color: var(--text-main);
    background-color: var(--accent-orange-light);
    max-width: 140px;
}

/* Inline Editable indicators */
[contenteditable="true"] {
    outline: none;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background-color 0.2s;
}

[contenteditable="true"]:hover {
    background-color: #f1f5f9;
    box-shadow: 0 0 0 1px #cbd5e1;
}

[contenteditable="true"]:focus {
    background-color: #fff;
    box-shadow: 0 0 0 2px var(--primary-color);
}

/* Evitar texto invisible (blanco sobre blanco) en elementos editables sobre fondo oscuro */
.header-banner-right[contenteditable="true"]:hover,
.header-banner-right[contenteditable="true"]:focus {
    background-color: var(--primary-color) !important;
    color: white !important;
    box-shadow: 0 0 0 2px var(--accent-orange) !important;
}

.ciclo-title-edit[contenteditable="true"]:hover,
.ciclo-title-edit[contenteditable="true"]:focus {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: white !important;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3) !important;
}

/* Row Action Buttons (Delete, Add) */
.course-row {
    position: relative;
}

.action-cell {
    display: flex;
    gap: 4px;
    justify-content: center;
    border: none !important;
    padding: 0 !important;
}

.row-action-btn {
    opacity: 0;
    cursor: pointer;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 2px 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.course-row:hover .row-action-btn {
    opacity: 1;
}

.row-action-btn:hover {
    color: #ef4444;
    background-color: #fee2e2;
}

.add-course-row {
    background-color: #f8fafc;
}

.add-course-btn {
    color: var(--primary-color);
    background: none;
    border: 1px dashed var(--primary-color);
    padding: 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.add-course-btn:hover {
    background-color: var(--primary-light);
    border-style: solid;
}

.cycle-actions {
    display: flex;
    gap: 8px;
}

.cycle-action-btn {
    color: white;
    background: rgba(255,255,255,0.15);
    border: none;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.65rem;
    cursor: pointer;
    transition: all 0.2s;
}

.cycle-action-btn:hover {
    background-color: rgba(255,255,255,0.3);
}

.cycle-action-btn.btn-delete:hover {
    background-color: #ef4444;
}

/* Certifications inside table as labels */
.cert-row {
    background-color: #f1f5f9;
}

.cert-cell {
    padding: 6px 10px !important;
    font-weight: 700;
    font-size: 0.7rem;
    color: var(--primary-color);
    border-top: 2px solid var(--border-color);
    border-bottom: 2px solid var(--border-color);
}

/* Modal Selector for Competencies (Quick Tooltip Popup) */
.comp-selector-popup {
    position: fixed;
    background: white;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    gap: 6px;
    z-index: 1000;
    animation: popupFade 0.15s ease-out;
}

@keyframes popupFade {
    from { opacity: 0; transform: scale(0.95) translateY(-5px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.selector-option {
    width: 26px;
    height: 26px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    cursor: pointer;
    border: 1px solid rgba(0,0,0,0.1);
    transition: transform 0.1s;
}

.selector-option:hover {
    transform: scale(1.1);
}

.selector-option.opt-0 { background: #fff; color: var(--text-muted); }
.selector-option.opt-1 { background: var(--level-1); color: #1e293b; }
.selector-option.opt-2 { background: var(--level-2); color: #1e293b; }
.selector-option.opt-3 { background: var(--level-3); color: white; }
.selector-option.opt-4 { background: var(--level-4); color: white; }

/* Help Box */
.help-box {
    background-color: #1e293b;
    border: 1px dashed #475569;
    padding: 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    line-height: 1.4;
    color: #cbd5e1;
}

.help-box h3 {
    font-family: 'Outfit', sans-serif;
    color: white;
    font-size: 0.8rem;
    margin-bottom: 6px;
}

.help-box ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.help-box li::before {
    content: "⚡ ";
}

/* Print CSS Stylesheet override */
@media print {
    @page {
        size: A4 portrait;
        margin: 10mm 15mm; /* Márgenes físicos de página de 10mm arriba/abajo y 15mm a los lados */
    }

    body {
        background-color: white !important;
        color: black !important;
        overflow: visible !important;
        height: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
    }
    
    #app-container {
        display: block !important;
        height: auto !important;
        width: 100% !important;
    }
    
    #editor-panel, .no-print {
        display: none !important;
    }
    
    #preview-pane {
        padding: 0 !important;
        margin: 0 !important;
        overflow: visible !important;
        display: block !important;
        width: 100% !important;
    }
    
    .document-page {
        width: 950px !important; /* Mantiene el ancho del lienzo de la pantalla */
        box-shadow: none !important;
        padding: 0 !important;
        border-radius: 0 !important;
        border: none !important;
        margin: 0 auto !important;
        /* Escalamos el documento al 82% para que quepa perfectamente y esté centrado */
        transform: scale(0.82);
        transform-origin: top center;
    }
    
    [contenteditable="true"]:hover {
        background-color: transparent !important;
        box-shadow: none !important;
    }
    
    [contenteditable="true"]:focus {
        background-color: transparent !important;
        box-shadow: none !important;
    }
    
    /* Ensure table borders and background colors print correctly */
    .curriculum-table th, .curriculum-table td, .ciclo-header-row, .vertical-header-cell {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    .comp-cell, .color-l1, .color-l2, .color-l3, .color-l4,
    .comp-val-1, .comp-val-2, .comp-val-3, .comp-val-4 {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Evita que la cabecera (thead) de la tabla se repita en las siguientes páginas */
    .curriculum-table thead {
        display: table-row-group !important;
    }
}

/* ==========================================
   FASE 2: ESTILOS DE AUTENTICACIÓN Y ADMIN PANEL
   ========================================== */

/* Login Overlay and Card */
#login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(11, 24, 45, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.login-card {
    background: #ffffff;
    padding: 35px 30px;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.08);
    width: 420px;
    max-width: 90%;
    display: flex;
    flex-direction: column;
    color: var(--text-main);
}

.login-logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}

.login-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 6px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 15px;
}

.form-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input {
    padding: 10px 14px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-main);
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(16, 46, 92, 0.15);
}

/* User Card inside Sidebar Admin List */
.admin-user-card {
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid #1e293b;
    border-radius: 6px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all 0.2s;
}

.admin-user-card:hover {
    background-color: rgba(255, 255, 255, 0.04);
    border-color: #334155;
}

.admin-user-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-user-email {
    font-weight: 700;
    font-size: 0.75rem;
    color: #f1f5f9;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 180px;
}

.admin-user-plan-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-saved {
    background-color: #48bb78; /* Green */
    box-shadow: 0 0 6px #48bb78;
}

.status-empty {
    background-color: #718096; /* Grey */
}

.admin-user-details {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    color: #94a3b8;
}

.admin-user-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.admin-action-btn {
    padding: 4px 8px;
    font-size: 0.65rem;
    border-radius: 4px;
    cursor: pointer;
    border: none;
    font-weight: 600;
    transition: all 0.15s;
    font-family: 'Inter', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-grow: 1;
}

.btn-inspect {
    background-color: #1a355e;
    color: #93c5fd;
    border: 1px solid #2563eb;
}

.btn-inspect:hover {
    background-color: #2563eb;
    color: white;
}

.btn-delete-user {
    background-color: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.btn-delete-user:hover {
    background-color: #ef4444;
    color: white;
}

/* ==========================================
   BOTONES DE AGREGAR / ELIMINAR ELEMENTOS INLINE
   ========================================== */
.add-item-btn {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: #48bb78;
    color: white;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: all 0.2s ease;
    padding: 0;
    margin-left: 8px;
}

.add-item-btn:hover {
    background-color: #38a169;
    transform: scale(1.15);
}

.delete-item-btn {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: transparent;
    color: #ef4444;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: bold;
    cursor: pointer;
    opacity: 0.4;
    transition: all 0.2s ease;
    padding: 0;
}

.delete-item-btn:hover {
    opacity: 1;
    background-color: rgba(239, 68, 68, 0.1);
    transform: scale(1.15);
}
