:root {
    color-scheme: dark;
    /* Tema Oscuro (Por Defecto) */
    --bg-base: #000000;
    /* Fondo base totalmente negro */
    --nav-bg: #000000;
    /* Header totalmente negro */

    /* Variables generales */
    --text-main: #fcfcfc;
    --text-muted: #9a9aab;
    --text-primary: #fcfcfc;
    --text-secondary: #9a9aab;
    --border-color: rgba(255, 255, 255, 0.1);
    --border: rgba(255, 255, 255, 0.1);
    --bg-card: #050505;
    --bg-card-soft: rgba(255, 255, 255, 0.04);
    --surface: #050505;
    --bg-main: #000000;
    --background: #050505;
    /* Fondo totalmente opaco para las tarjetas */

    /* Acentos y Gradientes (Como Euphoria) */
    --logo-gradient: linear-gradient(90deg, #ff0000 0%, #ff7b00 50%, #ffea00 100%);
    --primary: #ffaa00;
    --secondary: #ff7b00;
    --accent-color: #ffaa00;
    --primary-rgb: 255, 170, 0;
    --primary-hover: #ff8f00;
    --status-active: #a1d1a3;
    --status-pause: #d1bfa1;
    --btn-bg: #ffffff;
    --btn-text: #111116;
}

[data-theme="light"] {
    color-scheme: light;
    /* Tema Claro */
    --bg-base: #f6f6f9;
    --nav-bg: #f6f6f9;
    --text-main: #16161f;
    --text-muted: #4a4a5e;
    --text-primary: #16161f;
    --text-secondary: #4a4a5e;
    --border-color: rgba(0, 0, 0, 0.12);
    --border: rgba(0, 0, 0, 0.12);
    --bg-card: #ffffff;
    --surface: #ffffff;
    --bg-card-soft: rgba(0, 0, 0, 0.04);
    --bg-main: #f6f6f9;
    --background: #ffffff;
    /* Fondo opaco claro */

    --logo-gradient: linear-gradient(135deg, #7a003c 0%, #5a002b 40%, #350019 75%, #1a0010 100%);
    --primary: #d40a4e;
    --secondary: #5a002b;
    --accent-color: #d40a4e;
    --primary-rgb: 212, 10, 78;
    --primary-hover: #b0083f;
    --btn-bg: #16161f;
    --btn-text: #ffffff;
    --status-active: #15803d;
    --status-pause: #92400e;

    /* Sistema de sombras suaves para tema claro */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);

    /* Glass filter bar variables for light theme */
    --fb-label: #3f3f52;
    --fb-text: #16161f;
    --fb-input-border: rgba(0, 0, 0, 0.2);
    --fb-btn-text: #ffffff;
    --fb-btn-bg: var(--primary);
    --fb-btn-border: var(--primary);
    --fb-btn-hover: var(--secondary);
    --fb-input-bg: transparent;
    --fb-select-bg: #f0f0f4;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Forzar títulos a minúsculas para mantener la estética */
h1,
h2,
h3,
h4,
h5,
h6,
.page-title,
.page-subtitle,
.section-title,
.ficha-name,
.patient-name,
.record-type,
.preview-title {
    text-transform: lowercase !important;
}

body {
    font-family: "Neue Helvetica Pro 25 Ultra Light", "Raleway", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-weight: 400;
    background-color: var(--bg-base);
    color: var(--text-main);
    min-height: 100vh;
    transition: background-color 0.5s ease, color 0.5s ease;
    overflow-x: hidden;
    position: relative;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* =========================================================
   Fondos Animados y Texturas
   ========================================================= */

/* Fondos Animados y Texturas deshabilitados por rendimiento */
.animated-bg,
.background-noise,
#three-bg-canvas,
#three-bg-canvas-light,
#light-theme-gui {
    display: none !important;
}


/* =========================================================
   Navegación y Logo
   ========================================================= */
.navbar, .top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 4rem;
    background-color: var(--nav-bg);
    /* Sin borde para que se fusione con el body */
    border-bottom: none;
    position: sticky;
    top: 0;
    z-index: 100;
}

.mobile-menu-btn {
    display: none;
}

/* =========================================================
   Menú Principal
   ========================================================= */
.nav-links, .main-menu {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-links a, .menu-item {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: 1px;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    transition: all 0.3s ease;
}

.nav-links a:hover, .menu-item:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.menu-item.active {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
    font-weight: 400;
}

[data-theme="light"] .menu-item:hover, [data-theme="light"] .nav-links a:hover {
    background: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .menu-item.active {
    background: rgba(0, 0, 0, 0.1);
}

.nav-brand, .logo {
    font-size: 2.5rem;
    font-weight: 200 !important;
    letter-spacing: -2px;
    background: var(--logo-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    text-decoration: none;
}

[data-theme="light"] .nav-brand {
    /* Degradado exclusivo para el logo del header: rojo más claro y vivo */
    background: linear-gradient(135deg, #ff2a4b 0%, #e60029 45%, #b30018 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.theme-btn {
    background: none;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-btn:hover {
    background: rgba(128, 128, 128, 0.1);
}

.theme-btn span {
    font-size: 1.5rem;
}

/* =========================================================
   Botón Estilo Glow / Radial Gradient (.button)
   ========================================================= */
.button {
    min-width: 120px;
    position: relative;
    cursor: pointer;
    padding: 12px 17px;
    border: 0;
    border-radius: 7px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
    background: radial-gradient(
        ellipse at bottom,
        rgba(71, 81, 92, 1) 0%,
        rgba(11, 21, 30, 1) 45%
    );
    color: rgb(255, 255, 255, 0.66);
    font-family: 'Raleway', 'Inter', -apple-system, sans-serif;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    outline: none;
    box-sizing: border-box;
    transition: all 1s cubic-bezier(0.15, 0.83, 0.66, 1);
}

.button::before {
    content: "";
    width: 70%;
    height: 1px;
    position: absolute;
    bottom: 0;
    left: 15%;
    background: rgb(255, 255, 255);
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 1) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    opacity: 0.2;
    transition: all 1s cubic-bezier(0.15, 0.83, 0.66, 1);
}

.button:hover {
    color: rgb(255, 255, 255, 1);
    transform: scale(1.1) translateY(-3px);
}

.button:hover::before {
    opacity: 1;
}


/* Contenedor Principal */
.container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 2rem;
}

.page-header {
    display: inline-block;
    margin-bottom: 3rem;
    padding: 1.2rem 4rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

/* Eliminado */

.page-title {
    font-size: 3.5rem;
    font-weight: 300;
    letter-spacing: 2px;
    margin-bottom: 0.5rem;
}

.page-subtitle {
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--text-muted);
    letter-spacing: 1px;
}

/* Botones de Base Antiguos Compatibilidad */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 400;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
    border: none;
    text-align: center;
}

.btn-primary {
    background-color: var(--btn-bg);
    color: var(--btn-text);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] .btn-primary {
    background-color: var(--primary);
    color: #ffffff;
    box-shadow: var(--shadow-md);
}

[data-theme="light"] .btn-primary:hover {
    background-color: var(--secondary);
    color: #ffffff;
}

.btn-primary:hover {
    background-color: var(--accent-color);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

.btn-outline {
    background-color: transparent;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-outline:hover {
    background-color: rgba(255,255,255,0.05);
    border-color: var(--text-main);
}

[data-theme="light"] .btn-outline {
    border-color: var(--border-color);
}

[data-theme="light"] .btn-outline:hover {
    background-color: var(--bg-card-soft);
    border-color: var(--primary);
}

/* Compatibilidad Cards Anteriores */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}
.card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.3);
}

[data-theme="light"] .card {
    box-shadow: var(--shadow-md);
}
[data-theme="light"] .card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .card-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--logo-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    object-fit: cover;
}


/* =========================================================
   Botón de Volver (Back Link)
   ========================================================= */
.back-link {
    display: flex;
    width: max-content;
    margin-bottom: 1.5rem;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 400;
    transition: all 0.3s ease;
    background: var(--bg-card);
    padding: 0.8rem 1.5rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .back-link {
    box-shadow: var(--shadow-sm);
}


.back-link:hover {
    color: var(--text-main);
    transform: translateX(-5px);
}

/* Grid de Pacientes / Slider */
.slider-wrapper {
    position: relative;
    width: 100%;
    margin-top: -1rem; /* Acercar el slider al título */
}

.patients-grid {
    display: flex;
    gap: 2.5rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    padding: 2.5rem 1rem 3rem 1rem;
    /* Margen para hover extendido para que la tarjeta no se corte al saltar */
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

.patients-grid .psy-card {
    flex: 0 0 320px;
    height: auto;
    min-height: 440px;
    scroll-snap-align: center;
    border-radius: 0;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

.patients-grid .psy-card.psy-card-horizontal {
    flex: 0 0 600px;
    min-height: 240px;
}

@media (max-width: 768px) {
    .patients-grid .psy-card.psy-card-horizontal {
        flex: 0 0 85vw;
        min-height: 480px;
    }
}

[data-theme="light"] .patients-grid .psy-card {
    box-shadow: 0 15px 35px rgba(0,0,0,0.08);
}

/* Ocultar completamente el scrollbar en Webkit */
.patients-grid::-webkit-scrollbar {
    display: none;
}

/* Botones del Slider */
.slider-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    margin-top: -1.5rem;
    /* Compensar el padding-bottom del grid */
}

.slider-btn:hover {
    background: var(--text-main);
    color: var(--bg-base);
    transform: translateY(-50%) scale(1.1);
}

.slider-prev {
    left: -1rem;
}

.slider-next {
    right: -1rem;
}

[data-theme="light"] .slider-btn {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .slider-btn:hover {
    background: var(--text-main);
}

/* =========================================================
   Tarjetas de Pacientes (Diseño Premium Moderno)
   ========================================================= */
.previewCard {
    flex: 0 0 340px;
    width: 340px;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-card);
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.4s var(--ease-spring), box-shadow 0.4s ease, border-color 0.4s ease;
}

[data-theme="light"] .previewCard {
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .status-indicator {
    background: rgba(0, 0, 0, 0.45);
}

[data-theme="light"] .status-indicator.status-active {
    color: #86efac;
}

[data-theme="light"] .status-indicator.status-pause {
    color: #fde68a;
}

[data-theme="light"] .pulse-dot {
    background-color: #22c55e;
    box-shadow: 0 0 8px #22c55e;
}

[data-theme="light"] .pulse-dot.pause {
    background-color: #f59e0b;
    box-shadow: 0 0 8px #f59e0b;
}

.previewCard:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.3);
}

[data-theme="light"] .previewCard:hover {
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.15);
    border-color: rgba(0, 0, 0, 0.2);
}

.previewCard:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

/* -------- Foto con MÁS espacio (retrato 4/5) -------- */
.card-media {
    aspect-ratio: 4 / 5;
    /* antes 16/10: ahora mucho más alta */
    position: relative;
    overflow: hidden;
}

.card-media .backdrop {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    /* prioriza el rostro */
    transition: transform 0.8s ease, filter 0.5s ease;
    filter: brightness(0.9);
}

.previewCard:hover .backdrop {
    transform: scale(1.08);
    filter: brightness(0.75);
}

/* Degradado más alto para integrar el nombre sobre la foto */
.card-media-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top,
            rgba(0, 0, 0, 0.9) 0%,
            rgba(0, 0, 0, 0.45) 35%,
            transparent 65%);
    pointer-events: none;
}

/* Nombre superpuesto sobre la imagen (aprovecha el espacio) */
.card-media-title {
    position: absolute;
    left: 1.4rem;
    bottom: 1.2rem;
    right: 1.4rem;
    z-index: 2;
    color: #fff;
    font-size: 1.8rem;
    font-weight: 300;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
    margin: 0;
    line-height: 1.15;
    text-wrap: balance;
}

/* -------------------- Indicador de estado ----------------- */
.status-indicator {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 1px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 0.4rem 0.85rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
}

.status-indicator.status-active {
    color: var(--status-active);
}

.status-indicator.status-pause {
    color: var(--status-pause);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--status-active);
    box-shadow: 0 0 8px var(--status-active);
    animation: pulseAnim 2s infinite;
}

.pulse-dot.pause {
    background-color: var(--status-pause);
    box-shadow: 0 0 8px var(--status-pause);
    animation: none;
}

@keyframes pulseAnim {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(161, 209, 163, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(161, 209, 163, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(161, 209, 163, 0);
    }
}

/* -------------------- Contenido inferior ------------------ */
.previewCard .content {
    display: flex;
    flex-direction: column;
    padding: 1.4rem;
    gap: 1rem;
    color: var(--text-main);
    flex-grow: 1;
}

.content-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.8rem;
}

/* El título grande ahora vive sobre la foto; aquí queda compacto */
.previewCard .title {
    font-size: 1.1rem;
    font-weight: 500;
    margin: 0;
    color: var(--text-main);
}

.date-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}

.info-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.info-row {
    display: grid;
    grid-template-columns: 1.2rem 4.5rem 1fr;
    gap: 0.6rem;
    padding: 0.6rem 0.8rem;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-radius: 12px;
    transition: background 0.25s ease;
}

.info-row:hover {
    background: rgba(255, 255, 255, 0.04);
}

[data-theme="light"] .info-row:hover {
    background: rgba(0, 0, 0, 0.03);
}

.info-label {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.info-value {
    color: var(--text-main);
    font-weight: 300;
}

.info-row.highlight-row {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="light"] .info-row.highlight-row {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.info-row.highlight-row .info-value {
    color: var(--accent-color);
    font-weight: 500;
}

.icon-small {
    font-size: 1.1rem !important;
}

/* -------------------- Footer ------------------------------ */
.card-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-label {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.previewCard:hover .footer-label {
    color: var(--text-main);
}

.action-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    color: var(--text-main);
}

[data-theme="light"] .action-icon {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.action-icon .material-symbols-outlined {
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

.previewCard:hover .action-icon {
    background: var(--text-main);
    color: var(--bg-base);
    border-color: var(--text-main);
}

.previewCard:hover .action-icon .material-symbols-outlined {
    transform: translateX(3px);
}

/* =========================================================
   Tarjeta de paciente tipo "poster" (foto a pantalla completa)
   ========================================================= */
.patient-card {
    position: relative;
    border-radius: 28px;
    overflow: hidden;
    aspect-ratio: 3 / 4.5;
    /* un poco más alta = foto con más espacio */
    background-size: cover;
    background-position: center top;
    background-color: #000;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    transition: transform 0.4s var(--ease-spring), box-shadow 0.4s ease;
    color: #fcfcfc;
}

.patient-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
}

.card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom,
            rgba(0, 0, 0, 0) 0%,
            rgba(0, 0, 0, 0.35) 55%,
            rgba(0, 0, 0, 0.95) 95%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    overflow: hidden;
}

.card-content {
    padding: 2rem 1.8rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.patient-card:hover .card-content {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

.card-title-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.patient-name {
    font-size: 2.2rem;
    font-weight: 300;
    letter-spacing: 0.5px;
    margin: 0;
    color: #fcfcfc;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

.card-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-stats {
    display: flex;
    gap: 1.2rem;
}

.stat {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 1rem;
    font-weight: 400;
    color: #fcfcfc;
    text-shadow: 0 1px 5px rgba(0, 0, 0, 0.8);
}

.stat .material-symbols-outlined {
    font-size: 1.1rem;
    font-weight: 400;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-weight: 400;
}

.status-badge.active {
    color: var(--status-active);
}

.status-badge.pause {
    color: var(--status-pause);
}

.action-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #fcfcfc;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.action-btn:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

/* =========================================================
   Vista Previa (Glassmorphism Slide-Up en Hover)
   ========================================================= */
.card-preview {
    position: absolute;
    inset: 0;
    padding: 2rem;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    opacity: 0;
    transform: translateY(100%);
    transition: all 0.5s var(--ease-out);
    pointer-events: none;
    color: #fcfcfc;
}

.patient-card:hover .card-preview {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.preview-title {
    font-size: 1.5rem;
    font-weight: 300;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.preview-data {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    scrollbar-width: none;
}

.preview-data::-webkit-scrollbar {
    display: none;
}

.data-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.data-item .label {
    font-size: 0.85rem;
    font-weight: 400;
    color: #9a9aab;
    letter-spacing: 1px;
}

.data-item .value {
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.4;
    color: #fcfcfc;
}

.status-active {
    color: var(--status-active);
}

.status-pause {
    color: var(--status-pause);
}

.full-btn {
    margin-top: 1.5rem;
    background: #fff;
    color: #000;
    border: none;
    padding: 1rem;
    border-radius: 12px;
    font-family: inherit;
    font-weight: 400;
    font-size: 1rem;
    letter-spacing: 1px;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.full-btn:hover {
    background: var(--accent-color);
    color: #111;
    transform: translateY(-2px);
}

.full-btn:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

/* =========================================================
   Vista de Expedientes (Lista)
   ========================================================= */

/* Eliminado */
.back-link .material-symbols-outlined {
    font-size: 1.1rem;
}

.records-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 800px;
}

.record-card {
    display: flex;
    align-items: center;
    gap: 1.8rem;
    padding: 1.8rem 2rem;
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    text-decoration: none;
    color: var(--text-main);
}

[data-theme="light"] .record-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

.record-card:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateX(10px);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .record-card:hover {
    background: var(--bg-card);
    border-color: rgba(0, 0, 0, 0.18);
    box-shadow: var(--shadow-md);
}

.record-icon {
    width: 65px;
    height: 65px;
    border-radius: 18px;
    background: var(--logo-gradient);
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    box-shadow: 0 5px 15px rgba(255, 123, 0, 0.2);
}

.record-icon .material-symbols-outlined {
    font-size: 2.2rem;
    font-weight: 300;
}

.past-record .record-icon {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    box-shadow: none;
}

.record-info {
    flex: 1;
}

.record-type {
    font-size: 1.6rem;
    font-weight: 300;
    margin-bottom: 0.4rem;
    letter-spacing: 0.5px;
}

.record-meta {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: var(--text-muted);
    font-size: 1.05rem;
    font-weight: 400;
}

.record-meta .material-symbols-outlined {
    font-size: 1.1rem;
}

.separator {
    color: var(--border-color);
}

.open-record-btn {
    padding: 0.8rem 1.8rem;
    border-radius: 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    text-decoration: none;
    font-weight: 400;
    transition: all 0.3s ease;
}

.record-card:hover .open-record-btn {
    border-color: var(--text-main);
}

.open-record-btn:hover {
    background: var(--text-main) !important;
    color: var(--bg-base) !important;
}

.status-badge.inactive {
    color: var(--text-muted);
}

/* =========================================================
   Vista Agenda
   ========================================================= */
.agenda-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 3rem;
    margin-top: 2rem;
}

.calendar-widget {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 2rem;
    position: sticky;
    top: 120px;
}

.calendar-widget h3 {
    font-size: 1.2rem;
    font-weight: 400;
    margin: 0 0 1.5rem 0;
    text-align: center;
}

.days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.5rem;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 400;
}

.days-grid span {
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.days-grid .day {
    padding: 0.5rem 0;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
}

.days-grid .day:hover:not(.empty-day) {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="light"] .days-grid .day:hover:not(.empty-day) {
    background: rgba(0, 0, 0, 0.1);
}

.days-grid .day.past {
    color: var(--text-muted);
    opacity: 0.3;
    pointer-events: none;
}

.days-grid .day.active {
    background: var(--text-main);
    color: var(--bg-main);
    font-weight: 500;
}

.agenda-timeline {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: 24px;
    border: 1px solid var(--border-color);
}

.time-row {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 2rem;
    align-items: start;
}

.time-label {
    font-size: 0.95rem;
    font-weight: 400;
    color: var(--text-muted);
    padding-top: 1rem;
    text-align: right;
    border-right: 1px solid var(--border-color);
    height: 100%;
    padding-right: 1.5rem;
}

.time-content {
    min-height: 80px;
}

.appointment-card {
    padding: 1.5rem 2rem;
    border-radius: 20px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 2rem;
    align-items: center;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border-left: 4px solid var(--status-active);
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.appointment-card:hover {
    transform: translateX(5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.appointment-card .app-time {
    font-size: 1.05rem;
    font-weight: 400;
    color: var(--text-muted);
}

.appointment-card .app-details h4 {
    margin: 0 0 0.4rem 0;
    font-size: 1.2rem;
    font-weight: 400;
}

.appointment-card .app-details p {
    margin: 0;
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-muted);
}

.appointment-card .app-status {
    display: flex;
    align-items: center;
}

.time-content.empty {
    display: flex;
    align-items: center;
    padding-top: 1rem;
}

.add-appointment-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 400;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 12px;
    border: 1px dashed var(--border-color);
    transition: all 0.3s ease;
}

.add-appointment-btn:hover {
    color: var(--text-main);
    border-color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .add-appointment-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

@media (max-width: 900px) {
    .agenda-container {
        grid-template-columns: 1fr;
    }

    .calendar-widget {
        position: static;
        margin-bottom: 2rem;
    }

    .appointment-card {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* =========================================================
   Filtros y Búsqueda (Barra Superior)
   ========================================================= */
.filters-bar {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.search-container {
    position: relative;
    width: 250px;
}

.search-icon {
    position: absolute;
    left: 1.2rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.filter-input {
    width: 100%;
    padding: 0.8rem 1rem 0.8rem 3rem;
    border-radius: 30px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-main);
    font-size: 0.95rem;
    outline: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.filter-input:focus,
.filter-select:focus {
    border-color: var(--text-main);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.select-container {
    position: relative;
}

.filter-select {
    appearance: none;
    padding: 0.8rem 2.5rem 0.8rem 1.2rem;
    border-radius: 30px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-main);
    font-size: 0.95rem;
    outline: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.filter-select option {
    background: var(--bg-base);
    color: var(--text-main);
}

.select-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

[data-theme="light"] .filter-input,
[data-theme="light"] .filter-select {
    box-shadow: var(--shadow-sm);
    border-color: var(--border-color);
    background: var(--bg-card);
}

[data-theme="light"] .filter-input:focus,
[data-theme="light"] .filter-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(212, 10, 78, 0.15);
}

/* =========================================================
   Categorías de Pacientes (Contenedores Premium)
   ========================================================= */
.category-section {
    margin-bottom: 4rem;
}

.category-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0 1rem;
    background: transparent;
    border: none;
    box-shadow: none;
    position: relative;
}

[data-theme="light"] .category-head {
    background: transparent;
    border: none;
    box-shadow: none;
}

.category-title {
    display: inline-flex;
    align-items: center;
    gap: 1rem;
    font-size: 2.2rem;
    font-weight: 200;
    margin: 0;
    letter-spacing: 0.5px;
    color: var(--text-main);
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.category-title .material-symbols-outlined {
    font-size: 2.2rem;
    background: var(--logo-gradient);
    -webkit-background-clip: text;
    color: transparent;
}

.category-count {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 0.4rem 1.2rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    letter-spacing: 0.5px;
}

/* =========================================================
   Mobile Navbar Responsiveness
   ========================================================= */
@media (max-width: 900px) {
    .navbar, .top-nav {
        padding: 0.8rem 1.5rem;
    }

    .mobile-menu-btn {
        display: block !important;
        z-index: 102;
    }

    .nav-links {
        display: none;
        flex-direction: column;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background-color: var(--nav-bg);
        justify-content: center;
        align-items: center;
        gap: 2rem;
        z-index: 101;
    }

    .nav-links.active {
        display: flex;
    }

    .nav-links a, .menu-item {
        font-size: 1.5rem;
    }
}

/* Fix global para select, optgroup y option en modo oscuro y claro */
select, 
select.form-control, 
select.glass-input, 
select.sleek-input,
.clinico-modal select {
    color-scheme: dark;
}

select optgroup, 
select.form-control optgroup, 
select.glass-input optgroup, 
select.sleek-input optgroup,
.clinico-modal select optgroup {
    background-color: #1e2433 !important;
    color: #38bdf8 !important;
    font-weight: 700 !important;
    font-size: 0.8rem !important;
    letter-spacing: 0.04em !important;
    padding: 6px 10px !important;
}

select option, 
select.form-control option, 
select.glass-input option, 
select.sleek-input option,
.clinico-modal select option {
    background-color: #12141c !important;
    color: #f8fafc !important;
    padding: 8px 12px !important;
}

select option:disabled,
select.form-control option:disabled,
select.glass-input option:disabled,
select.sleek-input option:disabled,
select option.select-section-title,
.clinico-modal select option:disabled,
.clinico-modal select option.select-section-title {
    background-color: #1e2433 !important;
    color: #38bdf8 !important;
    font-weight: 700 !important;
    font-size: 0.8rem !important;
    letter-spacing: 0.05em !important;
    padding: 8px 12px !important;
}

[data-theme="light"] select, 
[data-theme="light"] select.form-control, 
[data-theme="light"] select.glass-input, 
[data-theme="light"] select.sleek-input,
[data-theme="light"] .clinico-modal select {
    color-scheme: light;
}

[data-theme="light"] select optgroup, 
[data-theme="light"] select.form-control optgroup, 
[data-theme="light"] select.glass-input optgroup, 
[data-theme="light"] select.sleek-input optgroup,
[data-theme="light"] .clinico-modal select optgroup {
    background-color: #f1f5f9 !important;
    color: #0369a1 !important;
    font-weight: 700 !important;
}

[data-theme="light"] select option, 
[data-theme="light"] select.form-control option, 
[data-theme="light"] select.glass-input option, 
[data-theme="light"] select.sleek-input option,
[data-theme="light"] .clinico-modal select option {
    background-color: #ffffff !important;
    color: #0f172a !important;
}

[data-theme="light"] select option:disabled,
[data-theme="light"] select.form-control option:disabled,
[data-theme="light"] select.glass-input option:disabled,
[data-theme="light"] select.sleek-input option:disabled,
[data-theme="light"] select option.select-section-title,
[data-theme="light"] .clinico-modal select option:disabled,
[data-theme="light"] .clinico-modal select option.select-section-title {
    background-color: #f1f5f9 !important;
    color: #0369a1 !important;
    font-weight: 700 !important;
}

/* =========================================================
   Refinamientos Adicionales Tema Claro
   ========================================================= */
[data-theme="light"] .previewCard {
    box-shadow: var(--shadow-md);
}

[data-theme="light"] .previewCard:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: var(--shadow-lg);
    border-color: rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .action-icon {
    background: var(--bg-card-soft);
    border-color: var(--border-color);
}

[data-theme="light"] .previewCard:hover .action-icon {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

[data-theme="light"] .card-footer {
    border-top-color: var(--border-color);
}

[data-theme="light"] .page-header {
    background: var(--bg-card);
    border-color: var(--border-color);
    box-shadow: var(--shadow-md);
}

[data-theme="light"] .appointment-card {
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

[data-theme="light"] .appointment-card:hover {
    box-shadow: var(--shadow-md);
}

[data-theme="light"] .add-appointment-btn:hover {
    background: var(--bg-card-soft);
    border-color: var(--primary);
    color: var(--primary);
}

[data-theme="light"] .calendar-widget,
[data-theme="light"] .agenda-timeline {
    box-shadow: var(--shadow-sm);
}

[data-theme="light"] .days-grid .day.active {
    background: var(--primary);
    color: #ffffff;
}

[data-theme="light"] .full-btn {
    background: var(--primary);
    color: #ffffff;
    box-shadow: var(--shadow-md);
}

[data-theme="light"] .full-btn:hover {
    background: var(--secondary);
    color: #ffffff;
}

/* Navegación - mejorar hover en tema claro para mayor consistencia */
[data-theme="light"] .menu-item:hover,
[data-theme="light"] .nav-links a:hover {
    color: var(--primary);
    background: rgba(212, 10, 78, 0.06);
}
