/* --- 0. Animaciones principales de interfaz --- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

@keyframes scaleIn {
    from { 
        opacity: 0; 
        transform: scale(0.95) translateY(10px); 
    }
    to { 
        opacity: 1; 
        transform: scale(1) translateY(0); 
    }
}

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); opacity: 1; }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

/* --- 5. Ayuda emergente de calendario --- */
.calendar-tooltip {
    position: fixed;
    z-index: 100;
    background: white;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    min-width: 220px;
    pointer-events: none;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    display: none;
}

.calendar-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
    display: block;
}

/* Cursor interactivo para eventos */
.calendar-event-item {
    cursor: pointer;
    transition: transform 0.1s;
}
.calendar-event-item:hover {
    transform: scale(1.02);
}

/* --- 6. Menú desplegable de usuario --- */
.user-dropdown {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
    pointer-events: none;
    visibility: hidden;
    /* Sombra suave y sofisticada */
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1); /* Transición suave */
    z-index: 60;
}

/* Mostrar al hacer hover sobre el contenedor padre (.group) */
.group:hover .user-dropdown {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    visibility: visible;
}

/* --- 7. Tarjetas de suscripción --- */
.plan-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, box-shadow;
}

.plan-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border-color: #94a3b8; /* gris slate 400 */
}

/* --- 8. Etiquetas de búsqueda --- */
.search-tag {
    display: inline-flex;
    align-items: center;
    background-color: #f1f5f9; /* gris slate 100 */
    color: #475569; /* gris slate 600 */
    border: 1px solid #e2e8f0; /* gris slate 200 */
    border-radius: 999px; /* Bordes completamente redondeados */
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    user-select: none;
    transition: all 0.2s ease;
}

.search-tag:hover {
    background-color: #e2e8f0; /* gris slate 200 */
    color: #1e293b; /* gris slate 800 */
    border-color: #cbd5e1; /* gris slate 300 */
}

/* Animación de entrada para etiquetas */
.animate-pop-in {
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Los overlays ya superan al footer en la pila; este fondo evita que los
   logos de alto contraste se perciban a través de su transparencia. */
.fixed.inset-0.backdrop-blur-sm {
    background-color: rgba(15, 23, 42, 0.96) !important;
}

/* --- RESULTS-UX-MICROPATCH-01: superficie modal aislada y opaca --- */
.pexam-modal-overlay {
    position: fixed !important;
    inset: 0 !important;
    isolation: isolate;
    z-index: 10000 !important;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    padding: 1rem;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    overscroll-behavior: contain;
    background: rgb(15, 23, 42) !important;
}

.pexam-modal-overlay.hidden {
    display: none !important;
}

.pexam-modal-dialog {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    max-height: calc(100vh - 2rem);
    max-height: calc(100dvh - 2rem);
    overflow: hidden;
    background: rgb(255, 255, 255) !important;
    opacity: 1;
}

.pexam-modal-header,
.pexam-modal-footer {
    position: relative;
    z-index: 2;
    flex: 0 0 auto;
    background: rgb(255, 255, 255) !important;
}

.pexam-modal-body {
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    background: rgb(255, 255, 255) !important;
}

/* --- FILES-1A PATCH-05: un solo scroll documental y fondo inmóvil --- */
html.pexam-medical-documents-open,
body.pexam-medical-documents-open {
    overflow: hidden !important;
    overscroll-behavior: none;
}

body.pexam-medical-documents-open {
    position: fixed !important;
    inset-inline: 0;
    top: var(--pexam-medical-documents-scroll-top, 0px);
    width: 100%;
}

#medical-documents-body {
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
    scrollbar-width: auto;
}

#medical-documents-body::-webkit-scrollbar {
    width: 12px;
}

#medical-documents-body::-webkit-scrollbar-track {
    background: #f1f5f9;
}

#medical-documents-body::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border: 3px solid #f1f5f9;
    border-radius: 9999px;
}

#medical-documents-body::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* --- UX-B2C-01: modal de agendamiento contenido en el viewport real --- */
html.pexam-booking-open,
body.pexam-booking-open {
    overflow: hidden !important;
    overscroll-behavior: none;
}

.pexam-booking-overlay {
    position: fixed !important;
    inset: 0 !important;
    isolation: isolate;
    z-index: 10000 !important;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    padding: 1rem;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    overscroll-behavior: contain;
    background: rgb(15, 23, 42) !important;
    pointer-events: auto;
}

.pexam-booking-dialog {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: calc(100vh - 2rem);
    max-height: calc(100dvh - 2rem);
    overflow: hidden;
}

.pexam-booking-header,
.pexam-booking-actions {
    flex: 0 0 auto;
    background: rgb(255, 255, 255) !important;
}

.pexam-booking-form {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.pexam-booking-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    background: rgb(255, 255, 255) !important;
}

.pexam-booking-actions {
    background: white;
}

@media (min-width: 640px) {
    .pexam-modal-overlay,
    .pexam-booking-overlay {
        padding: 1.5rem;
    }

    .pexam-modal-dialog,
    .pexam-booking-dialog {
        max-height: calc(100vh - 3rem);
        max-height: calc(100dvh - 3rem);
    }
}

/* --- UX-B2C-02: panel de filtros contenido, desplazable y colapsable --- */
:root {
    --pexam-header-height: 80px;
    --pexam-filter-gap: 1rem;
}

.pexam-results-layout {
    align-items: flex-start;
}

.pexam-filter-aside,
.pexam-results-layout > main {
    min-width: 0;
}

.pexam-filter-aside[hidden] {
    display: none !important;
    width: 0 !important;
    flex: 0 0 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
}

.pexam-results-layout.is-filter-collapsed > main {
    width: 100% !important;
    max-width: none;
    flex: 1 1 100%;
}

.pexam-filter-shell {
    position: sticky;
    top: calc(var(--pexam-header-height) + var(--pexam-filter-gap));
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: calc(100vh - var(--pexam-header-height) - (4 * var(--pexam-filter-gap)));
    max-height: calc(100dvh - var(--pexam-header-height) - (4 * var(--pexam-filter-gap)));
    overflow: hidden;
}

.pexam-filter-header {
    position: sticky;
    top: 0;
    z-index: 2;
    flex: 0 0 auto;
    background: white;
}

.pexam-filter-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
}

/* --- RESULTS-UX-MICROPATCH-01: prestaciones con precio y CTA no truncables --- */
.pexam-exam-row {
    display: grid;
    grid-template-columns: 1.5rem 2.5rem minmax(0, 1fr) max-content max-content;
    grid-template-areas: "check icon info price action";
    align-items: center;
    column-gap: 0.75rem;
    row-gap: 0.5rem;
    min-width: 0;
    overflow: hidden;
}

.pexam-exam-check { grid-area: check; }
.pexam-exam-icon { grid-area: icon; }
.pexam-exam-info {
    grid-area: info;
    min-width: 0;
}
.pexam-exam-name {
    display: -webkit-box;
    overflow: hidden;
    overflow-wrap: break-word;
    word-break: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
}
.pexam-exam-price {
    grid-area: price;
    min-width: max-content;
    white-space: nowrap;
}
.pexam-exam-action {
    grid-area: action;
    min-width: max-content;
    white-space: nowrap;
}

.pexam-results-layout:not(.is-filter-collapsed) .pexam-exam-row {
    grid-template-columns: 1.5rem 2.5rem minmax(0, 1fr) max-content;
    grid-template-areas:
        "check icon info info"
        ". . price action";
}

.pexam-results-layout:not(.is-filter-collapsed) .pexam-exam-price,
.pexam-results-layout:not(.is-filter-collapsed) .pexam-exam-action {
    justify-self: end;
}

.pexam-results-layout:not(.is-filter-collapsed) .pexam-exam-price-pending {
    min-width: 0;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: break-word;
    text-align: left;
    justify-self: start;
}

@media (max-width: 639px) {
    .pexam-exam-row,
    .pexam-results-layout:not(.is-filter-collapsed) .pexam-exam-row {
        grid-template-columns: 1.5rem 2.5rem minmax(0, 1fr);
        grid-template-areas:
            "check icon info"
            ". . price"
            ". . action";
        align-items: start;
    }

    .pexam-exam-price,
    .pexam-exam-action,
    .pexam-results-layout:not(.is-filter-collapsed) .pexam-exam-price,
    .pexam-results-layout:not(.is-filter-collapsed) .pexam-exam-action {
        justify-self: start;
    }

    .pexam-exam-price-pending {
        min-width: 0;
        max-width: 100%;
        white-space: normal;
        text-align: left;
    }

    .pexam-exam-action {
        width: 100%;
    }
}
