/* ============================================================ */
/* SITRAV — hoja de estilos de la casa                            */
/* Paleta de la marca (Contexto/imagen): azul rey CINCO + amarillo */
/* dorado del logo; semáforo verde/amarillo/rojo como acento.      */
/* Estructura calcada de cinco_presupuesto (webroot/css/sidebar.css) */
/* ============================================================ */

:root {
    --azul-inicio: #1B3FA3;
    --azul-fin: #142F7C;
    --azul-oscuro: #0B1B45;
    --amarillo: #F7CF3C;
    --tinta: #1C2B3A;          /* texto principal */
    --texto-suave: #5A6B7F;    /* texto secundario */
    --texto-tenue: #8A97A8;    /* ayudas, metadatos */
    --fondo: #F2F5F8;
    --borde: #DEE5EC;
    --borde-tenue: #EBF0F5;
    --mono: 'IBM Plex Mono', Consolas, 'Courier New', monospace;
    --sidebar-width: 250px;
    --header-height: 56px;
    --sidebar-hover: rgba(255, 255, 255, 0.12);
    --sidebar-active: rgba(255, 255, 255, 0.2);
    --sidebar-text: rgba(255, 255, 255, 0.85);
    --flyout-bg: #ffffff;
    --flyout-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

* { box-sizing: border-box; }

body {
    background: var(--fondo);
    font-family: 'IBM Plex Sans', 'Segoe UI', Roboto, Arial, sans-serif;
    color: var(--tinta);
    margin: 0;
}

h5, h6, .modal-title { color: var(--tinta); }

/* Los identificadores del dominio (INT-032, CAM-01, EDGE-…) van en
   monoespaciada: son códigos de máquina y se leen como tales. */
.codigo,
.cruce-card-codigo,
.ficha-encabezado .ficha-codigo { font-family: var(--mono); }

/* ====== FORMULARIOS ====== */
.form-label {
    font-size: 12.5px;
    font-weight: 600;
    color: #33465C;
    margin-bottom: 6px;
}
.form-control, .form-select {
    border-color: var(--borde);
    border-radius: 8px;
    color: var(--tinta);
}
.form-control::placeholder { color: #9AA8B7; }
.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: var(--azul-inicio);
    box-shadow: 0 0 0 3px rgba(27, 63, 163, 0.18);
}
.form-text { color: var(--texto-tenue); font-size: 12px; }
.form-check-input:checked {
    background-color: var(--azul-inicio);
    border-color: var(--azul-inicio);
}
input[readonly].form-control { background: #F5F8FB; color: var(--texto-suave); }

/* ====== MODALES ====== */
.modal-content {
    border: none;
    border-radius: 14px;
    box-shadow: 0 18px 50px rgba(12, 34, 58, 0.28);
}
.modal-header { border-bottom: none; padding: 22px 26px 4px; }
.modal-title { font-weight: 700; font-size: 17px; }
.modal-body { padding: 18px 26px 4px; }
.modal-footer { border-top: none; padding: 12px 26px 22px; }

/* ====== BOTONES ====== */
.btn { border-radius: 8px; transition: transform 120ms ease-out; }
.btn:active { transform: scale(0.98); }
.btn-outline-secondary { color: var(--texto-suave); border-color: #CBD5E0; }
.btn-outline-secondary:hover {
    background: #EDF1F5;
    border-color: #B8C4D2;
    color: #33465C;
}

/* ====== TARJETAS Y TABLAS ====== */
.card { border: 1px solid var(--borde); border-radius: 12px; }
.card.shadow-sm { box-shadow: 0 1px 2px rgba(16, 42, 67, 0.05) !important; }
.card .table thead th {
    font-size: 12px;
    font-weight: 600;
    color: #7C8B9C;
    border-bottom: 1px solid var(--borde);
}
.card .table td { border-color: var(--borde-tenue); }
.card .table { --bs-table-hover-bg: rgba(27, 63, 163, 0.05); }
.text-muted { color: var(--texto-suave) !important; }

/* ====== INSIGNIAS DE ESTADO (punto de señal) ====== */
.badge.bg-success, .badge.bg-secondary, .badge.bg-danger {
    font-weight: 600;
    font-size: 11.5px;
    padding: 4px 10px;
    border-radius: 20px;
}
.badge.bg-success::before, .badge.bg-secondary::before, .badge.bg-danger::before {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: 1px;
}
.badge.bg-success { background: #E3F2E9 !important; color: #17693A; }
.badge.bg-success::before { background: #1E8A4C; }
.badge.bg-secondary { background: #EDF1F5 !important; color: #5A6B7F; }
.badge.bg-secondary::before { background: #94A3B4; }
.badge.bg-danger { background: #F9E8E6 !important; color: #A93226; }
.badge.bg-danger::before { background: #C0392B; }

a { text-decoration: none; }

/* ====== BOTÓN PRIMARIO DE LA CASA ====== */
.btn-primario {
    background: linear-gradient(135deg, var(--azul-inicio), var(--azul-fin));
    border: none;
    color: #fff;
    font-weight: 600;
    transition: filter .15s ease, box-shadow .15s ease, transform 120ms ease-out;
}
.btn-primario:hover,
.btn-primario:focus {
    filter: brightness(1.08);
    color: #fff;
    box-shadow: 0 4px 14px rgba(27, 63, 163, 0.35);
}
.btn-primario:disabled {
    filter: grayscale(0.4);
    opacity: .7;
}

/* ====== LOGIN (molde CINCO: mitad acceso, mitad marca) ====== */
.login-cuerpo { margin: 0; }
.login-fila { display: flex; flex-wrap: wrap; min-height: 100vh; }
.login-mitad {
    flex: 1 1 50%;
    display: flex;
    justify-content: center;
    align-items: center;
}
.login-acceso {
    width: 360px;
    max-width: 92vw;
    padding: 40px 30px;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}
.login-logo { text-align: center; margin-bottom: 12px; }
.login-logo img { max-height: 200px; max-width: 100%; width: auto; }
.campo-linea {
    border: 0;
    border-bottom: 2px solid #e0e0e0;
    border-radius: 0;
    outline: none;
    width: 100%;
    padding: 10px 5px;
    font-size: 14px;
    color: var(--tinta);
    background: transparent;
    transition: border-color .3s ease;
}
.campo-linea:focus { border-bottom-color: var(--azul-inicio); }
.campo-linea::placeholder { color: #aaa; font-size: 13px; }
#btn-ingreso {
    margin-top: 25px;
    margin-bottom: 15px;
    background: var(--azul-inicio);
    width: 100%;
    color: #fff;
    border: 1.5px solid var(--azul-inicio);
    height: 46px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 1.5px;
    cursor: pointer;
    transition: background .18s ease, border-color .18s ease;
}
#btn-ingreso:hover { background: var(--azul-fin); border-color: var(--azul-fin); }
#btn-ingreso:active { background: var(--azul-oscuro); border-color: var(--azul-oscuro); }
#btn-ingreso:focus-visible { outline: 3px solid rgba(27, 63, 163, 0.45); outline-offset: 2px; }
.credito-wsi {
    font-size: 11px;
    width: 100%;
    text-align: center;
    color: #bbb;
    margin-top: 5px;
}
/* Mitad de marca, igual que las otras apps CINCO: imagen a sangre con
   la franja inferior azul y la frase "one system for all". */
.login-marca {
    background-image: url("../img/acceso.jpg");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    align-items: flex-end;
    padding: 0;
}
.login-sombra {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    width: 100%;
    height: 150px;
    background-color: rgba(16, 23, 84, 0.68);
}
.login-frase {
    width: 397px;
    max-width: 80%;
    margin-right: 30px;
}
@media screen and (max-width: 995px) {
    .login-marca { display: none; }
    .login-mitad { flex: 1 1 100%; }
}

/* ====== APLICACIÓN: HEADER SUPERIOR ====== */
.app-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-height);
    background: linear-gradient(90deg, var(--azul-inicio), var(--azul-fin));
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1000;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.header-toggle {
    background: none;
    border: none;
    font-size: 24px;
    color: #fff;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    transition: background .2s ease;
}
.header-toggle:hover { background: rgba(255, 255, 255, 0.15); }
.header-home {
    font-size: 20px;
    color: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    padding: 6px;
    border-radius: 8px;
    transition: background .2s ease;
}
.header-home:hover { background: rgba(255, 255, 255, 0.15); color: #fff; }
.header-brand {
    color: #fff;
    font-weight: 700;
    letter-spacing: .5px;
}
.header-user { display: flex; align-items: center; gap: 12px; }
.header-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--amarillo);
    color: var(--azul-oscuro);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}
.header-user-separator { width: 1px; height: 30px; background: rgba(255, 255, 255, 0.3); }
.header-user-info { display: flex; flex-direction: column; line-height: 1.25; }
.header-username { font-size: 13px; color: #fff; font-weight: 600; }
.header-userlogin { font-size: 11.5px; color: rgba(255, 255, 255, 0.8); }
.header-logout {
    color: rgba(255, 255, 255, 0.85);
    font-size: 22px;
    display: flex;
    align-items: center;
    transition: color .2s ease;
}
.header-logout:hover { color: #fff; }

/* ====== SIDEBAR ====== */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--azul-inicio) 0%, var(--azul-fin) 55%, var(--azul-oscuro) 100%);
    z-index: 1100;
    transform: translateX(-100%);
    transition: transform .35s cubic-bezier(.4, 0, .2, 1);
    display: flex;
    flex-direction: column;
    overflow: visible;
}
.sidebar.open { transform: translateX(0); }

.sidebar-logo {
    padding: 22px 20px 18px;
    text-align: center;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}
.sidebar-logo img { width: 170px; max-width: 100%; }
.sidebar-logo-sub { font-size: 11.5px; color: rgba(255, 255, 255, 0.75); margin-top: 6px; }

.sidebar-nav { list-style: none; margin: 0; padding: 12px 0; flex: 1; overflow: visible; }
.sidebar-item { position: relative; margin: 2px 10px; }
.sidebar-link {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: var(--sidebar-text);
    font-size: 14px;
    font-weight: 500;
    border-radius: 10px;
    gap: 12px;
    transition: background .2s ease, color .2s ease;
}
.sidebar-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-link ion-icon:first-child { font-size: 20px; flex-shrink: 0; }
.sidebar-link span { flex: 1; }
.sidebar-arrow { font-size: 13px; opacity: .6; transition: transform .25s ease; }
.sidebar-item.accordion-open > .sidebar-link .sidebar-arrow { transform: rotate(90deg); }

/* ====== FLYOUT (submenú) ====== */
.sidebar-flyout {
    position: fixed;
    min-width: 220px;
    background: var(--flyout-bg);
    border-radius: 12px;
    box-shadow: var(--flyout-shadow);
    padding: 8px 0;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-10px);
    transition: all .25s cubic-bezier(.4, 0, .2, 1);
    z-index: 1200;
}
.sidebar-flyout.show { opacity: 1; visibility: visible; transform: translateX(0); }
.flyout-header {
    padding: 10px 18px 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--azul-fin);
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 4px;
}
.sidebar-flyout ul { list-style: none; margin: 0; padding: 0; }
.flyout-link {
    display: flex;
    align-items: center;
    padding: 10px 18px;
    color: #444;
    font-size: 13px;
    font-weight: 500;
    gap: 8px;
    transition: all .2s ease;
}
.flyout-link:hover { background: rgba(27, 63, 163, .07); color: var(--azul-fin); padding-left: 22px; }
.flyout-link.active {
    color: var(--azul-fin);
    font-weight: 600;
    background: rgba(27, 63, 163, .08);
    border-left: 3px solid var(--amarillo);
}
.flyout-link ion-icon { font-size: 17px; flex-shrink: 0; color: var(--azul-fin); opacity: .7; }
.flyout-link:hover ion-icon, .flyout-link.active ion-icon { opacity: 1; }

/* Pestaña sobresaliente para abrir el sidebar */
.sidebar-tab {
    position: fixed;
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 28px; height: 60px;
    background: linear-gradient(180deg, var(--azul-inicio), var(--azul-fin));
    border-radius: 0 10px 10px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 999;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.15);
    transition: all .3s ease;
}
.sidebar-tab ion-icon { color: #fff; font-size: 16px; }
.sidebar-tab:hover { width: 34px; }
.sidebar-tab.hidden { opacity: 0; pointer-events: none; transform: translateY(-50%) translateX(-100%); }

/* Overlay de fondo (cerrar al hacer clic fuera) */
.sidebar-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: all .3s ease;
}
.sidebar-overlay.show { opacity: 1; visibility: visible; }

/* ====== CONTENIDO ====== */
.contenido {
    margin-top: var(--header-height);
    padding: 24px 28px;
    min-height: calc(100vh - var(--header-height));
    background: #f4f6f9;
}

/* ====== FICHA DEL CRUCE ====== */
.cruce-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 14px;
    /* Con muchos cruces la parrilla no empuja la ficha fuera de la
       pantalla: ~3 filas visibles y scroll propio (+ el buscador). */
    max-height: 340px;
    overflow-y: auto;
    padding: 3px;
}

.buscador-cruces { position: relative; }
.buscador-cruces ion-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #8a97a8;
    font-size: 16px;
    pointer-events: none;
}
.buscador-cruces input {
    width: 230px;
    padding-left: 32px;
    border-radius: 8px;
}
.cruce-card {
    background: #fff;
    border: 1px solid #e5e9f0;
    border-radius: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
    box-shadow: 0 1px 3px rgba(16, 42, 67, 0.06);
}
.cruce-card:hover {
    border-color: var(--azul-inicio);
    box-shadow: 0 4px 14px rgba(27, 63, 163, 0.15);
    transform: translateY(-1px);
}
.cruce-card:active { transform: scale(0.98); }
.cruce-card.seleccionado {
    border-color: var(--azul-inicio);
    box-shadow: 0 0 0 2px rgba(27, 63, 163, 0.25), 0 4px 14px rgba(27, 63, 163, 0.15);
}
.cruce-card.inactivo { opacity: .65; }
.cruce-card-cabecera { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cruce-card-codigo { font-weight: 700; color: var(--azul-oscuro); letter-spacing: .3px; }
.cruce-card-nombre { font-size: 13px; color: #5a6b7f; margin-top: 2px; }
.cruce-card-metas { display: flex; gap: 14px; margin-top: 10px; font-size: 12.5px; color: #6b7a8c; }
.cruce-card-metas ion-icon { vertical-align: -2px; font-size: 15px; color: var(--azul-fin); opacity: .75; }
.meta-alerta { color: #c0392b; font-weight: 600; }
.meta-alerta ion-icon { color: #c0392b !important; }

.insignia-modo { background: rgba(27, 63, 163, 0.12); color: var(--azul-fin); font-weight: 600; border-radius: 20px; padding: 4px 10px; }
.insignia-solo-vista { background: #eef1f5; color: #5a6b7f; font-weight: 600; border-radius: 20px; padding: 4px 10px; }

.ficha-encabezado .ficha-codigo { font-size: 20px; font-weight: 700; color: var(--azul-oscuro); letter-spacing: .5px; }
.ficha-encabezado .ficha-nombre { font-size: 15px; color: #33465c; margin-top: 2px; }

.ficha-seccion h6 { color: var(--azul-oscuro); font-weight: 700; display: flex; align-items: center; gap: 6px; margin-bottom: 0; }
.ficha-seccion h6 ion-icon { color: var(--azul-fin); font-size: 18px; }
.conteo-seccion { color: #8a97a8; font-weight: 500; font-size: 12.5px; }

.tabla-ficha thead th {
    font-size: 12px;
    color: #7C8B9C;
    font-weight: 600;
}

.estado-vacio {
    background: #fff;
    border: 1px dashed #cdd6e1;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    color: #8a97a8;
    grid-column: 1 / -1;
}
.estado-vacio ion-icon { font-size: 34px; color: #b8c4d2; }

/* La ficha no se teletransporta: entra con un puente corto (220ms) al
   seleccionar un cruce; la clase se re-dispara al cambiar de tarjeta. */
@keyframes ficha-entra {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}
.ficha-entrando { animation: ficha-entra 220ms ease-out; }

.cruce-cards::-webkit-scrollbar { width: 8px; }
.cruce-cards::-webkit-scrollbar-thumb { background: #C8D3DE; border-radius: 8px; }
.cruce-cards::-webkit-scrollbar-track { background: transparent; }

/* ====== ACCESIBILIDAD ====== */
.cruce-card:focus-visible,
.btn:focus-visible,
a:focus-visible {
    outline: 2px solid var(--azul-inicio);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
    }
}

/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
    .header-username, .header-userlogin { display: none; }
    .header-user-separator { display: none; }
    .contenido { padding: 16px; }
    .sidebar { overflow-y: auto; overflow-x: hidden; }
    .sidebar-flyout {
        position: static !important;
        min-width: 100% !important;
        background: rgba(0, 0, 0, 0.15) !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
        max-height: 0;
        overflow: hidden;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
        transition: max-height .35s ease, padding .35s ease !important;
    }
    .sidebar-flyout.show { max-height: 500px; padding: 6px 0 !important; }
    .sidebar-flyout::before { display: none !important; }
    .sidebar-flyout .flyout-header { display: none; }
    .sidebar-flyout .flyout-link {
        color: rgba(255, 255, 255, 0.8);
        padding: 10px 20px 10px 52px;
        font-size: 13px;
    }
    .sidebar-flyout .flyout-link:hover { background: rgba(255, 255, 255, 0.1); color: #fff; padding-left: 56px; }
    .sidebar-flyout .flyout-link.active {
        background: rgba(255, 255, 255, 0.15);
        color: #fff;
        border-left: 3px solid rgba(255, 255, 255, 0.6);
    }
    .sidebar-flyout .flyout-link ion-icon { color: rgba(255, 255, 255, 0.6); }
}
