/* ============================================================
   /estilos/normas.css — Módulo Biblioteca de Normas
   chat.higseg.ar · normas-chat v1.0
   Depende de: colores.css y general.css (copias locales de VISP)
   ============================================================ */

/* ── Layout general ── */
.normas-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    height: calc(100vh - 5rem - 3.5rem);
    overflow: hidden;
}

/* ── Sidebar ── */
.normas-sidebar {
    width: 280px;
    flex-shrink: 0;
    background: var(--color-secundario);
    border-right: 2px solid var(--color-borde);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-titulo {
    font-weight: 700;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-footer-fondo);
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--color-borde);
    background: var(--color-header-fondo);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.normas-lista {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.normas-lista::-webkit-scrollbar { width: 5px; }
.normas-lista::-webkit-scrollbar-thumb { background: #bbb; border-radius: 3px; }

.norma-categoria {
    font-size: 0.70rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-footer-fondo);
    padding: 0.6rem 0.5rem 0.2rem;
    margin-top: 0.3rem;
}

.norma-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.6rem;
    border-radius: 0.4rem;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.12s, border-color 0.12s;
    margin-bottom: 2px;
}

.norma-item:hover { background: var(--color-primario); }

.norma-item.seleccionado {
    background: var(--color-primario);
    border-color: var(--color-footer-fondo);
}

.norma-item input[type="checkbox"] {
    accent-color: var(--color-footer-fondo);
    width: 15px; height: 15px;
    flex-shrink: 0; cursor: pointer; margin: 0;
}

.norma-info { flex: 1; min-width: 0; }

.norma-codigo {
    font-family: 'Courier New', monospace;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--color-footer-fondo);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.norma-desc {
    font-size: 0.70rem;
    color: var(--color-texto-secundario);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.norma-badge {
    font-size: 0.65rem;
    background: var(--color-footer-fondo);
    color: white;
    padding: 1px 6px;
    border-radius: 3px;
    flex-shrink: 0;
}

/* ── Pie del sidebar ── */
.sidebar-pie {
    padding: 0.6rem 1rem;
    border-top: 1px solid var(--color-borde);
    font-size: 0.78rem;
    color: var(--color-texto-secundario);
    background: var(--color-header-fondo);
}

.sidebar-pie strong { color: var(--color-footer-fondo); }

/* ── Barra de contexto ── */
.contexto-barra-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.70rem;
    color: var(--color-texto-secundario);
    margin-bottom: 3px;
    margin-top: 0.4rem;
}

.contexto-barra-track {
    height: 5px;
    background: var(--color-borde);
    border-radius: 3px;
    overflow: hidden;
}

.contexto-barra-fill {
    height: 100%;
    width: 0%;
    background: var(--color-cumple);
    border-radius: 3px;
    transition: width 0.3s ease, background-color 0.3s ease;
}

/* ── Botón limpiar selección ── */
.btn-limpiar-sel {
    font-size: 0.72rem;
    padding: 3px 10px;
    background: transparent;
    border: 1px solid var(--color-borde);
    border-radius: 1rem;
    color: var(--color-texto-secundario);
    cursor: pointer;
    font-family: Montserrat, sans-serif;
    transition: background-color 0.12s, color 0.12s, border-color 0.12s;
    margin: 0;
    box-shadow: none;
    white-space: nowrap;
}

.btn-limpiar-sel:hover:not(:disabled) {
    background: #fde8e8;
    border-color: var(--color-no-cumple);
    color: var(--color-no-cumple);
}

.btn-limpiar-sel:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── Área de chat ── */
.normas-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f5f5f5;
    min-width: 0;
}

.chat-mensajes {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-mensajes::-webkit-scrollbar { width: 5px; }
.chat-mensajes::-webkit-scrollbar-thumb { background: #bbb; border-radius: 3px; }

/* ── Bienvenida ── */
.chat-bienvenida {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    gap: 1rem;
    color: var(--color-texto-secundario);
}

.bienvenida-icono { font-size: 3rem; opacity: 0.5; }

.chat-bienvenida h2 {
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--color-footer-fondo);
}

.chat-bienvenida p {
    font-size: 0.9rem;
    max-width: 420px;
    line-height: 1.6;
}

.chips-rapidos {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 0.5rem;
    max-width: 520px;
}

.chip {
    background: white;
    border: 1px solid var(--color-borde);
    border-radius: 1.2rem;
    padding: 0.4rem 0.9rem;
    font-size: 0.78rem;
    color: var(--color-texto-secundario);
    cursor: pointer;
    transition: all 0.12s;
    margin: 0;
    box-shadow: none;
}

.chip:hover {
    background: var(--color-primario);
    border-color: var(--color-footer-fondo);
    color: var(--color-footer-fondo);
}

/* ── Mensajes ── */
.mensaje {
    display: flex;
    gap: 0.6rem;
    animation: aparecerMensaje 0.2s ease;
}

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

.mensaje.usuario { flex-direction: row-reverse; }

.msg-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
    margin-top: 2px;
    border: 1px solid var(--color-borde);
}

.mensaje.usuario .msg-avatar {
    background: var(--color-footer-fondo);
    color: white;
    font-weight: 700;
    font-size: 0.68rem;
    border-color: var(--color-footer-fondo);
}

.mensaje.ia .msg-avatar { background: white; }

.msg-cuerpo { max-width: 78%; display: flex; flex-direction: column; }
.mensaje.usuario .msg-cuerpo { align-items: flex-end; }

.msg-burbuja {
    padding: 0.7rem 1rem;
    border-radius: 0.6rem;
    font-size: 0.88rem;
    line-height: 1.65;
    border: 1px solid var(--color-borde);
}

.mensaje.usuario .msg-burbuja {
    background: var(--color-footer-fondo);
    color: white;
    border-color: var(--color-footer-fondo);
    border-bottom-right-radius: 3px;
}

.mensaje.ia .msg-burbuja {
    background: white;
    color: var(--color-texto);
    border-bottom-left-radius: 3px;
}

.msg-burbuja p { margin-bottom: 0.5rem; }
.msg-burbuja p:last-child { margin-bottom: 0; }
.msg-burbuja strong { color: var(--color-footer-fondo); }
.mensaje.usuario .msg-burbuja strong { color: var(--color-primario); }
.msg-burbuja ul, .msg-burbuja ol { padding-left: 1.2rem; margin: 0.3rem 0; }
.msg-burbuja li { margin-bottom: 0.2rem; }

.msg-burbuja code {
    font-family: 'Courier New', monospace;
    font-size: 0.82rem;
    background: #f0f0f0;
    padding: 1px 5px;
    border-radius: 3px;
    border: 1px solid #ddd;
}

/* ── Etiquetas de fuentes ── */
.msg-fuentes { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.5rem; }

.fuente-tag {
    font-size: 0.68rem;
    background: #e8f4e8;
    color: var(--color-cumple);
    padding: 2px 7px;
    border-radius: 3px;
    border: 1px solid #b8d8b8;
    font-family: 'Courier New', monospace;
}

/* ── Typing indicator ── */
.msg-typing .msg-burbuja {
    display: flex; align-items: center; gap: 4px; padding: 0.9rem 1rem;
}

.punto-typing {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #aaa;
    animation: typing 0.9s infinite;
}

.punto-typing:nth-child(2) { animation-delay: 0.15s; }
.punto-typing:nth-child(3) { animation-delay: 0.30s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
    40%           { transform: scale(1.1); opacity: 1; }
}

/* ── Selector de modelo ── */
.selector-modelo-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.78rem;
    color: var(--color-texto-secundario);
}

.selector-modelo-bar label {
    font-weight: 600;
    color: var(--color-footer-fondo);
    white-space: nowrap;
}

.selector-modelo-bar select {
    border: 1px solid var(--color-borde);
    border-radius: 0.4rem;
    padding: 3px 8px;
    font-size: 0.78rem;
    font-family: Montserrat, sans-serif;
    color: var(--color-texto);
    background: white;
    outline: none;
    cursor: pointer;
    margin: 0;
    transition: border-color 0.15s;
    max-width: 280px;
}

.selector-modelo-bar select:focus {
    border-color: var(--color-footer-fondo);
}

/* ── Entrada ── */
.chat-entrada {
    border-top: 2px solid var(--color-borde);
    background: var(--color-header-fondo);
    padding: 0.9rem 1rem;
    flex-shrink: 0;
}

.aviso-sin-normas {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 0.4rem;
    padding: 0.5rem 0.8rem;
    font-size: 0.8rem;
    color: #7a5800;
    margin-bottom: 0.6rem;
    text-align: center;
    display: none;
}

.entrada-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    background: white;
    border: 1px solid var(--color-borde);
    border-radius: 0.6rem;
    padding: 0.5rem 0.6rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.entrada-wrapper:focus-within {
    border-color: var(--color-footer-fondo);
    box-shadow: 0 0 0 2px var(--color-sombra-modal);
}

.entrada-wrapper textarea {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--color-texto);
    font-family: Montserrat, sans-serif;
    font-size: 0.88rem;
    line-height: 1.5;
    resize: none;
    max-height: 100px;
    min-height: 22px;
}

.entrada-wrapper textarea::placeholder { color: #aaa; }

.btn-enviar {
    background: var(--color-footer-fondo);
    border: none;
    cursor: pointer;
    width: 36px; height: 36px;
    border-radius: 0.4rem;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.1s;
    margin: 0;
    box-shadow: none;
}

.btn-enviar:hover { background: var(--color-resaltado); }
.btn-enviar:active { transform: scale(0.95); }
.btn-enviar:disabled { background: #ccc; cursor: not-allowed; }
.btn-enviar svg { width: 16px; height: 16px; fill: white; }

.entrada-ayuda {
    display: flex;
    justify-content: space-between;
    font-size: 0.70rem;
    color: var(--color-texto-secundario);
    margin-top: 0.4rem;
    padding: 0 2px;
}

/* ── Config API Key ── */
.config-bar {
    background: #fff8e1;
    border-bottom: 1px solid #ffc107;
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 0.8rem;
    color: #7a5800;
    flex-shrink: 0;
}

.config-bar.oculto { display: none; }

.config-bar input {
    flex: 1;
    max-width: 360px;
    border: 1px solid #ffc107;
    border-radius: 0.3rem;
    padding: 4px 8px;
    font-size: 0.8rem;
    font-family: 'Courier New', monospace;
    background: white;
    outline: none;
    margin: 0;
}

.config-bar input:focus { border-color: var(--color-footer-fondo); }

.btn-config-guardar {
    background: var(--color-footer-fondo);
    color: white;
    border: none;
    border-radius: 0.3rem;
    padding: 5px 14px;
    font-size: 0.78rem;
    cursor: pointer;
    margin: 0;
    box-shadow: none;
    transition: background 0.15s;
}

.btn-config-guardar:hover { background: var(--color-resaltado); }

/* ── Errores ── */
.msg-error {
    background: #fde8e8;
    border: 1px solid var(--color-no-cumple);
    color: var(--color-no-cumple);
    border-radius: 0.4rem;
    padding: 0.5rem 0.8rem;
    font-size: 0.8rem;
}

/* ── Botones del header ── */
.btn-nueva-consulta {
    font-size: 0.8rem;
    padding: 0.3rem 0.9rem;
    background: transparent;
    border: 1px solid var(--color-borde) !important;
    border-radius: 1rem;
    color: var(--color-texto);
    margin: 0 0 0 0.5rem;
    box-shadow: none;
    transition: background 0.15s;
}

.btn-nueva-consulta:hover { background: var(--color-resaltado); }

.btn-abrir-sidebar {
    display: none;
    align-items: center;
    font-size: 0.8rem;
    padding: 0.3rem 0.7rem;
    background: transparent;
    border: 1px solid var(--color-borde) !important;
    border-radius: 1rem;
    color: var(--color-texto);
    margin: 0;
    box-shadow: none;
    cursor: pointer;
}

.btn-cerrar-sidebar {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--color-texto);
    margin: 0;
    box-shadow: none;
    padding: 0;
    line-height: 1;
}

/* ── Modal de ayuda ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: var(--color-semitransparente);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.abierto { display: flex; }

.modal-ayuda {
    background: white;
    border-radius: 0.8rem;
    border: 1px solid var(--color-borde);
    width: min(520px, 96vw);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 32px var(--color-sombra-modal);
    animation: aparecerMensaje 0.2s ease;
}

.modal-ayuda-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--color-borde);
    background: var(--color-header-fondo);
    flex-shrink: 0;
}

.modal-ayuda-header h3 {
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-footer-fondo);
    margin: 0;
}

.btn-cerrar-modal {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--color-texto-secundario);
    margin: 0;
    box-shadow: none;
    padding: 0 0.2rem;
    line-height: 1;
    transition: color 0.12s;
}

.btn-cerrar-modal:hover { color: var(--color-no-cumple); }

.modal-ayuda-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ayuda-paso {
    display: flex;
    gap: 0.8rem;
    align-items: flex-start;
}

.ayuda-paso-num {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--color-footer-fondo);
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.ayuda-paso-texto { flex: 1; }

.ayuda-paso-texto strong {
    font-size: 0.88rem;
    color: var(--color-footer-fondo);
    display: block;
    margin-bottom: 0.25rem;
}

.ayuda-paso-texto p {
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--color-texto-secundario);
    margin: 0;
}

.ayuda-nota {
    background: #f0f6ff;
    border: 1px solid #c0d8f0;
    border-left: 3px solid var(--color-footer-fondo);
    border-radius: 0.4rem;
    padding: 0.7rem 0.9rem;
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--color-texto-secundario);
}

.ayuda-nota strong { color: var(--color-footer-fondo); }

.modal-ayuda-footer {
    padding: 0.8rem 1.2rem;
    border-top: 1px solid var(--color-borde);
    display: flex;
    justify-content: flex-end;
    background: var(--color-header-fondo);
    flex-shrink: 0;
}

/* ── Botón ayuda bienvenida ── */
.btn-ayuda-bienvenida {
    background: white;
    border: 1px solid var(--color-footer-fondo);
    border-radius: 1.2rem;
    padding: 0.45rem 1.1rem;
    font-size: 0.82rem;
    color: var(--color-footer-fondo);
    cursor: pointer;
    font-weight: 600;
    transition: background 0.12s;
    margin: 0;
    box-shadow: none;
}

.btn-ayuda-bienvenida:hover { background: var(--color-primario); }

/* ── Responsive ── */
@media (max-width: 768px) {
    .normas-sidebar {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 200;
        width: 100%;
        border-right: none;
    }

    .normas-sidebar.abierto { display: flex; }
    .btn-abrir-sidebar { display: inline-flex !important; }
    .normas-layout { height: calc(100vh - 4rem - 3.5rem); }
}
