/**
 * CIEM IA+ · Selector de rutas + panel Ruta B (Grado A)
 * No modifica estilos del lienzo cian (#ciem_f11_origen).
 */

#fase1 #ciem_rutas_selector,
#ciem_rutas_selector {
    flex: 1 1 100%;
    align-self: stretch;
}

/* —— Barra de pestañas (alto impacto, antes del lienzo cian) —— */
#ciem_rutas_selector {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin: 22px 0 22px 0;
    padding: 0;
    font-family: Arial, sans-serif;
    font-size: 12pt;
    line-height: 1.45;
    color: #0f172a;
    clear: both;
    position: relative;
    z-index: 20;
}

#ciem_rutas_selector .ciem-rutas-titulo {
    margin: 0 0 12px 0;
    padding: 0 4px;
    font-family: Arial, sans-serif;
    font-size: 12pt;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #0369a1;
    line-height: 1.4;
}

#ciem_rutas_selector .ciem-rutas-sub {
    margin: 0 0 14px 0;
    padding: 0 4px;
    font-family: Arial, sans-serif;
    font-size: 12pt;
    font-weight: 400;
    color: #475569;
    line-height: 1.5;
}

#ciem_rutas_selector .ciem-rutas-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    width: 100%;
    border-radius: 16px;
    overflow: hidden;
    border: 3px solid #38bdf8;
    background: #f8fafc;
    box-shadow:
        0 16px 40px rgba(14, 165, 233, 0.22),
        0 4px 12px rgba(15, 23, 42, 0.08);
}

#ciem_rutas_selector.ciem-rutas-modo-b .ciem-rutas-tabs {
    border-color: #8b5cf6;
    box-shadow:
        0 16px 40px rgba(124, 58, 237, 0.22),
        0 4px 12px rgba(15, 23, 42, 0.08);
}

#ciem_rutas_selector .ciem-ruta-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 72px;
    padding: 18px 20px;
    margin: 0;
    border: none;
    border-radius: 0;
    background: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
    color: #64748b;
    font-family: Arial, sans-serif;
    font-size: 12pt;
    font-weight: 700;
    line-height: 1.35;
    text-align: center;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

#ciem_rutas_selector .ciem-ruta-tab .ciem-ruta-tab-linea {
    display: block;
    font-size: 12pt;
    font-weight: 1000;
    letter-spacing: 0.03em;
}

#ciem_rutas_selector .ciem-ruta-tab .ciem-ruta-tab-desc {
    display: block;
    font-size: 12pt;
    font-weight: 600;
    opacity: 0.92;
}

#ciem_rutas_selector .ciem-ruta-tab[data-ruta="A"] {
    border-right: 2px solid rgba(56, 189, 248, 0.35);
}

#ciem_rutas_selector .ciem-ruta-tab[data-ruta="B"] {
    border-left: 2px solid rgba(167, 139, 250, 0.25);
}

#ciem_rutas_selector .ciem-ruta-tab:hover {
    background: linear-gradient(180deg, #f8fafc 0%, #e0f2fe 100%);
    color: #0c4a6e;
}

#ciem_rutas_selector .ciem-ruta-tab[data-ruta="B"]:hover {
    background: linear-gradient(180deg, #faf5ff 0%, #ede9fe 100%);
    color: #5b21b6;
}

/* Línea A activa — cian institucional */
#ciem_rutas_selector .ciem-ruta-tab[data-ruta="A"].ciem-ruta-tab--activa {
    background: linear-gradient(180deg, #7dd3fc 0%, #38bdf8 45%, #0ea5e9 100%);
    color: #0f172a;
    box-shadow: inset 0 -4px 0 #0369a1;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

#ciem_rutas_selector .ciem-ruta-tab[data-ruta="A"].ciem-ruta-tab--activa .ciem-ruta-tab-linea {
    color: #0c4a6e;
}

/* Línea B activa — ambiente violeta elegante */
#ciem_rutas_selector .ciem-ruta-tab[data-ruta="B"].ciem-ruta-tab--activa {
    background: linear-gradient(180deg, #ddd6fe 0%, #a78bfa 45%, #7c3aed 100%);
    color: #ffffff;
    box-shadow: inset 0 -4px 0 #5b21b6;
    text-shadow: 0 1px 2px rgba(15, 23, 42, 0.25);
}

#ciem_rutas_selector .ciem-ruta-tab[data-ruta="B"].ciem-ruta-tab--activa .ciem-ruta-tab-linea,
#ciem_rutas_selector .ciem-ruta-tab[data-ruta="B"].ciem-ruta-tab--activa .ciem-ruta-tab-desc {
    color: #ffffff;
}

#ciem_rutas_selector .ciem-ruta-tab:focus-visible {
    outline: 3px solid #0f172a;
    outline-offset: 2px;
    z-index: 2;
}

@media (max-width: 640px) {
    #ciem_rutas_selector .ciem-rutas-tabs {
        grid-template-columns: 1fr;
    }
    #ciem_rutas_selector .ciem-ruta-tab[data-ruta="A"] {
        border-right: none;
        border-bottom: 2px solid rgba(56, 189, 248, 0.35);
    }
    #ciem_rutas_selector .ciem-ruta-tab[data-ruta="B"] {
        border-left: none;
    }
}

/* —— Conmutación: ocultar lienzo A por completo —— */
.ciem-ruta-a-oculta {
    display: none !important;
}

/* —— Panel Ruta B (visible con orgullo) —— */
#ciem_ruta_b_shell {
    display: none;
    width: 100%;
    box-sizing: border-box;
    margin: 8px 0 24px 0;
    padding: 22px 22px 24px 22px;
    border-radius: 16px;
    border: 3px solid #8b5cf6;
    background: linear-gradient(180deg, #faf5ff 0%, #ffffff 40%, #f5f3ff 100%);
    color: #0f172a;
    font-family: Arial, sans-serif;
    font-size: 12pt;
    line-height: 1.45;
    box-shadow: 0 18px 48px rgba(91, 33, 182, 0.16);
}

#ciem_ruta_b_shell.ciem-ruta-b-visible {
    display: block;
    animation: ciemRutaBFadeIn 0.28s ease;
}

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

#ciem_ruta_b_shell .ciem-rb-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 2px solid #e9d5ff;
}

#ciem_ruta_b_shell .ciem-rb-titulo {
    margin: 0;
    font-family: Arial, sans-serif;
    font-size: 12pt;
    font-weight: 1000;
    color: #5b21b6;
    line-height: 1.4;
}

#ciem_ruta_b_shell .ciem-rb-sub {
    margin: 6px 0 0 0;
    font-family: Arial, sans-serif;
    font-size: 12pt;
    font-weight: 400;
    color: #475569;
    line-height: 1.5;
}

#ciem_ruta_b_shell .ciem-rb-badge {
    padding: 10px 16px;
    border-radius: 999px;
    border: 2px solid #cbd5e1;
    background: #f8fafc;
    font-family: Arial, sans-serif;
    font-size: 12pt;
    font-weight: 900;
}

#ciem_ruta_b_shell .ciem-rb-ctrl {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

#ciem_ruta_b_shell .ciem-rb-btn-mentor {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 20px;
    border-radius: 12px;
    border: 2px solid #6d28d9;
    background: linear-gradient(180deg, #ede9fe, #ffffff);
    color: #4c1d95;
    font-family: Arial, sans-serif;
    font-size: 12pt;
    font-weight: 900;
    text-decoration: none;
    box-shadow: 0 8px 20px rgba(109, 40, 217, 0.12);
}

#ciem_ruta_b_shell .ciem-rb-btn-sync {
    padding: 14px 22px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(180deg, #a78bfa, #7c3aed);
    color: #fff;
    font-family: Arial, sans-serif;
    font-size: 12pt;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(124, 58, 237, 0.28);
}

#ciem_ruta_b_shell .ciem-rb-grid-campos {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 18px;
}

@media (max-width: 720px) {
    #ciem_ruta_b_shell .ciem-rb-grid-campos {
        grid-template-columns: 1fr;
    }
}

#ciem_ruta_b_shell .ciem-rb-lbl {
    display: block;
    font-family: Arial, sans-serif;
    font-size: 12pt;
    font-weight: 900;
    color: #0f172a;
}

#ciem_ruta_b_shell .ciem-rb-input,
#ciem_ruta_b_shell .ciem-rb-textarea {
    margin-top: 8px;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border-radius: 10px;
    border: 2px solid #c4b5fd;
    background: #fff;
    font-family: Arial, sans-serif;
    font-size: 12pt;
    line-height: 1.45;
}

#ciem_ruta_b_shell .ciem-rb-matriz-wrap {
    margin-top: 6px;
    padding: 18px;
    border-radius: 14px;
    border: 2px dashed #a78bfa;
    background: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(167, 139, 250, 0.15);
}

#ciem_ruta_b_shell .ciem-rb-matriz-titulo {
    margin: 0 0 10px 0;
    font-family: Arial, sans-serif;
    font-size: 12pt;
    font-weight: 1000;
    color: #5b21b6;
}

#ciem_ruta_b_shell .ciem-rb-tabla {
    width: 100%;
    border-collapse: collapse;
    font-family: Arial, sans-serif;
    font-size: 12pt;
}

#ciem_ruta_b_shell .ciem-rb-tabla th {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 3px solid #c4b5fd;
    background: #f5f3ff;
    color: #5b21b6;
    font-weight: 900;
    font-size: 12pt;
}

#ciem_ruta_b_shell .ciem-rb-tabla td {
    padding: 10px;
    border-bottom: 1px solid #ede9fe;
    vertical-align: top;
    font-size: 12pt;
}

#ciem_ruta_b_shell .ciem-rb-tabla code {
    font-family: Consolas, "Courier New", monospace;
    font-size: 11pt;
    color: #6d28d9;
    font-weight: 700;
}

#ciem_ruta_b_shell .ciem-rb-export {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 2px solid #e9d5ff;
}

#ciem_ruta_b_shell .ciem-rb-btn-export {
    padding: 12px 18px;
    border-radius: 12px;
    border: 2px solid #7c3aed;
    background: #fff;
    color: #5b21b6;
    font-family: Arial, sans-serif;
    font-size: 12pt;
    font-weight: 900;
    cursor: pointer;
}

#ciem_ruta_b_shell .ciem-rb-btn-validar {
    padding: 14px 22px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(180deg, #c4b5fd, #7c3aed);
    color: #fff;
    font-family: Arial, sans-serif;
    font-size: 12pt;
    font-weight: 1000;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(124, 58, 237, 0.25);
}

#ciem_ruta_b_alert {
    display: none;
    margin: 0 0 14px 0;
    padding: 12px 14px;
    border-radius: 12px;
    border: 2px solid #f59e0b;
    background: #fffbeb;
    color: #7c2d12;
    font-family: Arial, sans-serif;
    font-size: 12pt;
    font-weight: 900;
    line-height: 1.45;
}

#ciem_ruta_b_alert:not(:empty) {
    display: block;
}
