/* ═══════════════════════════════════════════
   shared.css — Estilos compartidos del sitio
   Incluye: reset, header, tabla, paginación,
   overlay, responsive, accesibilidad.
   ═══════════════════════════════════════════ */

/* ── Reset y base ── */
html {
    font-size: 62.5%;
    box-sizing: border-box;
}

*, *::before, *::after {
    box-sizing: inherit;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
    margin: 0;
    padding: 1.6rem;
    background-color: #f5f5f5;
    color: #222;
}

/* ── Header ── */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.6rem;
    padding: 1.6rem 2rem;
    background-color: #fff;
    border-radius: 0.8rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    margin-bottom: 2rem;
}

.header .tabela {
    background-color: transparent;
    padding: 0;
}

.header .a2 {
    font-size: 2.2rem;
    font-weight: 600;
    text-align: right;
}

/* ── Main layout ── */
.main {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* ── Controles (buscador) ── */
.controls {
    background-color: #fff;
    padding: 1.6rem 2rem;
    border-radius: 0.8rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.search-group {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    max-width: 40rem;
}

.search-group label {
    font-size: 1.4rem;
    font-weight: 500;
}

.search-group input[type="search"] {
    padding: 0.8rem 1.2rem;
    border-radius: 0.6rem;
    border: 1px solid #ccc;
    font-size: 1.4rem;
}

.search-group input[type="search"]:focus {
    outline: 2px solid #008756;
    outline-offset: 1px;
}

.search-group small {
    font-size: 1.2rem;
    color: #666;
}

/* ── Sección de tabla ── */
.table-section {
    background-color: #fff;
    padding: 1.6rem 2rem;
    border-radius: 0.8rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
}

.code-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1.4rem;
    min-width: 32rem;
}

.code-table thead {
    background-color: #008756;
    color: #fff;
}

.code-table th,
.code-table td {
    padding: 0.8rem 1.2rem;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
    word-break: break-word;            /* Evita desbordes en textos largos */
    hyphens: auto;                     /* Guiones automáticos si aplica */
}

.code-table th {
    cursor: pointer;
    user-select: none;
}

.code-table th::after {
    content: " \2195";
    font-size: 1.2rem;
    margin-left: 0.4rem;
    opacity: 0.6;
}

.code-table th.sorted-asc::after {
    content: " \2191";
    opacity: 1;
}

.code-table th.sorted-desc::after {
    content: " \2193";
    opacity: 1;
}

.code-table tbody tr {
    cursor: pointer;
}

.code-table tbody td {
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0, 135, 86, 0.2);
}

.code-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

.code-table tbody tr:hover {
    background-color: #e3f4ec;
}

/* ── Footer de la tabla ── */
.table-footer {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-top: 1.2rem;
}

.no-results {
    margin: 0;
    font-size: 1.3rem;
    color: #b00020;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: flex-end;
    font-size: 1.3rem;
}

.page-btn {
    padding: 0.5rem 1.2rem;
    border-radius: 0.6rem;
    border: none;
    background-color: #008756;
    color: #fff;
    cursor: pointer;
    font-size: 1.3rem;
}

.page-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.page-info {
    color: #555;
}

/* ── Overlay de información de fila ── */
.row-info-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.6rem;
    background-color: rgba(0, 0, 0, 0.4);
}

.row-info-overlay[hidden] {
    display: none;
}

.row-info-cajita {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    background-color: #fff;
    padding: 1.6rem;
    border-radius: 0.8rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    width: 100%;
}

.row-info-content {
    font-size: 1.4rem;
    line-height: 1.5;
    margin: 0;
    color: #222;
}

.row-info-close {
    display: block;
    width: 100%;
    padding: 0.8rem 1.2rem;
    border: none;
    border-radius: 0.6rem;
    background-color: #008756;
    color: #fff;
    font-size: 1.4rem;
    font-weight: 600;
    cursor: pointer;
}

.row-info-close:hover {
    background-color: #006d42;
}

/* ── Botón volver al inicio ── */
.back-home {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 2rem;
    padding: 0.6rem 1.2rem;
    min-height: 44px;                  /* Área táctil WCAG */
    background-color: #1e293b;
    color: #e5e7eb;
    text-decoration: none;
    font-size: 1.3rem;
    border-radius: 0.6rem;
    transition: background-color 0.15s ease-out;
}

.back-home:hover {
    background-color: #334155;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    body {
        padding: 1.2rem;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header .a2 {
        text-align: left;
        font-size: 1.8rem;
    }

    .controls,
    .table-section {
        padding: 1.2rem 1.4rem;
    }

    .row-info-cajita {
        width: 90%;
        max-width: 90%;
    }

    .row-info-close {
        min-height: 44px;
        padding: 1rem 1.2rem;
    }
}

/* ── Modo card para móvil (≤480px) ── */
@media (max-width: 480px) {
    .table-wrapper {
        overflow-x: visible;            /* Desactivamos scroll horizontal */
    }

    /* Convertir tabla a bloques */
    .code-table,
    .code-table thead,
    .code-table tbody,
    .code-table tr,
    .code-table th,
    .code-table td {
        display: block;
    }

    /* Ocultar cabeceras — se muestran como data-label */
    .code-table thead {
        display: none;
    }

    /* Cada fila se convierte en una card independiente */
    .code-table tr {
        margin-bottom: 1rem;
        border: 1px solid #d0d0d0;
        border-radius: 0.8rem;
        padding: 1rem;
        background-color: #fff;
    }

    /* Celdas en vertical con su label */
    .code-table td {
        padding: 0.35rem 0;
        border: none;
        font-size: 1.3rem;
        line-height: 1.4;
    }

    /* El label de la cabecera se muestra como ::before */
    .code-table td::before {
        content: attr(data-label) ": ";
        font-weight: 600;
        color: #555;
        display: inline;
    }

    /* Cards alternadas: impares blanco, pares verde suave */
    .code-table tbody tr:nth-child(odd) {
        background-color: #fff;
    }

    .code-table tbody tr:nth-child(even) {
        background-color: #ecf5ef;
    }

    .code-table tbody tr:hover {
        background-color: #d8ebe0;
    }

    /* Paginación centrada y más compacta */
    .pagination {
        justify-content: center;
        flex-wrap: wrap;
    }

    .page-btn {
        font-size: 1.4rem;
        padding: 0.7rem 1.6rem;
    }
}

/* ── Accesibilidad: movimiento reducido ── */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}