/* =====================================================
   DESIGN TOKENS
===================================================== */

:root {
    --color-primary:        #611232;
    --color-primary-light:  #7b173e;
    --color-accent:         #A8163D;

    --color-bg-main:        #ffffff;
    --color-bg-soft:        #EBEBEB;

    --color-text-main:      #161A1D;
    --color-text-secondary: #2d3436;
    --color-text-muted:     #444446;

    --color-border-light:   #ddd;

    --font-heading: 'Patria', serif;
    --font-body:    'Noto', sans-serif;

    --shadow-soft:   0 6px 18px rgba(0,0,0,0.06);
    --shadow-medium: 0 10px 24px rgba(0,0,0,0.12);

    --transition-fast:   0.2s ease;
    --transition-medium: 0.25s ease;
}

/* =====================================================
   FUENTES
===================================================== */

@font-face {
    font-family: 'Patria';
    src: url('/static/assets/fonts/HalisRBlack.woff2') format('woff2');
    font-weight: 700;
}

@font-face {
    font-family: 'Noto';
    src: url('/static/assets/fonts/NotoSans-Regular.woff2') format('woff2');
    font-weight: 400;
}

/* =====================================================
   BASE
===================================================== */

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    background-color: var(--color-bg-main);
    color: var(--color-text-secondary);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}


/* =====================================================
   TIPOGRAFÍA
===================================================== */

h1 {
    font-family: var(--font-heading);
    font-size: clamp(28px, 3.5vw, 72px);
    letter-spacing: -0.04em;
    margin: 4vh 0 0 4vw;
    color: var(--color-accent);
}

h2 {
    font-family: var(--font-body);
    font-weight: 600;
    text-align: center;
    color: var(--color-text-main);
}

h3 {
    font-family: var(--font-heading);
    text-align: center;
    color: var(--color-text-main);
}

h4 {
    font-family: var(--font-body);
    color: var(--color-accent);
}

/* =====================================================
   HEADER
===================================================== */

.header {
    position: relative;
    width: 100%;
    padding: 20px 4vw;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: white;
    border-bottom: 1px solid #eee;
    z-index: 100;
}

.logo { width: clamp(140px, 40vw, 200px); }

.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.estado-label {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-primary);
}

/* =====================================================
   HERO
===================================================== */

.hero {
    width: 100%;
    aspect-ratio: 16 / 6.5;
    position: relative;
    background: url("/static/assets/logo/maqueta2.svg") center / cover no-repeat;
    overflow: hidden;
}

.hero-content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* =====================================================
   BOTONES
===================================================== */

/* Navegación por tabs */
.buttons {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-top: 40px;
}

.btn {
    background: transparent;
    text-decoration: none;
    border: none;
    padding: 10px 18px;
    font-size: 20px;
    color: var(--color-text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: var(--transition-fast);
}

.btn:hover { color: black; }
.btn.activo { border-bottom-color: black; }
.btn img { width: 16px; height: 16px; }

/* Header */
.btn-login {
    padding: 8px 18px;
    border-radius: 6px;
    font-size: 14px;
    text-decoration: none;
    background: var(--color-primary);
    color: white;
    transition: var(--transition-fast);
}

.btn-login:hover { background: var(--color-primary-light); }

.btn-login.secondary {
    background: transparent;
    border: 1px solid var(--color-primary);
    color: var(--color-primary);
}

.btn-login.secondary:hover {
    background: var(--color-primary);
    color: white;
}

/* Home */
.btn-home {
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    background: var(--color-primary);
    color: white;
    transition: var(--transition-fast);
    white-space: nowrap;
}

.btn-home:hover { background: var(--color-primary-light); }

/* Descarga */
.btn-descarga {
    background: white;
    border: 1px solid var(--color-accent);
    color: var(--color-accent);
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-descarga:hover {
    background: var(--color-accent);
    color: white;
}

/* Expandir */
.btn-expandir {
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    padding: 2px 6px;
    font-size: 11px;
    color: #666;
    transition: var(--transition-fast);
}

.btn-expandir:hover { background: #f0f0f0; }

/* Modal */
.btn-cancel {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    background: #bdc3c7;
    cursor: pointer;
}

.btn-confirm {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    background: #e74c3c;
    color: white;
    font-weight: bold;
    cursor: pointer;
}

/* =====================================================
   BADGES
===================================================== */

.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.badge.pendiente { background: #fdecea; color: #b42318; }
.badge.validado  { background: #e6f4ea; color: #1e7e34; }

.live-badge {
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    background: #e0e0e0;
    color: #999;
    letter-spacing: 0.5px;
    transition: all 0.3s;
}

.live-badge.conectado { background: #d4edda; color: #1a6b35; }

/* =====================================================
   CARDS
===================================================== */

/* Navegación post-login */
.menu-section {
    background-color: var(--color-bg-soft);
    text-align: center;
    padding: 60px 0;
    flex: 1; 
}

.menu-title {
    font-size: 28px;
    margin-bottom: 40px;
    color: var(--color-text-main);
}

.menu { display: flex; justify-content: center; }

.card {
    background-color: white;
    padding: 30px 40px;
    border-radius: 12px;
    font-size: 24px;
    text-decoration: none;
    color: var(--color-text-secondary);
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-shadow: var(--shadow-soft);
    transition: var(--transition-medium);
}

.card img { width: 100%; }

.card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-medium);
}

/* Métricas (tablero) */
.card-metric {
    flex: 1;
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.card-metric h3 {
    margin: 0 0 12px;
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.card-metric p {
    margin: 0;
    font-size: 40px;
    font-weight: 700;
    color: var(--color-accent);
}

/* =====================================================
   LOGIN
===================================================== */

.login-body {
    background-color: #f2f2f2;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.login-container {
    background: white;
    width: 480px;
    padding: 60px 50px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.08);
}

.login-logo img  { width: clamp(60px, 8vw, 120px); }
.login-title     { font-family: var(--font-heading); font-size: 34px; margin: 0; }
.login-subtitle  { font-size: 14px; margin-bottom: 20px; }
.login-error     { color: #b02a37; margin-bottom: 20px; font-size: 14px; }

.login-form input {
    width: 100%;
    padding: 14px;
    margin-bottom: 20px;
    border: 1px solid var(--color-border-light);
    font-size: 16px;
    outline: none;
}

.login-form input:focus { border-color: var(--color-primary); }

.login-button {
    width: 100%;
    padding: 14px;
    background-color: var(--color-accent);
    color: white;
    border: none;
    font-size: 18px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.login-button:hover { background-color: #8d1132; }

/* =====================================================
   PÁGINAS INTERNAS (Entes / Códigos)
   — estilos compartidos entre .inst-body y .codigos-body
===================================================== */

.inst-body,
.codigos-body {
    font-family: var(--font-body);
    background-color: #f7f7f7;
}

.inst-container,
.codigos-container { padding: 40px 60px; }

.inst-body h1,
.codigos-body h1 {
    font-family: var(--font-heading);
    text-align: center;
    font-size: 40px;
    margin-bottom: 5px;
}

.inst-body h2,
.codigos-body h2 {
    font-family: var(--font-body);
    text-align: left;
    font-size: 28px;
    margin-bottom: 25px;
    color: var(--color-text-main);
}

.codigos-body h3 {
    font-family: var(--font-body);
    text-align: left;
    margin-bottom: 25px;
    color: var(--color-text-main);
}

.inst-body input[type="text"],
.codigos-body input[type="text"],
.codigos-body input[type="number"],
.codigos-body input[type="date"] {
    width: 420px;
    padding: 8px;
    border: 1px solid #ccc;
    font-size: 14px;
    margin-top: 4px;
}

.inst-body input[type="text"] { width: 400px; }

.inst-body input:focus,
.codigos-body input:focus {
    border-color: var(--color-primary);
    outline: none;
}

.codigos-body input:disabled {
    background: #f0f0f0;
    color: #888;
    cursor: not-allowed;
}

.inst-body button,
.codigos-body button {
    margin-right: 6px;
    margin-top: 8px;
    cursor: pointer;
    padding: 6px 10px;
    border: none;
    font-size: 14px;
    transition: var(--transition-fast);
}

.inst-body button img {
    width: 16px;
    vertical-align: middle;
    margin-left: 4px;
}

/* Tabs */
.inst-body #tabs button        { background: var(--color-primary); color: white; padding: 8px 14px; }
.inst-body #tabs button:hover  { background: #4a0d25; }
.inst-body #tabs button.activo { background: white; color: var(--color-text-main); border: 1px solid var(--color-primary); }

/* Entes: form-group */
.inst-body .form-group {
    background: white;
    padding: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid #ccc;
    box-shadow: 0 5px 15px rgba(0,0,0,0.03);
}

.inst-body .confirmado {
    background-color: #f0f8f0;
    border-left: 4px solid #4caf50;
}

/* Botones acción entes */
.inst-body .btn-guardar,
.codigos-body .btn-guardar { background: #3AC896; color: white; }

.inst-body .btn-validar,
.codigos-body .btn-validar { background: #2B6BF8; color: white; }

.inst-body .btn-enviar,
.btn-enviar { background: #2B6BF8; color: white; }

/* Códigos: cards */
.codigos-body .card {
    background: white;
    padding: 25px;
    margin-bottom: 25px;
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.04);
    border-left: 4px solid var(--color-primary);
    font-size: inherit;
    gap: 0;
    transform: none;
}

.codigos-body .card p    { font-size: 16px; line-height: 1.4; margin-bottom: 10px; }
.codigos-body .card h3   { margin-bottom: 15px; font-size: 14px; }
.codigos-body #contenedor { max-width: none; }
.codigos-body label      { margin-right: 12px; font-size: 14px; }

/* =====================================================
  TABLERO
===================================================== */
    
.dashboard {
    max-width: 1400px;
    margin: auto;
    padding: 40px;
}

.dashboard-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 30px;
}

.btn-home {
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    background: var(--color-primary, #611232);
    color: white;
    transition: 0.2s ease;
    white-space: nowrap;
}

.btn-home:hover {
    background: var(--color-primary-light, #7b173e);
}

.dashboard-header h1 { margin: 0; }

.panel-header {
    display: flex;
    justify-content: space-between; /* separa título izquierda, botón derecha */
    align-items: center;
}

.live-badge {
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    background: #e0e0e0;
    color: #999;
    letter-spacing: 0.5px;
    transition: all 0.3s;
}

.live-badge.conectado {
    background: #d4edda;
    color: #1a6b35;
}

.cards {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
}

.card-metric {
    flex: 1;
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.card-metric h3 {
    margin: 0 0 12px;
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.card-metric p {
    margin: 0;
    font-size: 40px;
    font-weight: 700;
    color: #9B2247;
}

.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.panel {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.panel h3 {
    margin: 0 0 20px;
    font-size: 15px;
    color: #333;
}

#mapa {
    height: 500px;
    width: 100%;
}

table { width: 100%; border-collapse: collapse; }

th {
    padding: 10px;
    border-bottom: 2px solid #eee;
    text-align: left;
    font-size: 13px;
    color: #666;
    font-weight: 600;
}

td {
    padding: 10px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}

/* =====================================================
   TABLAS
===================================================== */

table,
.tabla-codigos { width: 100%; border-collapse: collapse; }

th {
    padding: 10px 12px;
    border-bottom: 2px solid var(--color-border-light);
    text-align: left;
    font-size: 13px;
    color: #666;
    font-weight: 600;
}

td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}

tr:hover { background: #fafafa; }
.fila-estado { cursor: pointer; }

.tabla-detalle { width: 100%; border-collapse: collapse; background: #fafafa; }
.tabla-detalle th { background: #f5f5f5; font-size: 12px; }
.tabla-detalle td { font-size: 13px; }

.tabla-detalle a         { color: var(--color-accent); text-decoration: none; }
.tabla-detalle a:hover   { text-decoration: underline; }

/* =====================================================
   MODAL
===================================================== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-box {
    background: white;
    width: 420px;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.modal-header { font-size: 20px; font-weight: bold; margin-bottom: 15px; color: #c0392b; }
.modal-body   { font-size: 15px; line-height: 1.5; }
.modal-body ul { margin: 10px 0 15px 20px; }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* =====================================================
   AVISOS
===================================================== */

.aviso-cerrado {
    background: #fdecea;
    border-left: 4px solid #b42318;
    color: #b42318;
    padding: 14px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 24px;
}

.warning { color: #c0392b; font-weight: bold; }

/* =============================================
   LOADER OVERLAY
============================================= */
#loader-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

#loader-overlay.activo {
    display: flex;
}

.loader-box {
    background: #fff;
    border-radius: 12px;
    padding: 36px 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    min-width: 220px;
}

.loader-spinner {
    width: 48px;
    height: 48px;
    border: 5px solid #F5F0F1;
    border-top-color: #A11C3A;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#loader-mensaje {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #A11C3A;
    text-align: center;
    letter-spacing: 0.01em;
}

/* =====================================================
   footer
===================================================== */

.footer-version {
    text-align: center;
    font-size: 11px;
    color: #aaa;
    padding: 12px;
    margin-top: 40px;
    border-top: 1px solid #eee;
}

/* =====================================================
   RESPONSIVE
===================================================== */

@media (max-width: 900px) {
    .buttons       { flex-direction: column; align-items: center; gap: 20px; }
    .header        { flex-direction: column; gap: 10px; }
    h1             { text-align: center; margin-left: 0; padding: 0 5vw; }
}


.controles-barra {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: center;
    margin-bottom: 1.25rem;
}

.buscador-wrapper {
    position: relative;
    flex: 1 1 240px;
}

.buscador-wrapper svg {
    position: absolute;
    left: .75rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #888;
}

#buscadorInput {
    width: 100%;
    padding: .55rem .75rem .55rem 2.4rem;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    font-size: .95rem;
    box-sizing: border-box;
    outline: none;
    transition: border-color .2s;
}
#buscadorInput:focus { border-color: #A11C3A; }

.paginacion-info {
    font-size: .875rem;
    color: #555;
    white-space: nowrap;
}

/* ── Paginación ─────────────────────────────────────────── */
.paginacion {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: .5rem;
    margin: 1.5rem 0 .75rem;
    flex-wrap: wrap;
}

.paginacion button {
    min-width: 2.2rem;
    padding: .35rem .7rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    font-size: .875rem;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}

.paginacion button:hover:not(:disabled) {
    background: #f0e8ea;
    border-color: #A11C3A;
    color: #A11C3A;
}

.paginacion button.activa {
    background: #A11C3A;
    color: #fff;
    border-color: #A11C3A;
    font-weight: 700;
}

.paginacion button:disabled {
    opacity: .4;
    cursor: default;
}

/* ── Sin resultados ─────────────────────────────────────── */
#sinResultados {
    display: none;
    text-align: center;
    color: #888;
    padding: 2rem 0;
    font-size: 1rem;
}

/* ── Botón guardar individual en cada card ──────────────── */
.btn-guardar-card {
    margin-top: .5rem;
    background: #2563EB;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: .45rem 1rem;
    cursor: pointer;
    font-size: .9rem;
    transition: background .2s;
}
.btn-guardar-card:hover { background: #1D4ED8; }
.btn-guardar-card:disabled { opacity: .5; cursor: default; }