/*
 * Densidad de la interfaz: UNICO lugar donde se decide el tamano del texto y el alto de los campos.
 *
 * Taildash mide en `rem`. La raiz queda en 15px (mueve menu lateral, margenes y rellenos) y el texto se
 * controla con la escala de abajo: para hacer todo mas grande o mas pequeno se cambian estas variables,
 * nunca el `font-size` de un componente. Los componentes usan clases de la plantilla (text-xs, text-sm...)
 * y esas clases leen esta escala (ver "Escala tipografica").
 *
 * Este proyecto no compila Tailwind: solo existen las clases que trae style.css; lo demas se define aqui.
 */
:root {
    --fs-base: 0.8667rem;      /* texto general: tablas, campos, selects, botones, parrafos (13 px) */
    --fs-small: 0.8rem;        /* etiquetas de filtro, ayudas, errores, migas, pies (12 px) */
    --fs-title: 0.95rem;       /* titulos de seccion */
    --fs-heading: 1.1rem;      /* titulos de pagina */
    --fs-display: 1.4rem;      /* cifras grandes del panel de inicio */
    --lh-text: 1.35;           /* interlineado del texto corrido */
    --field-lh: 1.1rem;        /* alto de linea dentro de campos y botones */
    --field-py: 0.3rem;        /* relleno vertical de campos, botones y celdas (campo ~27 px) */
    --field-px: 0.75rem;       /* relleno horizontal de campos y celdas */
}
html { font-size: 15px; }
body { font-size: var(--fs-base); }

/* ---- Escala tipografica: las clases de la plantilla leen las variables de arriba. ---- */
.text-xs { font-size: var(--fs-small); line-height: var(--lh-text); }
.text-sm, .text-base { font-size: var(--fs-base); line-height: var(--lh-text); }
.text-lg { font-size: var(--fs-title); line-height: 1.3; }
.text-xl { font-size: var(--fs-heading); line-height: 1.3; }
.text-2xl, .text-3xl { font-size: var(--fs-display); line-height: 1.25; }

/* ---- Campos y botones: una sola medida de alto. `py-1.5` no existe en style.css, se define aqui. ---- */
.py-1\.5 { padding-top: var(--field-py); padding-bottom: var(--field-py); }
input.leading-5, select.leading-5, textarea.leading-5, button.leading-5 { line-height: var(--field-lh); }
button.py-2.px-4 { padding: var(--field-py) var(--field-px); }

/* El contenido nunca debe sobrepasar el ancho de la ventana. */
.wrapper { max-width: 100vw; }

/* El ultimo boton de la paginacion tenia margen negativo (-mr-0.5) para solapar bordes
   y desbordaba el listado ~2px, mostrando una barra de scroll horizontal vacia. */
.dataTable-pagination-list li:last-child button { margin-right: 0; }

/* ------------------------------------------------------------------------------------------
 * Tablas: mismo estilo que MesaFlow.
 * Encabezado de color con un separador fino entre titulos, celdas sin bordes verticales y
 * una linea suave entre filas. Se aplica con la clase `tabla-td` (TableDefault ya la lleva).
 * ------------------------------------------------------------------------------------------ */
.tabla-td { width: 100%; font-size: var(--fs-base); border-collapse: collapse; }
.tabla-td th { position: relative; padding: var(--field-py) var(--field-px); }
.tabla-td th + th::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    height: 1rem;
    width: 1px;
    transform: translateY(-50%);
    background-color: rgba(255, 255, 255, 0.7);
}
.tabla-td tbody tr { border-bottom: 1px solid #e5e7eb; }
.tabla-td tbody tr.td-tr:hover { background-color: #f3f4f6; }
.dark .tabla-td tbody tr { border-bottom-color: #374151; }
.dark .tabla-td tbody tr.td-tr:hover { background-color: #1f2937; }

/* Barra superior de un listado: buscador a la izquierda y "Mostrar N registros" a la derecha. */
.td-top { display: flex; flex-wrap: wrap; align-items: center; margin-top: 0.75rem; margin-bottom: 0.75rem; padding: 0 0.5rem; }
.td-top-buscar { flex: 1 1 16rem; padding-right: 1rem; margin-bottom: 0.25rem; }
.td-top-mostrar { display: flex; align-items: center; margin-left: auto; margin-bottom: 0.25rem; white-space: nowrap; color: #4b5563; font-size: var(--fs-small); }
.td-top-mostrar select { width: 5rem; margin: 0 0.5rem; }

/* Celda de acciones: los botones de fila (clase `accion-fila`, la llevan todos los *ListButton) van siempre
 * en una sola fila, centrados y con la celda del ancho justo. Los botones tienen un margen derecho fijo
 * (ltr:mr-2) que los corria a la izquierda; dentro de una tabla se reparte por igual a ambos lados. */
.tabla-td td:has(.accion-fila) { width: 1%; white-space: nowrap; text-align: center; vertical-align: middle; }
.tabla-td td .accion-fila { margin-left: 0.25rem; margin-right: 0.25rem; vertical-align: middle; }

/* Si la tabla es mas ancha que su tarjeta y se desplaza, la columna de acciones (siempre la ultima)
 * queda fija al borde derecho para que los botones se vean siempre. El encabezado hereda el color del
 * <thead> (que pone el tema) a traves del <tr>. */
.tabla-td thead tr { background-color: inherit; }
.tabla-td:has(td .accion-fila) thead th:last-child { position: sticky; right: 0; z-index: 1; background-color: inherit; }
.tabla-td td:has(.accion-fila):last-child { position: sticky; right: 0; z-index: 1; background-color: #ffffff; }
.tabla-td tbody tr.td-tr:hover > td:has(.accion-fila):last-child { background-color: #f3f4f6; }
.tabla-td tbody tr.bg-gray-300 > td:has(.accion-fila):last-child { background-color: #d1d5db; }
.dark .tabla-td td:has(.accion-fila):last-child { background-color: #1f2937; }

/* ------------------------------------------------------------------------------------------
 * vue-multiselect (SelectBuscable y los selectores asincronos) con la apariencia de un <select> de la plantilla.
 * --acento lo fija el componente en <body> con el color del tema activo (el de .bg-indigo-500).
 * La lista desplegable se dibuja en <body> (Teleport), por eso estos estilos no cuelgan de un contenedor.
 * ------------------------------------------------------------------------------------------ */
.select-buscable { width: 100%; }
:root { --acento: #6366f1; }
body .multiselect { min-height: 0; color: #1f2937; font-size: inherit; line-height: var(--field-lh); }
body .multiselect__tags {
    min-height: 0; padding: var(--field-py) 2rem var(--field-py) var(--field-px);
    background: #fff; border: 1px solid #d1d5db; border-radius: 0.25rem;
}
body .multiselect--active .multiselect__tags,
body .multiselect__tags:hover { border-color: var(--acento); }
body .multiselect__input,
body .multiselect__single {
    min-height: 0; margin: 0; padding: 0; background: transparent; font-size: inherit; line-height: var(--field-lh); color: inherit;
}
body .multiselect__input::placeholder { color: #6b7280; }
body .multiselect__placeholder { margin: 0; padding: 0; color: #6b7280; line-height: var(--field-lh); }
body .multiselect__tags, body .multiselect__placeholder, body .multiselect__input, body .multiselect__single, body .multiselect__option { font-size: inherit; }
body .multiselect__select { top: 0; right: 0; height: 100%; width: 2rem; padding: 0; }
body .multiselect__select::before { display: none; }
body .multiselect__select {
    background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e") no-repeat center / 0.8rem;
    transform: none !important;
}
body .multiselect__content-wrapper {
    border: 1px solid var(--acento); border-top-width: 1px; border-radius: 0.25rem; margin-top: 2px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}
body .multiselect__option { min-height: 0; padding: var(--field-py) var(--field-px); line-height: var(--field-lh); font-size: inherit; }
body .multiselect__option--highlight,
body .multiselect__option--highlight::after { background: var(--acento); color: #fff; }
body .multiselect__option--selected { background: transparent; color: var(--acento); font-weight: 700; }
body .multiselect__option--selected.multiselect__option--highlight,
body .multiselect__option--selected.multiselect__option--highlight::after { background: var(--acento); color: #fff; filter: brightness(0.92); }
body .multiselect__spinner { background: transparent; right: 2rem; top: 0; height: 100%; }
body .multiselect__spinner::before,
body .multiselect__spinner::after { border-top-color: var(--acento); }
body .multiselect--disabled { background: transparent; opacity: 1; }
body .multiselect--disabled .multiselect__tags { background: #f3f4f6; opacity: 0.7; cursor: not-allowed; }
body .multiselect--disabled .multiselect__select { background-color: transparent; }
.dark body .multiselect { color: #d1d5db; }
.dark body .multiselect__tags { background: #374151; border-color: #374151; }
.dark body .multiselect__content-wrapper { background: #374151; }
.dark body .multiselect__option { color: #d1d5db; }
body .multiselect__single { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* Interruptor de activo / inactivo en las filas de una tabla (se alinea como el resto de acciones). */
.interruptor {
    position: relative; display: inline-block; vertical-align: middle; width: 2rem; height: 1.1rem; padding: 0;
    border: 0; border-radius: 9999px; background: #9ca3af; cursor: pointer; transition: background-color .15s;
}
.interruptor > span {
    position: absolute; top: 0.14rem; left: 0.14rem; width: 0.82rem; height: 0.82rem; border-radius: 9999px;
    background: #fff; transition: transform .15s;
}
.interruptor-on { background: var(--acento); }
.interruptor-on > span { transform: translateX(0.9rem); }
body .multiselect__content-wrapper { overflow-x: hidden; }
body .multiselect__option { white-space: normal; overflow-wrap: anywhere; }

/* ------------------------------------------------------------------------------------------
 * Panel de inicio (Dashboard): tarjetas, graficos y listas. Rejillas propias porque Tailwind
 * no se compila en este proyecto (solo existen las clases ya incluidas en style.css).
 * ------------------------------------------------------------------------------------------ */
.dash-box { background: #fff; border-radius: 0.375rem; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08); padding: 0.75rem; min-width: 0; }
.dark .dash-box { background: #1f2937; }
.dash-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr)); gap: 0.75rem; margin-bottom: 0.75rem; }
.dash-fila { display: grid; grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr)); gap: 0.75rem; margin-bottom: 0.75rem; }
.dash-card { display: flex; flex-direction: column; border-left: 4px solid var(--acento, #6366f1); }
.dash-card.dash-alerta { border-left-color: #dc2626; }
.dash-card.dash-alerta .dash-valor { color: #dc2626; }
.dash-etiqueta { font-size: var(--fs-small); color: #6b7280; text-transform: uppercase; letter-spacing: 0.03em; }
.dash-valor { font-size: var(--fs-display); line-height: 1.2; margin: 0.15rem 0; }
.dash-sub { font-size: var(--fs-small); color: #6b7280; }
.dash-titulo { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; margin-bottom: 0.5rem; }
.dash-enlace { font-size: var(--fs-small); font-weight: 400; color: var(--acento, #6366f1); }
.dash-grafico { position: relative; height: 15rem; }
.dash-vacio { color: #6b7280; padding: 0.5rem 0; }
.dash-rojo { color: #dc2626; }
.dash { width: 100%; }
.dash-box { overflow-x: auto; }
.dash-box .tabla-td td { white-space: nowrap; }
.dash-fila.dash-tres { grid-template-columns: repeat(auto-fit, minmax(28rem, 1fr)); }

/* Titulo de pagina (nombre de la pantalla) a la izquierda y ruta de migas a la derecha. */
.titulo-pagina { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 0 1rem; }
.migas { display: flex; align-items: center; gap: 0.4rem; font-size: var(--fs-small); color: #6b7280; }
.migas a { color: inherit; }
.migas a:hover { color: var(--acento, #6366f1); }
.migas-sep { font-size: 0.6rem; opacity: 0.7; }
.migas-actual { color: var(--acento, #6366f1); }

/* Pestanas (tabs): una fila de botones con la activa subrayada en el color del tema. */
.pestanas { display: flex; gap: 0.25rem; border-bottom: 1px solid #d1d5db; margin: 0 0.25rem 0.75rem; }
.pestanas button { padding: 0.5rem 1rem; border: 0; background: transparent; color: #6b7280; border-bottom: 3px solid transparent; margin-bottom: -1px; cursor: pointer; }
.pestanas button:hover { color: var(--acento, #6366f1); }
.pestanas button.pestana-activa { color: var(--acento, #6366f1); border-bottom-color: var(--acento, #6366f1); font-weight: 700; }

/* Acordeon simple (un bloque con titulo desplegable). */
.acordeon { border: 1px solid #e5e7eb; border-radius: 0.25rem; margin: 0 0.5rem 0.75rem; }
.dark .acordeon { border-color: #374151; }
.acordeon-titulo { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 0.6rem 0.75rem; background: #f3f4f6; border: 0; text-align: left; cursor: pointer; font-weight: 600; }
.dark .acordeon-titulo { background: #1f2937; }
.acordeon-flecha { transition: transform .15s; transform: rotate(-90deg); }
.acordeon-flecha.acordeon-abierto { transform: rotate(0); }
.acordeon-cuerpo { padding: 0.5rem 0.25rem; }

/* Filtros de un listado (DataList): cuadricula bajo el buscador, cada filtro con su etiqueta arriba. */
.td-filtros { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 0.5rem 1rem; align-items: end; padding: 0 0.5rem; margin-bottom: 0.9rem; }
.td-filtro { min-width: 0; }
.td-filtro-wide { grid-column: span 2; }
.td-filtro-label { display: block; margin-bottom: 0.2rem; font-size: var(--fs-small); font-weight: 600; color: #6b7280; }
.dark .td-filtro-label { color: #9ca3af; }
.td-filtros-limpiar { justify-self: start; align-self: end; padding: var(--field-py) 0.25rem; font-size: var(--fs-small); color: #6b7280; text-decoration: underline; background: none; border: 0; cursor: pointer; }
.td-filtros-limpiar:hover { color: #4f46e5; }
@media (max-width: 640px) { .td-filtro-wide { grid-column: span 1; } }

/* Registro de credito: aviso del saldo que el credito nuevo absorbe y resumen de lo que se financia. */
.aviso-saldo { margin-top: 0.5rem; padding: 0.5rem 0.75rem; border: 1px solid #f59e0b; border-left-width: 4px; border-radius: 0.25rem; background: #fffbeb; color: #78350f; font-size: var(--fs-small); }
.dark .aviso-saldo { background: #451a03; color: #fde68a; }
.resumen-credito { width: 100%; }
.resumen-credito > div { display: flex; justify-content: space-between; padding: 0.15rem 0; border-bottom: 1px dashed #d1d5db; }
.resumen-credito .resumen-total { font-weight: 700; border-bottom: 0; border-top: 1px solid #6b7280; margin-top: 0.15rem; padding-top: 0.3rem; }

/* Foto de perfil (componente Avatar): mismo fondo en todos lados (las fotos PNG con transparencia se ven igual), recorte centrado y borde suave. */
.avatar { background-color: #ffffff; object-fit: cover; border: 1px solid #d1d5db; }
.avatar-enlace:focus { outline: none; }
.avatar-enlace:focus-visible { outline: 2px solid var(--acento, #6366f1); outline-offset: 2px; border-radius: 9999px; }
.avatar.h-24 { border: 3px solid #ffffff; box-shadow: 0 0 0 1px #d1d5db; }

/* ------------------------------------------------------------------------------------------
 * Detalles de interfaz comunes: selector de sede, casillas y pie de pagina.
 * ------------------------------------------------------------------------------------------ */
.sede-selector { display: inline-block; padding: 0.3rem 0.75rem; border: 1px solid #d1d5db; border-radius: 0.375rem; background: #f9fafb; font-weight: 600; }
.sede-selector:hover { border-color: var(--acento); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--acento); cursor: pointer; vertical-align: middle; }
.pie-sistema { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem; color: #6b7280; }
