/* Overrides mínimos para Tabler.
   - Dejar el layout y tipografías a Tabler
   - Mantener lógica SPA: mostrar/ocultar secciones
   - Mantener modal custom (IP details) usado por JS actual
*/

/* Bootstrap usa .d-flex { display:flex !important; } y puede pisar [hidden].
   Forzamos hidden a nivel autor para que siempre oculte. */
[hidden] { display: none !important; }

/* Base (light y dark): primaria en escala de grises (evitar azul por defecto) */
:root {
    --tblr-primary: #6b7280;            /* gray-500 */
    --tblr-primary-rgb: 107, 114, 128;
    --bs-primary: #6b7280;
    --bs-primary-rgb: 107, 114, 128;
}

/* Controles de overview: se manejan via atributo [hidden] desde JS */

/* Dark mode más "gris" y menos negro puro (premium enterprise) */
[data-bs-theme="dark"] {
    /* Enterprise dark (gris neutro, "negro claro", sin azul) */
    --tblr-body-bg: #202226;
    --tblr-bg-surface: #2a2d33;
    --tblr-card-bg: #2a2d33;
    --tblr-bg-forms: #262930;
    --tblr-border-color: rgba(255, 255, 255, 0.10);
    --tblr-muted: rgba(255, 255, 255, 0.62);
    /* primario en escala de grises (no azul) */
    --tblr-primary: #a1a1aa;            /* zinc-400 */
    --tblr-primary-rgb: 161, 161, 170;
    --tblr-link-color: #d4d4d8;
    --bs-primary: #a1a1aa;
    --bs-primary-rgb: 161, 161, 170;
}

html[data-bs-theme="dark"] body,
body[data-bs-theme="dark"] {
    background-color: var(--tblr-body-bg) !important;
}

html[data-bs-theme="dark"] .card,
body[data-bs-theme="dark"] .card {
    background-color: var(--tblr-card-bg) !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}

html[data-bs-theme="dark"] .navbar-vertical,
body[data-bs-theme="dark"] .navbar-vertical {
    background-color: #23262c !important;
    border-right-color: rgba(255, 255, 255, 0.08) !important;
}

html[data-bs-theme="dark"] .navbar,
body[data-bs-theme="dark"] .navbar {
    background-color: rgba(36, 39, 45, 0.86) !important;
    backdrop-filter: blur(6px);
}

/* Botones primarios en gris (evita azul) */
[data-bs-theme="dark"] .btn-primary {
    --bs-btn-color: #e5e7eb;
    --bs-btn-bg: rgba(161, 161, 170, 0.18);
    --bs-btn-border-color: rgba(161, 161, 170, 0.35);
    --bs-btn-hover-color: #ffffff;
    --bs-btn-hover-bg: rgba(161, 161, 170, 0.28);
    --bs-btn-hover-border-color: rgba(161, 161, 170, 0.55);
    --bs-btn-active-bg: rgba(161, 161, 170, 0.32);
    --bs-btn-active-border-color: rgba(161, 161, 170, 0.65);
    --bs-btn-focus-shadow-rgb: 161, 161, 170;
}

.section { display: none; }
.section.active { display: block; }

.loading {
    text-align: center;
    padding: 28px 10px;
    color: var(--tblr-muted, #6c757d);
}

/* SweetAlert2: que no se vea "blanco horrible" en dark */
[data-bs-theme="dark"] .swal2-popup,
[data-bs-theme="dark"] .swal2-toast {
    background: #111827 !important;
    color: #e5e7eb !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

[data-bs-theme="dark"] .swal2-title,
[data-bs-theme="dark"] .swal2-html-container {
    color: #e5e7eb !important;
}

[data-bs-theme="light"] .swal2-popup,
[data-bs-theme="light"] .swal2-toast {
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
}

/* Enlaces de IP (tablas) */
.ip-link {
    text-decoration: none;
    font-weight: 600;
}
.ip-link:hover { text-decoration: underline; }

[data-bs-theme="dark"] .ip-link {
    color: #d4d4d8;
}

[data-bs-theme="dark"] .ip-link:hover {
    color: #ffffff;
}

/* Tabs en gris (evitar azul por defecto) */
[data-bs-theme="dark"] .nav-tabs .nav-link.active,
[data-bs-theme="dark"] .nav-tabs .nav-item.show .nav-link {
    border-color: rgba(161, 161, 170, 0.45) rgba(161, 161, 170, 0.45) transparent !important;
}

[data-bs-theme="dark"] .nav-tabs .nav-link {
    color: rgba(255, 255, 255, 0.65);
}

/* Sidebar "magia": headings y activo más marcado */
.sidebar-heading {
    letter-spacing: .12em;
    font-size: .72rem;
    padding-top: .25rem;
    padding-bottom: .25rem;
}

.navbar-vertical .nav-link.js-nav-link.active {
    position: relative;
    font-weight: 700;
}

.navbar-vertical .nav-link.js-nav-link.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 3px;
    background: var(--tblr-primary, #206bc4);
}

/* Resultado de BUSCAR */
.swiss-result { margin-top: 10px; }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.detail-item { min-width: 0; }

.detail-label {
    color: var(--tblr-muted, #6c757d);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.detail-value {
    font-weight: 600;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.detail-item-full { grid-column: 1 / -1; }

.detail-section { margin-bottom: 18px; }
.detail-section h4 {
    font-size: 1rem;
    margin-bottom: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.swiss-table { min-width: 900px; }

/* Modal: ahora se usa el modal nativo de Bootstrap/Tabler (sin overrides). */

/* Header "cuadrado": evita que el select/btn se achiquen raro en pantallas medianas */
#timeRange { max-width: 240px; }

/* DNI: domicilios accordion compacto */
#domiciliosAccordion .accordion-item { border-left: 0; border-right: 0; }
#domiciliosAccordion .accordion-button { background: transparent; box-shadow: none; }
#domiciliosAccordion .accordion-button:not(.collapsed) { background: rgba(128,128,128,.08); }
#domiciliosAccordion .accordion-button::after {
    flex-shrink: 0;
    width: 1rem; height: 1rem;
    margin-left: .5rem;
    content: "";
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%236b7280'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-size: 1rem;
    transition: transform .2s ease-in-out;
}
#domiciliosAccordion .accordion-button:not(.collapsed)::after { transform: rotate(-180deg); }
.dom-acc-item { cursor: pointer; transition: background .15s; }
.dom-acc-item:hover { background: rgba(128,128,128,.05); }
#domiciliosAccordion .accordion-body table th { font-weight: 600; opacity: .6; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; }
#domiciliosAccordion .accordion-body table td { padding: 4px 8px; }
.detail-section h4 { font-weight: 600; }

@media (max-width: 768px) {
    .detail-grid { grid-template-columns: 1fr; }
    .swiss-table { min-width: 700px; }
}
