/* PROYECTO: catalogo-cttc-senati 
   ESTILO: Enterprise Professional 2026 (Full Version)
*/

:root {
    --bg-app: #f8fafc;
    --bg-card: #ffffff;
    --primary-green: #10b981; 
    --primary-dark: #064e3b;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --senati-blue: #0054a6;
    --info-blue: #0ea5e9;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    line-height: 1.5;
}

/* --- NAVEGACIÓN --- */
.navbar {
    background: var(--bg-card);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand { font-size: 1.25rem; font-weight: 800; color: var(--primary-dark); }
.brand span { color: var(--primary-green); }

/* --- HEADER / NAV ACTIONS (botones a la derecha) --- */
.nav-actions { display:flex; align-items:center; gap:12px; }
.u-name { font-weight:700; color: var(--text-muted); font-size: 0.95rem; padding: 6px 10px; border-radius: 8px; }

/* Botón principal (Ver Vista Pública) */
.nav-actions .btn-primary { background: var(--senati-blue); color: white; padding: 8px 12px; border-radius: 8px; border: none; font-weight: 600; cursor: pointer; }
.nav-actions .btn-primary:hover { filter: brightness(0.95); }

/* Botón de cierre de sesión */
.nav-actions .btn-delete { background: transparent; border: 1px solid var(--border-color); color: var(--text-muted); padding: 6px 10px; border-radius: 8px; cursor: pointer; }
.nav-actions .btn-delete:hover { background: #fff; box-shadow: var(--shadow); }

/* --- SISTEMA DE PESTAÑAS --- */
/* Contenedor principal de controles */
.controls-wrapper {
    background: #ffffff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    margin-bottom: 25px;
    border: 1px solid #e2e8f0;
}

/* Grilla para los filtros */
.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    align-items: center;
}

/* Estilo para los selects y el input de búsqueda */
.custom-select, 
.search-input {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background-color: #f8fafc;
    color: #334155;
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    transition: all 0.3s ease;
    outline: none;
}

/* Efecto Focus para resaltar el filtro activo */
.custom-select:focus, 
.search-input:focus {
    border-color: #0ea5e9;
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.2);
}

/* Estilo específico para el input de búsqueda */
.search-input {
    background-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%2364748b"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path></svg>');
    background-repeat: no-repeat;
    background-position: 12px center;
    background-size: 18px;
    padding-left: 40px;
}

/* Labels informativos opcionales (si decides agregarlos al HTML) */
.filter-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* Responsividad para móviles */
@media (max-width: 768px) {
    .filters {
        grid-template-columns: 1fr; /* Un filtro por fila en celulares */
    }
}

.tabs-navigation {
    display: flex;
    background: #e2e8f0;
    padding: 4px;
    border-radius: 10px;
}

.tab-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 8px;
    font-weight: 600;
    color: var(--text-muted);
    transition: 0.3s;
}

.tab-btn.active {
    background: white;
    color: var(--primary-green);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.4s ease; }

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

/* --- TARJETAS DE PROGRAMAS --- */
.programa-card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.prog-header {
    border-bottom: 2px solid var(--bg-app);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.prog-header h3 { color: var(--senati-blue); font-size: 1.1rem; }

.sub-table { 
    width: 100%; 
    border-collapse: collapse; 
    font-size: 0.85rem; 
}

.sub-table th { background: #f8fafc; color: var(--text-muted); padding: 10px; }
.sub-table td { padding: 10px; border-bottom: 1px solid #f1f5f9; }

/* --- COMPONENTES DE TABLA --- */
.table-container {
    background: var(--bg-card); 
    border-radius: 12px;
    border: 1px solid var(--border-color); 
    overflow: hidden;
    margin-top: 1rem;
}

table { width: 100%; border-collapse: collapse; }
th { background: #f1f5f9; padding: 1rem; text-align: left; font-size: 0.75rem; text-transform: uppercase; color: var(--text-muted); }
td { padding: 1rem; border-bottom: 1px solid var(--border-color); font-size: 0.875rem; }

/* Indicadores de Estado (SINFO) */
.status-dot {
    height: 10px;
    width: 10px;
    border-radius: 50%;
    display: inline-block;
}
.status-dot.green { background-color: #10b981; box-shadow: 0 0 8px #10b981; }
.status-dot.gray { background-color: #cbd5e1; }

/* --- BOTONES Y FORMULARIOS --- */
.btn-primary, .btn-save {
    background: var(--primary-green);
    color: white; border: none; padding: 0.6rem 1.2rem;
    border-radius: 8px; font-weight: 600; cursor: pointer;
    transition: filter 0.2s;
}

.btn-primary:hover, .btn-save:hover { filter: brightness(0.9); }

.btn-dia {
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    background-color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    color: #334155;
}

.btn-dia.active {
    background-color: #22c55e !important;
    color: white !important;
    border-color: #166534;
    font-weight: bold;
}

/* --- ACCIONES MASIVAS (EXCEL) --- */
.bulk-actions {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    border: 1px dashed var(--primary-green);
}

.button-group-row {
    display: flex;
    gap: 10px;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.btn-secondary {
    background: #64748b;
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

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

.btn-link-download {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}

.btn-link-download:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

/* Estilos de Guía Informativa de Importación */
.import-guide {
    margin-top: 15px;
    padding: 12px;
    background: #f1f5f9;
    border-radius: 8px;
    font-size: 11px;
    color: #475569;
    border-left: 4px solid var(--info-blue);
}

.import-guide strong { color: var(--text-main); }

.import-guide ul {
    margin-left: 18px;
    margin-top: 5px;
}

.info-tag {
    font-size: 12px;
    color: var(--info-blue);
    cursor: help;
    font-weight: 600;
}

/* --- ADMINISTRACIÓN --- */
.admin-content { 
    max-width: 1200px; 
    margin: 2rem auto; 
    padding: 0 1rem; 
}

.form-container { 
    background: white; 
    padding: 2.5rem; 
    border-radius: 16px; 
    border: 1px solid var(--border-color); 
    box-shadow: var(--shadow);
}

.form-grid-two-columns {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.field-group { 
    display: flex; 
    flex-direction: column; 
    margin-bottom: 0.5rem;
}

.field-group label { 
    font-size: 0.75rem; 
    font-weight: 700; 
    color: var(--text-muted); 
    margin-bottom: 0.4rem; 
    text-transform: uppercase;
}

.field-group input, 
.field-group select { 
    padding: 0.75rem; 
    border-radius: 8px; 
    border: 1px solid var(--border-color); 
    background: #f9fafb; 
    font-family: inherit;
    font-size: 0.9rem;
}

/* --- MODALES --- */
.modal { 
    position: fixed; inset: 0; background: rgba(0,0,0,0.5); 
    display: flex; align-items: center; justify-content: center; z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content.small { 
    background: white; 
    padding: 2rem; 
    border-radius: 20px; 
    width: 90%; 
    max-width: 400px; 
}

/* --- UTILIDADES --- */
.hidden { display: none !important; }
.shadow { box-shadow: var(--shadow); }

@media (max-width: 768px) {
    .controls-wrapper { flex-direction: column; align-items: stretch; }
    .form-grid-two-columns { grid-template-columns: 1fr; }
    .button-group-row { flex-direction: column; }
    .button-group-row button, .button-group-row label { width: 100%; text-align: center; }
}
/* Optimización para 8 columnas */
table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
}

/* Solo las tablas de gestión/datos masivos mantienen el scroll horizontal */
.table-container table {
    min-width: 1200px;
}

th, td {
    padding: 12px 15px;
    font-size: 0.85rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: #f1f5f9;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 1px 0 var(--border-color);
}

.child-row-style td:first-child {
    padding-left: 2rem;
}

/* Estilo para ocultar las filas */
.hidden-row {
    display: none !important;
}

/* Botón de expandir: más claramente clicable */
.expand-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 0 6px;
}

/* Estilo para las filas de módulos (hijos) */
.child-row-style {
    background-color: #f9fafb; /* Color ligeramente distinto */
}

.child-row-style td:first-child {
    padding-left: 2rem; /* Indentación para efecto de jerarquía */
    border-left: 4px solid var(--primary-green);
}

/* Mejoras de UI: columna de acciones sticky y botones más grandes */
.actions-col {
    position: -webkit-sticky; /* Safari */
    position: sticky;
    right: 0;
    background: white;
    z-index: 2;
}

.actions-th {
    position: -webkit-sticky; /* Safari */
    position: sticky;
    right: 0;
    background: #f1f5f9;
    z-index: 20;
}

.action-button {
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid transparent;
    margin: 0 4px;
    cursor: pointer;
    font-size: 0.95rem;
    background: #ffffff;
}

.action-button:hover { filter: brightness(0.98); }

.action-button.delete { background: #fee2e2; border-color: #fca5a5; }

.expand-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 800;
    color: var(--text-muted);
    margin-right: 8px;
}

/* Aumentar click target de las filas */
tr td { padding: 14px 12px; }


.prog-master-row:hover {
    background-color: #f1f5f9;
}

/* Estilo para los 3 registros más próximos */
.highlight-urgent {
    background-color: #fffbeb !important; /* Un fondo crema muy suave */
    border-left: 5px solid #f59e0b !important; /* Borde naranja brillante */
    position: relative;
}

.highlight-urgent td:first-child {
    color: #d97706;
    font-weight: 800;
    animation: pulse-text 2s infinite;
}

.highlight-urgent::after {
    content: "🔥 ¡Inicia pronto!";
    position: absolute;
    right: 10px;
    top: 5px;
    font-size: 10px;
    background: #f59e0b;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
}

@keyframes pulse-text {
    0% { opacity: 1; }
    50% { opacity: 0.6; }
    100% { opacity: 1; }
}

.multi-docente-container select {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #ffffff;
}

.multi-docente-container select option {
    padding: 8px;
    border-bottom: 1px solid #f1f5f9;
}

/* ESTILOS PARA SECCIONES COLLAPSIBLES */
.section-header-collapsible {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: #f1f5f9;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    user-select: none;
    transition: background 0.3s ease;
}

.section-header-collapsible:hover {
    background: #e2e8f0;
}

.section-header-collapsible h2 {
    font-size: 1.25rem;
    color: var(--text-main);
    margin: 0;
}

.toggle-icon {
    font-size: 1.2rem;
    color: var(--text-muted);
    transition: transform 0.3s ease;
    display: inline-block;
}

.section-content {
    padding: 20px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
    opacity: 1;
}

/* ESTILOS PARA INPUTS DE FECHA EN TABLA */
.fecha-modulo-inicio,
.fecha-modulo-fin {
    padding: 6px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    transition: all 0.3s ease;
}

.fecha-modulo-inicio:hover:not(:disabled),
.fecha-modulo-fin:hover:not(:disabled) {
    border-color: #0ea5e9;
    box-shadow: 0 0 4px rgba(14, 165, 233, 0.3);
}

.fecha-modulo-inicio:focus,
.fecha-modulo-fin:focus {
    outline: none;
    border-color: #0ea5e9;
    box-shadow: 0 0 8px rgba(14, 165, 233, 0.4);
}

.fecha-modulo-fin:disabled {
    background: #f1f5f9;
    color: #64748b;
    cursor: not-allowed;
    opacity: 0.7;
}

/* --- HORARIO BLOQUES --- */
.horario-bloque {
    margin-bottom: 15px !important;
    display: block !important;
    clear: both !important;
    position: relative;
    z-index: auto;
}

/* Quitar la flecha por defecto de summary en Chrome/Safari */
summary::-webkit-details-marker {
    display: none;
}

/* Rotar icono al abrir */
details[open] summary span:last-child {
    transform: rotate(180deg);
}

/* Efecto hover en las opciones del desplegable */
#empresaCheckboxContainer label:hover {
    background-color: #f1f5f9;
}

/* --- DASHBOARD --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 2rem;
}

/* El Resumen General ocupa todo el ancho para dar espacio a las columnas de metas */
.dashboard-grid .report-card:first-child {
    grid-column: 1 / -1;
}

.report-card {
    background: #f9fafb;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.report-card h3 {
    font-size: 1.1rem;
    color: var(--senati-blue);
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.report-table {
    width: 100%;
    font-size: 0.85rem;
    border-collapse: collapse;
    min-width: auto !important; /* Fuerza el ajuste al contenedor de la tarjeta */
}

.report-table th, .report-table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
}

.report-table tfoot td {
    font-weight: bold;
    background: #f0f9ff;
    border-bottom: none;
}