/* FUENTES Y BASE */
body {
    font-family: 'Outfit', sans-serif;
}

textarea {
    resize: vertical;
}

/* TIPOGRAFÍA PROSE */
.prose p {
    margin-top: 0;
    margin-bottom: 1em;
}

.prose h4 {
    margin-bottom: 0.5em;
    margin-top: 1.5em;
    font-size: 1.1em;
    font-weight: 600;
}

.prose ul {
    margin-left: 1.5em;
    list-style-type: disc;
}

/* ANIMACIONES */
.loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #008791;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.animate-fade-in-out {
    animation: fadeInOut 3s forwards;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    10%, 90% { opacity: 1; }
}
/* =========================================
   OCULTAR SCROLLBAR (Móviles y Tablets)
   ========================================= */
@media (max-width: 767px) {
    #main-content::-webkit-scrollbar,
    .overflow-y-auto::-webkit-scrollbar {
        display: none;
    }

    #main-content,
    .overflow-y-auto {
        -ms-overflow-style: none;  /* IE and Edge */
        scrollbar-width: none;  /* Firefox */
    }
}

/* Barra de scroll Rectangular y Clara para Chrome/Safari en Desktop */
@media (min-width: 768px) {
    #main-content::-webkit-scrollbar,
    .overflow-y-auto::-webkit-scrollbar {
        width: 8px;
    }

    #main-content::-webkit-scrollbar-track,
    .overflow-y-auto::-webkit-scrollbar-track {
        background: #f8fafc;
        border-radius: 0px; 
    }

    #main-content::-webkit-scrollbar-thumb,
    .overflow-y-auto::-webkit-scrollbar-thumb {
        background: #cbd5e1; 
        border-radius: 0px; 
    }

    #main-content::-webkit-scrollbar-thumb:hover,
    .overflow-y-auto::-webkit-scrollbar-thumb:hover {
        background: #94a3b8; 
    }
}

/* PANTALLA DE CARGA NEURACLOUD (Líneas 315-325) */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.loader-modern {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(0, 135, 145, 0.1);
    border-left-color: #008791;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* LÍNEA DE VIDA */
.timeline {
    border-left: 2px solid #d1fae5;
}

.timeline-item {
    position: relative;
    padding-left: 1.5rem;
    padding-bottom: 1.5rem;
}

.timeline-item:before {
    content: '';
    position: absolute;
    left: -0.4rem;
    top: 0.25rem;
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 9999px;
    background-color: #008791;
}

/* MOTOR GRÁFICO DEL GENOGRAMA */
.genogram-container {
    position: relative;
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    min-height: 600px;
    overflow: hidden;
    cursor: grab;
}

.genogram-container:active {
    cursor: grabbing;
}

.genogram-workspace {
    position: absolute;
    width: 100%;
    height: 100%;
    transform-origin: 0 0;
}

.genogram-node {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    user-select: none;
    width: 100px;
    padding: 8px;
    border: 2px solid transparent;
    border-radius: 8px;
}

.genogram-node.selected {
    border-color: #10b981;
    background-color: rgba(16, 185, 129, 0.1);
}

.genogram-node:hover {
    z-index: 10;
}

.genogram-node.dragging {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 20;
    transform: scale(1.08);
    border-color: #10b981;
}

.shape-container {
    position: relative;
    width: 70px;
    height: 70px;
}

.genogram-shape {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid;
    background-color: white;
    font-weight: 600;
    font-size: 1.5rem;
}

.genogram-node.male .genogram-shape {
    border-color: #3b82f6;
}

.genogram-node.female .genogram-shape {
    border-color: #ec4899;
    border-radius: 9999px;
}

.genogram-node.other .genogram-shape {
    border-color: #8b5cf6;
    transform: rotate(45deg);
    border-radius: 4px;
}

.genogram-node.patient .genogram-shape {
    border-width: 4px;
    border-style: double;
}

.deceased-cross {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    color: black;
    font-weight: bold;
    line-height: 1;
}

.genogram-name {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    text-align: center;
    padding: 0.1rem 0.5rem;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 0.25rem;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.genogram-info {
    font-size: 0.7rem;
    color: #6b7280;
}

.genogram-svg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* TUTORIALES Y REFERIDOS */
@keyframes attention-pulse {
    0% { box-shadow: 0 0 0 0 rgba(0, 135, 145, 0.7); transform: scale(1); }
    50% { box-shadow: 0 0 0 15px rgba(0, 135, 145, 0); transform: scale(1.02); }
    100% { box-shadow: 0 0 0 0 rgba(0, 135, 145, 0); transform: scale(1); }
}

.highlight-referral {
    animation: attention-pulse 2s infinite;
    z-index: 9999 !important;
    border-color: #008791 !important;
}

.driver-popover.referral-theme {
    background: linear-gradient(135deg, #008791 0%, #006066 100%);
    color: white;
    border: 1px solid #4fd1c5;
    box-shadow: 0 10px 25px -5px rgba(0, 135, 145, 0.4);
}

.driver-popover.referral-theme .driver-popover-title {
    color: #fbbf24;
    font-size: 1.25rem;
    font-weight: 800;
}

.driver-popover.driverjs-theme {
    background-color: #1e293b;
    color: #ffffff;
    border-radius: 12px;
    padding: 15px;
    max-width: 300px;
}

/* ESTILOS DE IMPRESIÓN */

/* #print-area solo existe para la impresión: aunque se le cargue contenido,
   nunca debe aparecer (ni parpadear) en pantalla. */
@media screen {
    #print-area { display: none !important; }
}

@media print {
    body>*:not(#print-area) { display: none; }
    body, html { background-color: white; }
    .no-print { display: none !important; }
    #print-area, #print-area * { visibility: visible; }
    /* display gana sobre .hidden de Tailwind: basta con rellenar #print-area
       y llamar a window.print(), sin alternar clases. */
    #print-area { display: block !important; position: absolute; left: 0; top: 0; width: 100%; font-family: 'Segoe UI', sans-serif; color: #333; }
    @page { size: A4; margin: 2.5cm; }
    .report-title-page { display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100vh; text-align: center; page-break-after: always; }
    .report-section { page-break-inside: avoid; margin-bottom: 2em; padding-bottom: 1em; border-bottom: 1px solid #e2e8f0; }

    /* Listado de pacientes impreso desde el generador de informes */
    .print-list-header { border-bottom: 2px solid #008791; padding-bottom: 10px; margin-bottom: 20px; }
    .print-list-header h1 { font-size: 20px; font-weight: bold; color: #008791; margin: 0; }
    .print-list-header p { font-size: 11px; color: #666; margin: 4px 0 0; }
    .print-list-table { width: 100%; border-collapse: collapse; font-size: 11px; }
    .print-list-table thead { display: table-header-group; }
    .print-list-table th { text-align: left; background-color: #f1f5f9; border: 1px solid #cbd5e1; padding: 6px 8px; font-weight: bold; }
    /* overflow-wrap evita que un correo largo se coma el ancho de las demás columnas */
    .print-list-table td { border: 1px solid #e2e8f0; padding: 6px 8px; vertical-align: top; overflow-wrap: anywhere; }
    .print-list-table tr { page-break-inside: avoid; }
    .print-list-footer { margin-top: 16px; font-size: 10px; color: #888; text-align: right; }
}

/* MODERN LOADER */
.loader-modern {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(0, 135, 145, 0.1);
    border-left-color: #008791;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ==========================================================
   EDITOR ENRIQUECIDO DE INFORMES
   El contenido se guarda como HTML. Las tablas se editan como
   celdas reales, no como texto con barras verticales.
   ========================================================== */
.rich-editor {
    outline: none;
    line-height: 1.65;
}

.rich-editor p { margin: 0 0 0.6em; }
.rich-editor p:last-child { margin-bottom: 0; }

.rich-editor ul,
.rich-editor ol {
    margin: 0 0 0.6em 1.35em;
    padding: 0;
}

.rich-editor ul { list-style: disc; }
.rich-editor ol { list-style: decimal; }
.rich-editor li { margin-bottom: 0.2em; }

.rich-editor strong { font-weight: 700; }
.rich-editor em { font-style: italic; }

.rich-editor table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.7em 0;
    border: 1px solid #cbd5e1;
    table-layout: fixed;
}

.rich-editor th,
.rich-editor td {
    border: 1px solid #e2e8f0;
    padding: 6px 9px;
    vertical-align: top;
    min-width: 48px;
    word-break: break-word;
}

.rich-editor th {
    background: #f2f9fa;
    text-align: left;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: #4a6572;
}

.rich-editor td { background: #ffffff; }
.rich-editor tbody tr:nth-child(even) td { background: #f8fafc; }

/* La celda donde está el cursor se resalta, para no perderse en tablas grandes */
.rich-editor td:focus,
.rich-editor th:focus { outline: 2px solid rgba(0, 135, 145, 0.35); outline-offset: -2px; }

/* Marcador de posición cuando el campo está vacío */
.rich-editor:empty:before,
.rich-editor[data-empty="true"]:before {
    content: attr(data-placeholder);
    color: #9ca3af;
    pointer-events: none;
}

/* Tablas escritas dentro de un informe. Se usan en el diálogo de inserción y
   el PDF las redefine con sus propias medidas. */
.rt-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    font-size: 12px;
}

.rt-table th {
    background: #f2f9fa;
    border: 1px solid #e2e8f0;
    padding: 6px 9px;
    text-align: left;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: #4a6572;
    white-space: nowrap;
}

.rt-table td {
    border: 1px solid #e2e8f0;
    padding: 6px 9px;
    color: #1e293b;
    vertical-align: top;
    min-width: 60px;
}

.rt-table tbody tr:nth-child(even) { background: #f8fafc; }

/* Fondo a cuadros para previsualizar PNG con transparencia (firma y sello). */
.asset-checker {
    background-image:
        linear-gradient(45deg, #eef2f6 25%, transparent 25%, transparent 75%, #eef2f6 75%),
        linear-gradient(45deg, #eef2f6 25%, transparent 25%, transparent 75%, #eef2f6 75%);
    background-size: 16px 16px;
    background-position: 0 0, 8px 8px;
    background-color: #ffffff;
}

/* Spinner en línea para estados de carga dentro de botones.
   Toma el color del texto del botón (currentColor), así funciona igual sobre
   fondo sólido o claro sin depender de las clases border-* que traen las llamadas. */
.loader-small {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    flex-shrink: 0;
}

/* ZOOM: PARCHE MÍNIMO CONTRA EL PREFLIGHT DE TAILWIND
   Aquí había un "escudo" que forzaba box-sizing:content-box y border-style:none
   a TODOS los descendientes de #video-container, con la idea de que Zoom calcula
   su grilla en content-box. Es falso en el Meeting SDK 6.2.0: el bundle declara
   box-sizing:border-box en 38 sitios (raíz, ventana arrastrable, barra, paneles,
   lista virtualizada) y content-box en uno solo, un <input> interno.
   Medido en navegador cargando este mismo CSS, el escudo inflaba un panel que el
   SDK declara de 480px hasta 544px, borraba los separadores de la barra y dejaba
   los botones en 39x24 px en vez de 69x46: de ahí los iconos diminutos y el vídeo
   descuadrado.
   El resto del Preflight no hace falta blindarlo: sus selectores universales
   tienen especificidad 0,0,0 y pierden contra las clases de emotion del SDK
   (0,1,0). Lo único que sí muerde es el `max-width:100%` de Preflight sobre
   img/video: medido, estrangula un vídeo de 1324px de ancho hasta 731px.

   OJO CON LA ESPECIFICIDAD, aquí está el truco: el selector va envuelto en
   `:where()` a propósito, para que el `#` NO sume y la regla se quede en 0,0,1.
   Así empata con Preflight y le gana por orden de carga (esta hoja va después
   de tailwind.css), pero PIERDE contra las clases del SDK (0,1,0) y no le pisa
   sus tamaños. Escrito como `#video-container video` (1,0,1) le ganaba también
   al SDK: un vídeo que Zoom dimensiona a 745px de alto se quedaba en 150px.
   No añadir aquí `height`: Preflight pone `height:auto`, que es lo mismo que
   calcula el navegador, así que no hay nada que revertir. */
:where(#video-container) img,
:where(#video-container) video { max-width: none; }

/* SCROLLBARS */
@media (min-width: 768px) {
    #main-content::-webkit-scrollbar, .overflow-y-auto::-webkit-scrollbar { width: 8px; }
    #main-content::-webkit-scrollbar-track, .overflow-y-auto::-webkit-scrollbar-track { background: #f8fafc; }
    #main-content::-webkit-scrollbar-thumb, .overflow-y-auto::-webkit-scrollbar-thumb { background: #cbd5e1; }
}

.custom-scrollbar::-webkit-scrollbar { width: 8px; }
.custom-scrollbar::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 4px; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
/* ESTADO "TODO AL DÍA" (widget Requiere tu atención) */
@keyframes attention-clear-ping {
    0% { transform: scale(0.85); opacity: 0.8; }
    70%, 100% { transform: scale(1.5); opacity: 0; }
}
.attention-clear-ping {
    animation: attention-clear-ping 2.4s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes attention-check-draw {
    to { stroke-dashoffset: 0; }
}
.attention-check-path {
    stroke-dasharray: 24;
    stroke-dashoffset: 24;
    animation: attention-check-draw 0.6s ease-out 0.3s forwards;
}

@media (prefers-reduced-motion: reduce) {
    .attention-clear-ping { animation: none; opacity: 0; }
    .attention-check-path { animation: none; stroke-dashoffset: 0; }
}
