/* =========================
   VARIABLES GLOBALES
========================= */
:root {
    --azul-1: #0b3d84;
    --azul-2: #0a4f9d;
    --azul-3: #153f80;
    --azul-texto: #17395e;
    --azul-badge: #0d3f7b;
    --azul-soft: #dbe7f8;

    --gris-borde: #d2dbe7;
    --gris-fondo: rgba(242, 246, 250, 0.93);
    --gris-celda: rgba(255, 255, 255, 0.96);
    --gris-celda-alt: rgba(244, 247, 251, 0.98);

    --verde-1: #179787;
    --verde-2: #0d7f73;
    --verde-soft: #dceee8;

    --rojo-soft: #f5dddd;
    --rojo-texto: #b94a48;

    --naranja-1: #f59b15;
    --naranja-2: #f27c00;

    --sombra: 0 12px 28px rgba(0, 0, 0, 0.14);
    --radio: 16px;
    --radio-sm: 10px;
    --alto-touch: 50px;
    --transicion: 0.18s ease;
}

/* =========================
   RESETEO BASE
========================= */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    min-height: 100%;
    width: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--azul-texto);
    background-image:
        linear-gradient(rgba(7, 36, 79, 0.24), rgba(7, 36, 79, 0.24)),
        url('../img/UNAM.jpg');
    background-position: center center;
    background-repeat: no-repeat;
    background-size: cover;
    background-attachment: fixed;
}

/* =========================
   HEADER PRINCIPAL
========================= */
.topbar {
    width: 100%;
    background: linear-gradient(180deg, var(--azul-1) 0%, var(--azul-2) 100%);
    border-bottom: 6px solid rgba(255, 255, 255, 0.16);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
}

.topbar__inner {
    width: 100%;
    max-width: 1420px;
    min-height: 92px;
    margin: 0 auto;
    padding: 10px 16px;
    display: grid;
    grid-template-columns: 210px minmax(0, 1fr) 210px;
    align-items: center;
    gap: 14px;
}

.topbar__logo {
    display: flex;
    align-items: center;
}

.topbar__logo--left {
    justify-content: flex-start;
}

.topbar__logo--right {
    justify-content: flex-end;
}

.topbar__logo img {
    display: block;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

.topbar__logo--left img {
    max-height: 66px;
}

.topbar__logo--right img {
    max-height: 76px;
}

.topbar__title {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.topbar__title h1 {
    color: #ffffff;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.18);
}

/* =========================
   CONTENIDO PRINCIPAL
========================= */
.page {
    width: 100%;
    padding: 18px 18px 28px;
}

.consulta-card {
    width: min(98%, 1900px);
    margin: 0 auto;
    padding: 20px;
    background: var(--gris-fondo);
    border: 1px solid rgba(194, 206, 221, 0.96);
    border-radius: 20px;
    box-shadow: var(--sombra);
    backdrop-filter: blur(2px);
}

/* =========================
   ENCABEZADO INTERNO
========================= */
.consulta-card__header {
    position: relative;
    min-height: 78px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 18px;
}

.consulta-card__search {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 430px;
    flex: 0 0 430px;
}

.consulta-card__title-wrap {
    position: absolute;
    left: 50%;
    z-index: 1;
    width: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateX(-50%);
}

#h1TituloPaciente {
    min-width: 300px;
    margin: 0;
    padding-bottom: 12px;
    color: var(--azul-3);
    border-bottom: 1px solid #d8e2ee;
    font-size: 2.15rem;
    font-weight: 800;
    line-height: 1.15;
    text-align: center;
}

/* =========================
   BUSCADOR
========================= */
.search-form {
    display: flex;
    align-items: center;
    gap: 14px;
}

.search-field {
    position: relative;
    flex: 1;
}

.search-field__icon {
    position: absolute;
    top: 50%;
    left: 16px;
    color: #8997b0;
    font-size: 1.1rem;
    pointer-events: none;
    transform: translateY(-50%);
}

.search-field input[type="text"] {
    width: 100%;
    height: var(--alto-touch);
    padding: 0 16px 0 44px;
    color: var(--azul-texto);
    background: #ffffff;
    border: 1px solid #c7d4e2;
    border-radius: var(--radio-sm);
    outline: none;
    font-size: 1rem;
    font-weight: 600;
    transition: border-color var(--transicion), box-shadow var(--transicion);
}

.search-field input[type="text"]::placeholder {
    color: #8c99b2;
    font-weight: 600;
}

.search-field input[type="text"]:focus {
    border-color: #d98f17;
    box-shadow: 0 0 0 4px rgba(217, 143, 23, 0.12);
}

.btn-search {
    min-width: 118px;
    height: var(--alto-touch);
    color: #ffffff;
    background: linear-gradient(180deg, var(--naranja-1) 0%, var(--naranja-2) 100%);
    border: none;
    border-radius: var(--radio-sm);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    transition: filter var(--transicion), transform var(--transicion);
}

.btn-search:hover {
    filter: brightness(1.03);
}

.btn-search:active {
    transform: translateY(1px);
}

/* =========================
   BOTONES DE ACCION
========================= */
.consulta-card__actions {
    position: relative;
    z-index: 3;
    margin-left: auto;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(199, 212, 226, 0.95);
    border-radius: 18px;
    box-shadow: 0 8px 22px rgba(23, 57, 94, 0.12);
    backdrop-filter: blur(4px);
}

.btn-inicio,
.btn-exportar {
    min-width: 150px;
    min-height: 48px;
    padding: 0 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #ffffff !important;
    border: none;
    border-radius: 14px;
    font-size: 0.96rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0.2px;
    text-decoration: none !important;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    box-shadow:
        0 7px 16px rgba(22, 48, 87, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.18);
    transition:
        transform 0.18s ease,
        box-shadow 0.18s ease,
        filter 0.18s ease;
}

.btn-inicio {
    background: linear-gradient(180deg, #0d4fa3 0%, #0a3f86 100%);
}

.btn-exportar {
    background: linear-gradient(180deg, #208c57 0%, #176f42 100%);
}

.btn-inicio:hover,
.btn-exportar:hover {
    filter: brightness(1.06);
    transform: translateY(-2px);
    box-shadow:
        0 10px 22px rgba(22, 48, 87, 0.22),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-inicio:active,
.btn-exportar:active {
    transform: translateY(0);
    box-shadow:
        0 5px 12px rgba(22, 48, 87, 0.16),
        inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.btn-inicio:focus-visible,
.btn-exportar:focus-visible {
    outline: 3px solid rgba(245, 155, 21, 0.35);
    outline-offset: 3px;
}

/* =========================
   TABLA
========================= */
.tabla-card {
    width: 100%;
}

.divTabla {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    background: rgba(255, 255, 255, 0.58);
    border: 1px solid #cbd7e5;
    border-radius: 14px 14px 0 0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
    -webkit-overflow-scrolling: touch;
}

.divTabla::-webkit-scrollbar {
    height: 14px;
}

.divTabla::-webkit-scrollbar-track {
    background: rgba(198, 211, 227, 0.95);
    border-radius: 20px;
}

.divTabla::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #d89c17 0%, #b67b0a 100%);
    border: 2px solid rgba(198, 211, 227, 0.95);
    border-radius: 20px;
}

.miTabla {
    width: 100%;
    min-width: 2985px;
    background: #ffffff;
    border-collapse: collapse;
    table-layout: fixed;
}

.miTabla col.col-nombre {
    width: 200px;
}

.miTabla col.col-mes {
    width: 160px;
}

.miTabla col.col-fecha {
    width: 170px;
}

.miTabla col.col-encargada {
    width: 240px;
}

.miTabla col.col-num {
    width: 135px;
}

.miTabla col.col-clas {
    width: 185px;
}

.miTabla col.col-obs {
    width: 420px;
}

.miTabla thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    height: 74px;
    padding: 12px 8px;
    color: #ffffff;
    background: linear-gradient(180deg, var(--verde-1) 0%, var(--verde-2) 100%);
    border: 1px solid rgba(255, 255, 255, 0.22);
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    vertical-align: middle;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.miTabla tbody tr {
    height: auto;
    min-height: 86px;
}

.miTabla tbody td {
    height: auto;
    min-height: 86px;
    padding: 10px 8px;
    color: #29486b;
    background: var(--gris-celda);
    border: 1px solid #d8e1ec;
    font-size: 0.94rem;
    line-height: 1.35;
    text-align: center;
    vertical-align: middle;
    white-space: normal;
    overflow: visible;
}

.miTabla tbody tr:nth-child(even) td {
    background: var(--gris-celda-alt);
}

.miTabla tbody tr:hover td {
    background: #eef4fa;
}

.miTabla td:last-child {
    vertical-align: top;
}

.cell-text,
.cell-badge {
    width: 100%;
    margin: 0 auto;
}

.cell-text {
    display: block;
    max-height: none;
    overflow: visible;
    line-height: 1.35;
    text-align: center;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
    hyphens: auto;
    -webkit-line-clamp: unset;
}

.cell-text--name {
    display: block;
    width: 100%;
    max-width: none;
    height: auto;
    max-height: none;
    overflow: visible;
    color: #1f3d61;
    font-weight: 700;
    line-height: 1.45;
    text-align: left;
    white-space: normal;
    word-break: normal;
    overflow-wrap: anywhere;
    -webkit-line-clamp: unset;
    -webkit-box-orient: unset;
}

.cell-text--obs {
    display: block;
    max-height: none;
    padding: 4px 2px;
    overflow: visible;
    line-height: 1.45;
    text-align: left;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    -webkit-line-clamp: unset;
}

.cell-badge {
    display: flex;
    align-items: center;
    justify-content: center;
}

.no-results {
    height: auto !important;
    padding: 30px 20px !important;
    color: #60748f;
    font-weight: 700;
}

/* =========================
   BADGES
========================= */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 110px;
    min-height: 34px;
    padding: 7px 14px;
    color: #5c6e86;
    background: #edf2f7;
    border-radius: var(--radio-sm);
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.15;
    text-align: center;
    white-space: normal;
}

.badge--normal {
    color: #2d7f5c;
    background: var(--verde-soft);
}

.badge--deficiente {
    color: var(--rojo-texto);
    background: var(--rojo-soft);
}

.badge--acelerado {
    color: var(--azul-badge);
    background: var(--azul-soft);
}

/* =========================
   PIE DE TABLA Y PAGINACION
========================= */
.table-footer {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 16px;
    align-items: center;
    padding: 16px;
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid #cbd7e5;
    border-top: none;
    border-radius: 0 0 14px 14px;
}

.table-footer__info {
    color: #73849c;
    font-size: 1rem;
    font-weight: 600;
}

.table-footer__pagination {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pagination-btn,
.pagination-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 16px;
    background: #f2f5f9;
    border: 1px solid #d0d9e6;
    border-radius: var(--radio-sm);
    font-weight: 700;
    text-decoration: none;
    transition: background var(--transicion), color var(--transicion), transform var(--transicion);
}

.pagination-btn {
    min-width: 96px;
    color: #b0bccd;
}

.pagination-btn.is-disabled {
    cursor: default;
    opacity: 0.85;
    pointer-events: none;
}

.pagination-number {
    min-width: 44px;
    color: #5f7290;
}

.pagination-number.is-active {
    color: #ffffff;
    background: linear-gradient(180deg, var(--azul-1) 0%, var(--azul-2) 100%);
    border-color: var(--azul-2);
}

.table-footer__per-page {
    display: flex;
    justify-content: flex-end;
}

.per-page-form {
    display: flex;
    align-items: center;
    gap: 10px;
}

.per-page-form label {
    color: #6d809b;
    font-size: 1rem;
    font-weight: 600;
}

.per-page-form select {
    min-width: 86px;
    height: 44px;
    padding: 0 12px;
    color: var(--azul-texto);
    background: #ffffff;
    border: 1px solid #c7d4e2;
    border-radius: var(--radio-sm);
    outline: none;
    font-size: 1rem;
    font-weight: 600;
}

/* =========================
   TABLET
========================= */
@media (max-width: 1024px) {
    .topbar__inner {
        grid-template-columns: 160px minmax(0, 1fr) 160px;
        min-height: 84px;
    }

    .topbar__logo--left img {
        max-height: 54px;
    }

    .topbar__logo--right img {
        max-height: 64px;
    }

    .topbar__title h1 {
        font-size: 1.65rem;
    }

    .page {
        padding: 16px 14px 24px;
    }

    .consulta-card {
        width: min(98%, 1900px);
        padding: 16px;
    }

    .consulta-card__header {
        position: static;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }

    .consulta-card__search {
        width: 100%;
        max-width: 100%;
        flex: none;
    }

    .consulta-card__title-wrap {
        position: static;
        left: auto;
        width: 100%;
        justify-content: center;
        transform: none;
    }

    #h1TituloPaciente {
        min-width: auto;
        font-size: 1.8rem;
    }

    .consulta-card__actions {
        width: 100%;
        margin-left: 0;
        justify-content: center;
    }

    .miTabla thead th {
        height: 70px;
        font-size: 0.86rem;
    }

    .miTabla tbody tr,
    .miTabla tbody td {
        height: auto;
        min-height: 80px;
        font-size: 0.9rem;
    }

    .badge {
        min-width: 84px;
        font-size: 0.86rem;
    }

    .table-footer {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
    }
}

/* =========================
   CELULAR
========================= */
@media (max-width: 680px) {
    .topbar__inner {
        grid-template-columns: 1fr;
        justify-items: center;
        gap: 8px;
        padding: 12px;
        text-align: center;
    }

    .topbar__logo--left,
    .topbar__logo--right {
        justify-content: center;
    }

    .topbar__logo--left img {
        max-height: 42px;
    }

    .topbar__logo--right img {
        max-height: 48px;
    }

    .topbar__title h1 {
        font-size: 1.2rem;
    }

    .page {
        padding: 14px 10px 22px;
    }

    .consulta-card {
        width: min(100%, 1560px);
        padding: 14px 10px;
        border-radius: var(--radio);
    }

    .consulta-card__header {
        gap: 14px;
    }

    #h1TituloPaciente {
        font-size: 1.45rem;
    }

    .search-form {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-search {
        width: 100%;
    }

    .consulta-card__actions {
        width: 100%;
        padding: 10px;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        border-radius: 16px;
    }

    .btn-inicio,
    .btn-exportar {
        width: 100%;
        min-width: 0;
        min-height: 48px;
    }

    .miTabla thead th {
        height: 66px;
        padding: 8px 5px;
        font-size: 0.8rem;
    }

    .miTabla tbody tr,
    .miTabla tbody td {
        min-height: 74px;
        font-size: 0.82rem;
    }

    .cell-text {
        max-height: none;
        overflow: visible;
        -webkit-line-clamp: unset;
    }

    .cell-text--name {
        display: block;
        max-height: none;
        overflow: visible;
        white-space: normal;
        -webkit-line-clamp: unset;
    }

    .cell-text--obs {
        display: block;
        max-height: none;
        overflow: visible;
        -webkit-line-clamp: unset;
    }

    .badge {
        min-width: 78px;
        min-height: 30px;
        font-size: 0.82rem;
    }

    .table-footer__pagination {
        flex-wrap: wrap;
        justify-content: center;
    }

    .per-page-form {
        flex-direction: column;
    }
}

/* =========================
   IMPRESION
========================= */
@media print {
    body {
        background: #ffffff !important;
    }

    .topbar,
    .consulta-card__search,
    .consulta-card__actions,
    .table-footer {
        display: none !important;
    }

    .page {
        padding: 0;
    }

    .consulta-card {
        width: 100%;
        margin: 0;
        padding: 0;
        background: #ffffff;
        border: none;
        box-shadow: none;
    }

    #h1TituloPaciente {
        margin-bottom: 12px;
        border-bottom: 1px solid #999;
    }

    .divTabla {
        overflow: visible;
        background: #ffffff;
        border: none;
    }

    .miTabla {
        min-width: 100%;
    }

    .miTabla th,
    .miTabla td {
        height: auto !important;
        min-height: auto !important;
        color: #000000 !important;
        background: #ffffff !important;
        border: 1px solid #999;
        font-size: 11px;
    }

    .cell-text,
    .cell-badge {
        height: auto !important;
        max-height: none !important;
    }

    .badge {
        min-width: auto;
        min-height: auto;
        padding: 0;
        color: #000000 !important;
        background: none !important;
        border: none !important;
    }
}

/* =========================
   ACCESIBILIDAD BASICA
========================= */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
    }
}