/*
 * Serval - Estilos Generales
 * Bootstrap 5.3 + Inter
 */

:root {
    font-feature-settings: "cv01","cv02","cv03","cv04","cv09","cv11";
    --bs-font-sans-serif: 'Inter var', 'InterVariable', 'Inter', sans-serif !important;
    font-family: var(--bs-font-sans-serif);
    --bs-link-decoration: none;
    --bs-link-hover-decoration: none;
}

html, body {
    width: 100%;
    height: 100%;
    height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    overscroll-behavior: none;
}
body {
    font-size: .875rem !important;
    font-weight: 500;
}
body, button, input, select, textarea, option, optgroup, .popover-header, .popover-body, .tooltip, .tooltip-inner {
    font-family: var(--bs-font-sans-serif) !important;
    font-feature-settings: "cv01","cv02","cv03","cv04","cv09","cv11" !important;
}
a,
a:hover,
a:focus,
.btn-link,
.btn-link:hover,
.btn-link:focus,
#botonMenuComponentes {
    text-decoration: none !important;
}
fieldset {
    width: 100%;
    margin: 0 auto;
}
textarea {
    width: 100%;
    resize: none;
}
:focus {
    outline: 0;
}
:disabled {
    cursor: not-allowed;
}
th[rel] {
    cursor: pointer;
}
[draggable] {
    -moz-user-select: none;
    -khtml-user-select: none;
    -webkit-user-select: none;
    user-select: none;
    -khtml-user-drag: element;
    -webkit-user-drag: element;
}

/*
 * Ajustes de bootstrap y utilidades
 */
#bloqueInicioSesion .alert-dismissible {
    padding: 3em 1.25rem .75rem !important;
}
#bloqueInicioSesion .alert-dismissible .close,
#bloqueInicioSesion .alert-dismissible .btn-close {
    left: 0;
}
.popover {
    max-width: 800px !important;
}
.w-5  { width: 5% !important; }
.w-10 { width: 10% !important; }
.w-15 { width: 15% !important; }
.w-20 { width: 20% !important; }
.w-30 { width: 30% !important; }
.w-40 { width: 40% !important; }
.w-60 { width: 60% !important; }
.w-70 { width: 70% !important; }
.w-80 { width: 80% !important; }
.w-90 { width: 90% !important; }
.x-small {
    font-size: 65%;
}
.btn:focus {
    outline: none;
}
.ui-front {
    z-index: 9999;
}
.badge {
    padding: .35em .4em .25em;
}
.form-check-inline {
    margin-right: 0 !important;
}
.form-select {
    font-size: 0.9rem;
}
.form-select option {
    padding: .25em .125em;
}
.ui-autocomplete {
    overflow: auto;
    max-height: 280px;
}
.lista-intercalada > li:nth-child(even), .ui-autocomplete > li:nth-child(even) {
    background-color: var(--bs-light);
}
.table thead th[rel] {
    position: relative;
}
.table thead th[rel]:before {
    font-family: "Font Awesome 5 Free", "FontAwesome Solid", "FontAwesome";
    font-weight: 900;
    position: absolute;
    content: "";
    float: right;
    right: 0.5rem;
    opacity: .25;
    top: 30%;
}
.table thead th[rel]:hover:before {
    content: "0dc";
}
.table thead th[rel].orden-columna-asc:before {
    content: "0de";
    opacity: .75;
}
.table thead th[rel].orden-columna-desc:before {
    content: "0dd";
    opacity: .75;
}
.campo-numero .boton-incremento, .campo-numero .boton-decremento {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    padding: 0 .5rem;
    cursor: pointer;
}
.campo-numero .boton-incremento {
    -webkit-mask: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='-1.25 0 6 2'><path d='M2 0L0 2h4zm0'/></svg>") no-repeat 50% 50%;
    mask: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='-1.25 0 6 2'><path d='M2 0L0 2h4zm0'/></svg>") no-repeat 50% 50%;
}
.campo-numero .boton-decremento {
    -webkit-mask: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='-1.25 2.25 6 4'><path d='M2 5L0 3h4z'/></svg>") no-repeat 50% 50%;
    mask: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='-1.25 2 6 4'><path d='M2 5L0 3h4z'/></svg>") no-repeat 50% 50%;
}

/*
 * Estructura
 */
#contenedorPrincipal {
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
}
#bloqueLateral.offcanvas {
    --bs-offcanvas-width: 340px;
    font-family: var(--bs-font-sans-serif) !important;
    font-feature-settings: "cv01","cv02","cv03","cv04","cv09","cv11" !important;
}
#bloqueLateral .offcanvas-header {
    height: 3.125em;
    min-height: 3.125em;
}
#bloqueMenu {
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
}
#bloqueCentral {
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
}
#bloqueSuperior {
    min-height: 3.125em;
    flex-shrink: 0;
}
#bloqueSuperior .btn {
    padding: 0.35rem 0.55rem;
}
#logoSuperior {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
}
#logoSuperior svg,
#bloqueLateral svg,
.offcanvas-header svg {
    height: 32px;
    width: auto;
    max-width: 100%;
}
.menu-copropiedades-dropdown {
    max-height: 320px;
    overflow-y: auto;
    min-width: 240px;
    max-width: 360px;
}
.menu-usuario-dropdown {
    min-width: 220px;
    max-width: 320px;
}
.item-cambiar-copropiedad {
    cursor: pointer;
}
.item-cambiar-copropiedad:hover {
    background-color: var(--bs-light);
}
#botonPerfilUsuario {
    border-top: 0 !important;
    border-left: 0 !important;
    border-right: 0 !important;
    border-radius: 0 !important;
    text-align: left;
}
#botonPerfilUsuario:focus,
#botonPerfilUsuario:active {
    box-shadow: none !important;
}
.card > .position-absolute.top-0.end-0.rounded-circle,
.position-absolute.top-0.end-0.rounded-circle:has(.menu-acciones-registro) {
    width: 2rem;
    height: 2rem;
    padding: 0 !important;
    transition: background-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
.card > .position-absolute.top-0.end-0.rounded-circle:hover,
.position-absolute.top-0.end-0.rounded-circle:has(.menu-acciones-registro):hover {
    background-color: #fff !important;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.15) !important;
}
.menu-acciones-registro {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}
.menu-acciones-registro .menu-acciones {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    text-decoration: none;
    line-height: 1;
    color: inherit;
}
.menu-acciones-registro .menu-acciones:hover i {
    color: var(--bs-dark) !important;
}
.menu-acciones-registro .dropdown-menu,
.menu-acciones-general .dropdown-menu {
    z-index: 1050;
    min-width: 140px;
}
#bloqueComponente {
    position: relative;
    overflow: auto;
    flex: 1 1 auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}
#bloqueComponente:has(#contenedorComponente) {
    overflow: hidden;
    padding-bottom: 0.25rem;
}
#bloqueComponente:has(#contenedorComponente) > .align-self-stretch.flex-fill {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}
#contenedorComponente {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}
#contenedorComponente > .card {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
    margin-bottom: 0 !important;
    overflow: hidden;
    border-radius: var(--bs-card-border-radius);
}
#contenedorComponente > .card > .card-header {
    flex-shrink: 0;
    z-index: 3;
}
#contenedorComponente > .card > .card-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    padding: 0 !important;
}
#contenedorComponente > .card > .card-body > .container-fluid {
    flex-shrink: 0;
    background-color: var(--bs-body-bg, #fff);
    padding: 0.75rem 1rem !important;
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
    margin-bottom: 0 !important;
    z-index: 2;
}
#contenedorComponente > .card > .card-body > .row {
    display: flex;
    flex-wrap: wrap;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem 1rem 0.5rem 1rem !important;
    margin-top: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    align-content: flex-start;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    scrollbar-width: thin;
}
#contenedorComponente > .card > .card-body > .row::-webkit-scrollbar {
    width: 6px;
}
#contenedorComponente > .card > .card-body > .row::-webkit-scrollbar-track {
    background: transparent;
}
#contenedorComponente > .card > .card-body > .row::-webkit-scrollbar-thumb {
    background-color: var(--bs-secondary-border-subtle, #ced4da);
    border-radius: 3px;
}
#contenedorComponente > .card > .card-body > .row::-webkit-scrollbar-thumb:hover {
    background-color: var(--bs-secondary, #6c757d);
}
#contenedorComponente > .card > .card-body > .table-responsive {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 1rem;
    margin: 0;
}
#contenedorComponente > .card > .card-footer {
    flex-shrink: 0;
    margin-top: auto;
    border-top: 1px solid var(--bs-border-color, #dee2e6);
    z-index: 3;
}
#bloqueInferior {
    font-size: 0.75rem;
    overflow: hidden;
    flex-shrink: 0;
    z-index: 10;
}
#paginaInicio #bloqueSuperior {
    min-height: 5.5em;
}
#paginaInicio #logoSuperior {
    width: 100%;
    justify-content: center;
}
#paginaInicio #logoSuperior svg {
    height: 64px;
}
#mensajeEspera {
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 9999;
    opacity: .85;
    filter: alpha(opacity=85);
}
#bloqueInicioSesion {
    width: 100%;
    max-width: 380px;
    margin-left: auto;
    margin-right: auto;
}
#menu-lateral a {
    text-decoration: none;
}

/* ── Acordeón del menú lateral ─────────────────────────── */
#menu-lateral {
    --menu-item-hover-bg: #dae0e5;
    font-family: var(--bs-font-sans-serif) !important;
    font-feature-settings: "cv01","cv02","cv03","cv04","cv09","cv11" !important;
}
#menu-lateral,
#menu-lateral .accordion-button,
#menu-lateral .accordion-header,
#menu-lateral .nivel-1,
#menu-lateral .nivel-2,
#menu-lateral .nivel-3,
#menu-lateral .list-group-item,
#menu-lateral button,
#menu-lateral span,
#menu-lateral a {
    font-family: var(--bs-font-sans-serif) !important;
    font-feature-settings: "cv01","cv02","cv03","cv04","cv09","cv11" !important;
}
#menu-lateral .accordion-button {
    color: inherit;
    background-color: transparent;
    border: 0;
    box-shadow: none;
    font-size: 0.95rem;
    font-weight: 500;
    font-family: var(--bs-font-sans-serif) !important;
    font-feature-settings: "cv01","cv02","cv03","cv04","cv09","cv11" !important;
}
#menu-lateral .accordion-button:focus {
    box-shadow: none;
    border-color: transparent;
}
#menu-lateral .accordion-button:not(.collapsed) {
    box-shadow: none;
}
#menu-lateral .accordion-button::after {
    filter: brightness(0) invert(1);
    background-size: 0.75rem;
    width: 0.75rem;
    height: 0.75rem;
}
#menu-lateral .list-group-item {
    font-size: 0.9rem;
}
#menu-lateral .list-group-item:hover,
#menu-lateral .list-group-item:focus {
    background-color: var(--menu-item-hover-bg) !important;
}
#menu-lateral .list-group-item.active,
#menu-lateral .list-group-item.active:hover,
#menu-lateral .list-group-item.active:focus {
    background-color: var(--menu-item-hover-bg) !important;
    color: #081732 !important;
}

/*
 * Clases de utilidad y retrocompatibilidad
 */
.oculto {
    display: none !important;
}
.centrado, .centrada {
    text-align: center !important;
}
.derecha {
    text-align: right !important;
}
.izquierda {
    text-align: left !important;
}
.negrilla {
    font-weight: 600 !important;
}
.numero-entero {
    text-align: right !important;
}
.etiquetaFormulario {
    font-weight: 700;
}
.campo-hora {
    text-transform: uppercase;
}
.menu-seleccion-multiple {
    max-height: 360px;
    overflow: hidden;
    overflow-y: auto;
}
.indicador-espera-campo {
    background: transparent url("imagenes/loading.svg") scroll no-repeat 100% 50%;
    background-size: contain;
}
.lista-simple, .lista-simple ul {
    list-style-type: none !important;
    padding-left: 0;
}
#historial-chat {
    overflow: hidden;
    overflow-y: auto;
    max-height: 265px;
}
.chat-enviado, .chat-recibido {
    position: relative;
    background: var(--bs-light);
    border-radius: .4em;
}
.chat-enviado {
    margin: .125em 0 .125em 25%;
}
.chat-recibido {
    margin: .125em 25% .125em 0;
}
.chat-enviado:after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    width: 0;
    height: 0;
    border: 0.5em solid transparent;
    border-right: 0;
    margin-top: -0.5em;
    margin-right: -0.5em;
}
.chat-recibido:after {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 0;
    height: 0;
    border: 0.5em solid transparent;
    border-left: 0;
    margin-top: -0.5em;
    margin-left: -0.5em;
}

/* ═══════════════════════════════════════════════════════
   Componente: Asistente IA
   ═══════════════════════════════════════════════════════ */

/* Contenedor del chat */
.chat-contenedor {
    display : flex;
    height  : 500px;
}

/* Sidebar de conversaciones */
.chat-sidebar {
    width            : 200px;
    min-width        : 200px;
    border-right     : 1px solid #dee2e6;
    overflow-y       : auto;
    background-color : #f8f9fa;
}

.chat-principal {
    flex           : 1;
    display        : flex;
    flex-direction : column;
    min-width      : 0;
}

/* Área de mensajes */
#chatMensajes {
    flex             : 1;
    overflow-y       : auto;
    padding          : 14px;
    background-color : #f8f9fa;
}

/* Barra de entrada */
.chat-entrada {
    flex-shrink : 0;
}

/* ── Burbujas ────────────────────────────────────────── */
.burbuja {
    max-width     : 75%;
    padding       : 9px 13px;
    border-radius : 16px;
    font-size     : 0.9rem;
    line-height   : 1.5;
    word-break    : break-word;
}

.burbuja-usuario {
    background-color           : #0d6efd;
    color                      : #fff;
    border-bottom-right-radius : 3px;
}

.burbuja-ia {
    background-color          : #ffffff;
    color                     : #212529;
    border                    : 1px solid #dee2e6;
    border-bottom-left-radius : 3px;
}

/* ── Indicador "escribiendo..." ──────────────────────── */
.escribiendo span {
    display       : inline-block;
    width         : 7px;
    height        : 7px;
    margin        : 0 2px;
    background    : #6c757d;
    border-radius : 50%;
    animation     : iaEscribiendo 1.2s infinite;
}
.escribiendo span:nth-child(2) { animation-delay: .2s; }
.escribiendo span:nth-child(3) { animation-delay: .4s; }

@keyframes iaEscribiendo {
    0%, 60%, 100% { opacity: .2; transform: scale(1);   }
    30%           { opacity:  1; transform: scale(1.3); }
}

/* ── Indicador de escucha activa ─────────────────────── */
.chat-indicador-voz {
    font-weight    : 500;
    letter-spacing : 0.02em;
}

.animacion-pulso {
    animation: pulsoRojo 1s infinite;
}

@keyframes pulsoRojo {
    0%, 100% { opacity: 1;   }
    50%      { opacity: 0.3; }
}

/* Botón micrófono activo */
#botonMicrofono.btn-danger {
    box-shadow : 0 0 0 0.2rem rgba(220, 53, 69, 0.4);
}

/* ── Panel de conversaciones ─────────────────────────── */
.item-conversacion {
    padding       : 8px 10px;
    border-bottom : 1px solid #e9ecef;
    cursor        : pointer;
    transition    : background-color 0.15s;
}

.item-conversacion:hover {
    background-color : #e9ecef;
}

.item-conversacion.activa {
    background-color : #d1ecf1;
    border-left      : 3px solid #0d6efd;
}

.titulo-conversacion {
    font-size     : 0.82rem;
    font-weight   : 500;
    white-space   : nowrap;
    overflow      : hidden;
    text-overflow : ellipsis;
}

.fecha-conversacion {
    font-size : 0.7rem;
}

/* ── Toggle de voz ───────────────────────────────────── */
.input-group .form-check {
    margin : 0;
    padding-left : 1.8rem;
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
    .chat-sidebar {
        width     : 100%;
        min-width : 100%;
        height    : auto;
        max-height: 120px;
        border-right  : none;
        border-bottom : 1px solid #dee2e6;
    }

    .chat-contenedor {
        flex-direction : column;
        height         : 70vh;
    }
}

/* ── Tooltips personalizados (tema alert-info) ───────── */
.custom-tooltip-info,
.tooltip-info {
    --bs-tooltip-bg: #cff4fc !important;
    --bs-tooltip-color: #055160 !important;
    --bs-tooltip-opacity: 1 !important;
}

.custom-tooltip-info .tooltip-inner,
.tooltip-info .tooltip-inner {
    background-color: #cff4fc !important;
    color: #055160 !important;
    border: 1px solid #9eeaf9 !important;
    box-shadow: 0 0.125rem 0.35rem rgba(5, 81, 96, 0.18) !important;
}

/* Flecha arriba */
.custom-tooltip-info.bs-tooltip-top .tooltip-arrow::before,
.custom-tooltip-info.bs-tooltip-auto[data-popper-placement^="top"] .tooltip-arrow::before,
.custom-tooltip-info.bs-tooltip-top .arrow::before,
.custom-tooltip-info.bs-tooltip-auto[data-popper-placement^="top"] .arrow::before,
.tooltip-info.bs-tooltip-top .tooltip-arrow::before,
.tooltip-info.bs-tooltip-auto[data-popper-placement^="top"] .tooltip-arrow::before,
.tooltip-info.bs-tooltip-top .arrow::before,
.tooltip-info.bs-tooltip-auto[data-popper-placement^="top"] .arrow::before {
    border-top-color: #cff4fc !important;
}

/* Flecha abajo */
.custom-tooltip-info.bs-tooltip-bottom .tooltip-arrow::before,
.custom-tooltip-info.bs-tooltip-auto[data-popper-placement^="bottom"] .tooltip-arrow::before,
.custom-tooltip-info.bs-tooltip-bottom .arrow::before,
.custom-tooltip-info.bs-tooltip-auto[data-popper-placement^="bottom"] .arrow::before,
.tooltip-info.bs-tooltip-bottom .tooltip-arrow::before,
.tooltip-info.bs-tooltip-auto[data-popper-placement^="bottom"] .tooltip-arrow::before,
.tooltip-info.bs-tooltip-bottom .arrow::before,
.tooltip-info.bs-tooltip-auto[data-popper-placement^="bottom"] .arrow::before {
    border-bottom-color: #cff4fc !important;
}

/* Flecha derecha */
.custom-tooltip-info.bs-tooltip-end .tooltip-arrow::before,
.custom-tooltip-info.bs-tooltip-auto[data-popper-placement^="right"] .tooltip-arrow::before,
.custom-tooltip-info.bs-tooltip-right .tooltip-arrow::before,
.custom-tooltip-info.bs-tooltip-end .arrow::before,
.custom-tooltip-info.bs-tooltip-auto[data-popper-placement^="right"] .arrow::before,
.custom-tooltip-info.bs-tooltip-right .arrow::before,
.tooltip-info.bs-tooltip-end .tooltip-arrow::before,
.tooltip-info.bs-tooltip-auto[data-popper-placement^="right"] .tooltip-arrow::before,
.tooltip-info.bs-tooltip-right .tooltip-arrow::before,
.tooltip-info.bs-tooltip-end .arrow::before,
.tooltip-info.bs-tooltip-auto[data-popper-placement^="right"] .arrow::before,
.tooltip-info.bs-tooltip-right .arrow::before {
    border-right-color: #cff4fc !important;
}

/* Flecha izquierda */
.custom-tooltip-info.bs-tooltip-start .tooltip-arrow::before,
.custom-tooltip-info.bs-tooltip-auto[data-popper-placement^="left"] .tooltip-arrow::before,
.custom-tooltip-info.bs-tooltip-left .tooltip-arrow::before,
.custom-tooltip-info.bs-tooltip-start .arrow::before,
.custom-tooltip-info.bs-tooltip-auto[data-popper-placement^="left"] .arrow::before,
.custom-tooltip-info.bs-tooltip-left .arrow::before,
.tooltip-info.bs-tooltip-start .tooltip-arrow::before,
.tooltip-info.bs-tooltip-auto[data-popper-placement^="left"] .tooltip-arrow::before,
.tooltip-info.bs-tooltip-left .tooltip-arrow::before,
.tooltip-info.bs-tooltip-start .arrow::before,
.tooltip-info.bs-tooltip-auto[data-popper-placement^="left"] .arrow::before,
.tooltip-info.bs-tooltip-left .arrow::before {
    border-left-color: #cff4fc !important;
}
