/* =============================================================================
   SiGeCu — custom.css
   Overrides mínimos sobre Bootstrap 5.3.
   Paleta: azul institucional UNICACH + estados semáforo para revisión.
   Sin scroll horizontal en ninguna resolución.
   ============================================================================= */

/* ── Variables de color ────────────────────────────────────────────────────── */
:root {
    --sg-azul:        #1A4B8C;   /* Azul UNICACH institucional */
    --sg-azul-hover:  #153d73;
    --sg-azul-claro:  #EBF1FA;
    --sg-verde:       #1a7a4a;   /* Estado: aprobado */
    --sg-verde-bg:    #d4edda;
    --sg-ambar:       #856404;   /* Estado: en revisión */
    --sg-ambar-bg:    #fff3cd;
    --sg-rojo:        #842029;   /* Estado: requiere corrección */
    --sg-rojo-bg:     #f8d7da;
    --sg-gris-borde:  #dee2e6;   /* Estado: pendiente */
    --sg-gris-fondo:  #f8f9fa;
    --sg-radio:       6px;
    --sg-sombra:      0 1px 3px rgba(0,0,0,.08);
}

/* ── Base ──────────────────────────────────────────────────────────────────── */
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: .9rem;
    overflow-x: hidden;     /* Sin scroll horizontal bajo ninguna circunstancia */
}

* {
    box-sizing: border-box;
    word-break: break-word; /* Evita desbordamiento de texto largo */
}

/* ── Navbar ─────────────────────────────────────────────────────────────────── */
.sigecu-navbar {
    background: linear-gradient(135deg, var(--sg-azul) 0%, #2563b0 100%);
    box-shadow: 0 2px 8px rgba(0,0,0,.18);
}

.sigecu-navbar .nav-link {
    color: rgba(255,255,255,.8) !important;
    font-size: .85rem;
    padding: .4rem .8rem;
    border-radius: var(--sg-radio);
    transition: background .15s, color .15s;
}
.sigecu-navbar .nav-link:hover,
.sigecu-navbar .nav-link.active {
    background: rgba(255,255,255,.15);
    color: #fff !important;
}

.sigecu-logo-icon {
    background: rgba(255,255,255,.15);
    border-radius: 8px;
    padding: 4px 7px;
}

.sigecu-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255,255,255,.25);
    font-size: .8rem;
    font-weight: 700;
    color: #fff;
}

.sigecu-btn-usuario {
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.25);
    color: #fff;
    font-size: .8rem;
}
.sigecu-btn-usuario:hover {
    background: rgba(255,255,255,.2);
    color: #fff;
}

/* ── Chips de estadísticas ─────────────────────────────────────────────────── */
.sigecu-stat-chip {
    display: inline-flex;
    align-items: center;
    background: #fff;
    border: 1px solid var(--sg-gris-borde);
    border-radius: 20px;
    padding: .25rem .75rem;
    font-size: .8rem;
    color: #495057;
    box-shadow: var(--sg-sombra);
}

/* ── Acordeón de funciones ─────────────────────────────────────────────────── */
.sigecu-funcion {
    border-radius: var(--sg-radio) !important;
    overflow: hidden;
    border-left: 4px solid var(--sg-gris-borde) !important;
    transition: border-color .2s;
}

.sigecu-acordeon-funcion {
    background: #fff;
    font-size: .875rem;
    border-radius: 0 !important;
}
.sigecu-acordeon-funcion:not(.collapsed) {
    background: var(--sg-azul-claro);
    color: var(--sg-azul);
}
.sigecu-acordeon-funcion:focus {
    box-shadow: 0 0 0 .2rem rgba(26,75,140,.2);
}

/* ── Acordeón de tareas ────────────────────────────────────────────────────── */
.sigecu-tarea {
    border-left: 3px solid var(--sg-gris-borde) !important;
    border-radius: 4px !important;
    background: #fff;
    margin-left: .5rem;
    transition: border-color .2s;
}

.sigecu-acordeon-tarea {
    background: #fdfdfd;
    font-size: .84rem;
}
.sigecu-acordeon-tarea:not(.collapsed) {
    background: #f0f4fb;
}

/* ── Lista de operaciones ─────────────────────────────────────────────────── */
.sigecu-lista-operaciones {
    margin-left: .5rem;
}

.sigecu-operacion {
    border-left: 3px solid var(--sg-gris-borde);
    border-radius: 4px !important;
    margin-bottom: 2px;
    font-size: .83rem;
    transition: border-color .2s, background .15s;
}
.sigecu-operacion:hover {
    background: var(--sg-azul-claro);
}

/* ── Códigos ─────────────────────────────────────────────────────────────────── */
.sigecu-codigo-f {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 26px;
    background: var(--sg-azul);
    color: #fff;
    border-radius: 5px;
    font-size: .78rem;
    font-weight: 700;
    padding: 0 8px;
    letter-spacing: .02em;
    flex-shrink: 0;
}

.sigecu-codigo-t {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 22px;
    background: #2563b0;
    color: #fff;
    border-radius: 4px;
    font-size: .75rem;
    font-weight: 600;
    padding: 0 7px;
    flex-shrink: 0;
}

.sigecu-codigo-o {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 20px;
    background: var(--sg-gris-fondo);
    color: #495057;
    border: 1px solid var(--sg-gris-borde);
    border-radius: 3px;
    font-size: .75rem;
    font-weight: 600;
    padding: 0 6px;
    flex-shrink: 0;
}

/* ── Descripción truncada en el acordeón (se expande al abrir) ─────────────── */
.sigecu-desc-funcion {
    font-size: .84rem;
    min-width: 0; /* Necesario para que text-truncate funcione en flex */
}

/* ── Bordes de estado (semáforo) ─────────────────────────────────────────────── */
.borde-aprobado    { border-left-color: var(--sg-verde) !important; }
.borde-revision    { border-left-color: #f0ad4e !important; }
.borde-correccion  { border-left-color: var(--sg-rojo) !important; }
.borde-pendiente   { border-left-color: var(--sg-gris-borde) !important; }

/* ── Modal header ──────────────────────────────────────────────────────────── */
.sigecu-modal-header {
    background: linear-gradient(135deg, var(--sg-azul) 0%, #2563b0 100%);
    color: #fff;
}
.sigecu-modal-header .btn-close-white {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* ── Botones extra pequeños ─────────────────────────────────────────────────── */
.btn-xs {
    font-size: .76rem;
    padding: .18rem .5rem;
    line-height: 1.4;
}

/* ── Formularios ────────────────────────────────────────────────────────────── */
.form-label.fw-medium {
    font-size: .82rem;
    margin-bottom: .25rem;
}

.form-text {
    font-size: .75rem;
}

/* ── Toast ──────────────────────────────────────────────────────────────────── */
.toast {
    min-width: 260px;
    font-size: .84rem;
}

/* ── Responsive: tablet 1024px (reuniones de comité) ───────────────────────── */
@media (max-width: 1024px) {
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    .sigecu-desc-funcion {
        max-width: 280px;
    }
}

@media (max-width: 768px) {
    .sigecu-stat-chip {
        font-size: .74rem;
        padding: .2rem .55rem;
    }
    .sigecu-codigo-f { min-width: 30px; font-size: .72rem; }
    .sigecu-codigo-t { min-width: 30px; font-size: .72rem; }
    .sigecu-desc-funcion { max-width: 180px; }
}

/* =============================================================================
   SiGeCu — Estilos Matriz de Competencias (F3)
   ============================================================================= */

/* Stat cards en la parte superior */
.sigecu-stat-card {
    background: var(--bs-white, #fff);
    border: 0.5px solid var(--sg-gris-borde);
    border-radius: var(--sg-radio);
    padding: .75rem 1rem;
    text-align: center;
    box-shadow: var(--sg-sombra);
}
.sigecu-stat-num {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    color: #212529;
}
.sigecu-stat-lbl {
    font-size: .75rem;
    color: #6c757d;
    margin-top: 2px;
}

/* Tarjeta de tarea en la Matriz */
.tarea-matriz-card {
    border: 0.5px solid var(--sg-gris-borde);
    border-left: 3px solid var(--sg-gris-borde);
    border-radius: 6px;
    background: #fff;
    transition: border-color .2s;
}
.tarea-matriz-card.borde-aprobado    { border-left-color: var(--sg-verde) !important; }
.tarea-matriz-card.borde-revision    { border-left-color: #f0ad4e !important; }
.tarea-matriz-card.borde-correccion  { border-left-color: var(--sg-rojo) !important; }
.tarea-matriz-header { cursor: pointer; }
.tarea-matriz-header:hover { background: var(--sg-azul-claro); border-radius: 6px 6px 0 0; }

/* Transición del chevron */
.sigecu-chevron-tarea {
    transition: transform .2s;
    flex-shrink: 0;
    font-size: .8rem;
    color: #6c757d;
}

/* Tabs de la Matriz */
.nav-tabs-sm .nav-link {
    font-size: .8rem;
    padding: .35rem .75rem;
    color: #6c757d;
    border-radius: 0;
}
.nav-tabs-sm .nav-link.active {
    color: var(--sg-azul);
    font-weight: 500;
    border-color: var(--sg-gris-borde) var(--sg-gris-borde) #fff;
}
.nav-tabs-sm .nav-link:hover { color: var(--sg-azul); }

/* Panel de tab */
.tab-pane-m { font-size: .85rem; }
.tab-pane-m .form-label { font-size: .78rem; }
.tab-pane-m .form-control,
.tab-pane-m .form-select { font-size: .82rem; }

/* Display de créditos SATCA — con candado */
.satca-display {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--sg-azul);
    border: 2px solid var(--sg-gris-borde);
    border-radius: 6px;
    width: 56px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sg-gris-fondo);
    cursor: not-allowed;
}

@media (max-width: 768px) {
    .nav-tabs-sm { flex-wrap: nowrap; overflow-x: auto; }
    .nav-tabs-sm .nav-link { white-space: nowrap; }
    .sigecu-stat-num { font-size: 1.2rem; }
}

/* ── Elementos validados en el AST ──────────────────────────────────────────── */
.funcion-validada > .accordion-header .accordion-button {
    border-left: 3px solid #1a7a4a;
}
.tarea-validada {
    border-left-color: #1a7a4a !important;
}
.tarea-validada .sigecu-acordeon-tarea {
    background: #f0faf4;
}

/* ── AST Editor v3 — Responsive móvil ─────────────────────────────────────── */

/* El titulo en el header NUNCA debe romper el flex verticalmente */
.ast-titulo {
    min-width: 0;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* En móvil el header de función apila en dos filas:
   fila 1: badge + badges estado + contador + acciones
   fila 2: título completo debajo */
@media (max-width: 640px) {

    .ast-funcion-header {
        flex-wrap: wrap;
        gap: 6px;
    }

    /* El título ocupa toda la fila en móvil */
    .ast-funcion-header .ast-titulo {
        order: 10;          /* Va después de badges y acciones */
        width: 100%;
        font-size: 12px;
        line-height: 1.5;
    }

    /* Contador y acciones se quedan en la fila superior */
    .ast-funcion-header .ast-contador {
        margin-left: auto;
    }

    /* Tarea: mismo patrón */
    .ast-tarea-header {
        flex-wrap: wrap;
        gap: 5px;
    }

    .ast-tarea-header .ast-titulo {
        order: 10;
        width: 100%;
        font-size: 12px;
        line-height: 1.5;
    }

    .ast-tarea-header .ast-contador {
        margin-left: auto;
    }

    /* Operación: chips en varias líneas */
    .ast-operacion {
        flex-wrap: wrap;
    }

    .ast-op-chips {
        width: 100%;
    }

    .ast-op-chips .ast-op-chip {
        font-size: 11px;
    }

    /* Chips de sintaxis: apilar verticalmente en móvil */
    .ast-sintaxis {
        flex-direction: column;
        gap: 4px;
    }

    .ast-chip-sep { display: none; }

    .ast-chip {
        gap: 4px;
    }

    .ast-chip-lbl {
        min-width: 60px;
    }

    /* Iconos más pequeños en móvil */
    .ast-ibtn { width: 24px; height: 24px; font-size: 12px; }
    .ast-ibtn.sm { width: 20px; height: 20px; font-size: 11px; }

    /* Ocultar etiquetas de botones que no caben */
    .ast-badge-f { font-size: 10px; padding: 1px 6px; }
    .ast-badge-t { font-size: 10px; padding: 1px 5px; }
}