/* =====================================================
   DIGITURNO - Clínica Visión Colombia
   Design System CSS
   Color principal: #144390 | Fuente: Montserrat
   ===================================================== */

/* ── Google Font ── */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700;800;900&display=swap');

/* ── Variables ── */
:root {
    /* ─── Paleta Corporativa Visión Colombia ─── */
    --primary:          #144390;   /* Azul Rey – bloque estructural principal */
    --primary-light:    #1a5bbf;   /* Azul más vibrante para acciones */
    --primary-lighter:  #e8eef8;   /* Fondo tint para hover en tablas */
    --primary-dark:     #0e2f66;   /* Azul muy oscuro para énfasis extremo */
    --accent:           #007BFF;   /* Azul acento para badges y CTAs secundarios */
    --accent-light:     #e0edff;

    /* Semáforo de prioridades – colores planos, sin gradiente */
    --priority-alta:       #C0392B;
    --priority-alta-bg:    #fdecea;
    --priority-media:      #D68910;
    --priority-media-bg:   #fef5e7;
    --priority-normal:     #1E8449;
    --priority-normal-bg:  #e6f5ea;

    /* Estados */
    --success:    #1E8449;
    --success-bg: #e6f5ea;
    --warning:    #D68910;
    --warning-bg: #fef5e7;
    --danger:     #C0392B;
    --danger-bg:  #fdecea;
    --info:       #1a5bbf;
    --info-bg:    #e0edff;

    /* Neutros – escala fría (ligeramente azulada) */
    --white:     #ffffff;
    --gray-50:   #F8FAFC;
    --gray-100:  #F1F5F9;
    --gray-200:  #E2E8F0;
    --gray-300:  #CBD5E1;
    --gray-400:  #94A3B8;
    --gray-500:  #64748B;
    --gray-600:  #475569;
    --gray-700:  #334155;
    --gray-800:  #1E293B;
    --gray-900:  #0F172A;   /* Texto principal: casi negro, con matiz azul */

    /* Tipografía – Montserrat exclusivo */
    --font-family:    'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-xs:   0.75rem;
    --font-size-sm:   0.875rem;
    --font-size-base: 1rem;
    --font-size-lg:   1.125rem;
    --font-size-xl:   1.25rem;
    --font-size-2xl:  1.5rem;
    --font-size-3xl:  2rem;
    --font-size-4xl:  2.5rem;
    --font-size-5xl:  3.5rem;
    --font-size-6xl:  5rem;

    /* Espaciado */
    --space-1:  0.25rem;
    --space-2:  0.5rem;
    --space-3:  0.75rem;
    --space-4:  1rem;
    --space-5:  1.25rem;
    --space-6:  1.5rem;
    --space-8:  2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;

    /* Bordes – más redondeados para las píldoras */
    --radius-sm:   6px;
    --radius-md:   10px;
    --radius-lg:   16px;
    --radius-xl:   24px;
    --radius-full: 9999px;

    /* Sombras – suaves y tangibles, no brillantes */
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 8px 30px rgba(15, 23, 42, 0.10);
    --shadow-xl: 0 20px 40px rgba(15, 23, 42, 0.12);
    --shadow-card: 0 20px 40px rgba(0, 0, 0, 0.15);

    /* Transiciones */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;
}

/* ── Reset ── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: 400;
    line-height: 1.6;
    color: var(--gray-900);        /* #0F172A – más profundo, no negro puro */
    background-color: var(--gray-100);
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-light);
}

img {
    max-width: 100%;
    display: block;
}

/* ── Tipografía ── */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    color: var(--gray-900);
}

h1 { font-size: var(--font-size-4xl); }
h2 { font-size: var(--font-size-3xl); }
h3 { font-size: var(--font-size-2xl); }
h4 { font-size: var(--font-size-xl); }
h5 { font-size: var(--font-size-lg); }

.text-primary { color: var(--primary); }
.text-muted { color: var(--gray-500); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-center { text-align: center; }
.text-right { text-align: right; }

.font-light { font-weight: 300; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }

/* ── Layout Utilities ── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-6);
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.w-full { width: 100%; }
.h-full { height: 100%; }
.min-h-screen { min-height: 100vh; }

/* ── Spacing ── */
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }

/* ── Card Component ── */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: var(--space-8);
    transition: box-shadow var(--transition-base);
    border: 1px solid var(--gray-200);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-4);
    border-bottom: 2px solid var(--gray-100);
}

.card-header h3 {
    font-size: var(--font-size-xl);
    color: var(--primary);
}

/* ── Button Component ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    font-weight: 700;
    line-height: 1.4;
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    white-space: nowrap;
    user-select: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Solid primary – azul rey sólido, sin gradiente */
.btn-primary {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-success {
    background: #1E8449;
    color: var(--white);
    border-color: #1E8449;
}
.btn-success:hover:not(:disabled) {
    background: #176439;
    border-color: #176439;
}

.btn-danger {
    background: #C0392B;
    color: var(--white);
    border-color: #C0392B;
}
.btn-danger:hover:not(:disabled) {
    background: #a93226;
    border-color: #a93226;
}

.btn-warning {
    background: #D68910;
    color: var(--white);
    border-color: #D68910;
}
.btn-warning:hover:not(:disabled) {
    background: #b7770d;
    border-color: #b7770d;
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline:hover:not(:disabled) {
    background: var(--primary);
    color: var(--white);
    transform: translateY(-2px);
}

.btn-ghost {
    background: transparent;
    color: var(--gray-600);
    border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
    background: var(--gray-100);
    color: var(--gray-800);
}

.btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-size-xs);
}

.btn-lg {
    padding: var(--space-5) var(--space-10);
    font-size: var(--font-size-lg);
    border-radius: var(--radius-lg);
}

.btn-xl {
    padding: var(--space-8) var(--space-16);
    font-size: var(--font-size-2xl);
    border-radius: var(--radius-xl);
}

.btn-block {
    display: flex;
    width: 100%;
}

/* ── Form Components ── */
.form-group {
    margin-bottom: var(--space-5);
    position: relative;
}

.form-group label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: var(--space-2);
    letter-spacing: 0.3px;
}

.form-control {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: 400;
    color: var(--gray-800);
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
    outline: none;
    appearance: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(20, 67, 144, 0.1);
}

.form-control::placeholder {
    color: var(--gray-400);
}

.form-control-icon {
    padding-left: 2.75rem;
}

.form-icon {
    position: absolute;
    top: 50%;
    left: var(--space-4);
    transform: translateY(-50%);
    color: var(--gray-400);
    font-size: var(--font-size-lg);
    pointer-events: none;
    transition: color var(--transition-fast);
}

.form-group:focus-within .form-icon {
    color: var(--primary);
}

select.form-control {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7689' d='M1.41 0L6 4.58 10.59 0 12 1.41l-6 6-6-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

/* ── Badge Component ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    font-size: var(--font-size-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.badge-espera {
    background: var(--info-bg);
    color: var(--info);
}

.badge-llamando {
    background: var(--warning-bg);
    color: #c07d00;
    animation: pulse-badge 1.5s ease-in-out infinite;
}

.badge-atendido {
    background: var(--success-bg);
    color: var(--success);
}

.badge-ausente {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-alta {
    background: var(--priority-alta-bg);
    color: var(--priority-alta);
}

.badge-media {
    background: var(--priority-media-bg);
    color: #b8860b;
}

.badge-normal {
    background: var(--priority-normal-bg);
    color: var(--priority-normal);
}

/* ── Table Component ── */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
}

.table th {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-weight: 700;
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--gray-500);
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}

.table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
    vertical-align: middle;
}

.table tbody tr {
    transition: background-color var(--transition-fast);
}

.table tbody tr:hover {
    background-color: var(--primary-lighter);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* ── Table Wrapper (Responsivo para evitar scroll horizontal de toda la pantalla) ── */
.table-wrapper {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg);
    background: var(--white);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-4);
}

.table-wrapper::-webkit-scrollbar {
    height: 6px;
}
.table-wrapper::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: var(--radius-full);
}

/* ── Sidebar / Nav (Fixed Position para que nunca se quede arriba al hacer scroll) ── */
.app-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    position: relative;
}

.sidebar {
    /* Sólido – Bloque de color puro */
    background: var(--primary);
    color: var(--white);
    padding: var(--space-6) 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100vh;
    height: 100dvh;
    width: 260px;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 4px 0 20px rgba(15, 23, 42, 0.15);
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
    z-index: 100;
    transform: translateX(0);
}

.sidebar.collapsed,
.app-layout.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
    pointer-events: none;
    visibility: hidden;
}

.main-wrapper {
    flex: 1;
    min-width: 0;
    width: calc(100% - 260px);
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-layout.sidebar-collapsed .main-wrapper {
    margin-left: 0;
    width: 100%;
}

/* Backdrop para pantallas móviles/tablets */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 95;
    opacity: 1;
    transition: opacity 0.25s ease;
}
.sidebar-backdrop.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

.main-wrapper {
    min-width: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-full);
}

.sidebar-brand {
    padding: 0 var(--space-6);
    margin-bottom: var(--space-6);
    text-align: center;
    flex-shrink: 0;
}

.sidebar-brand h2 {
    color: var(--white);
    font-size: var(--font-size-xl);
    font-weight: 800;
    letter-spacing: -0.5px;
}

.sidebar-brand p {
    color: rgba(255, 255, 255, 0.7);
    font-size: var(--font-size-xs);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-top: var(--space-1);
}

.sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;
    list-style: none;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-6);
    color: rgba(255, 255, 255, 0.75);
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover,
.sidebar-nav li a.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
    border-left-color: var(--white);
}

.sidebar-nav li a .nav-icon {
    font-size: var(--font-size-lg);
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    margin-top: auto;
    flex-shrink: 0;
}

/* ── Top Bar ── */
.topbar {
    background: var(--white);
    padding: var(--space-4) var(--space-8);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h1 {
    font-size: var(--font-size-xl);
    color: var(--gray-900);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.topbar-user .avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    /* Sólido sin gradiente */
    background: var(--primary);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--font-size-sm);
}

/* ── Main Content ── */
.main-content {
    padding: var(--space-8);
    overflow-y: auto;
}

/* ── Stats Cards ── */
.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: var(--space-5);
    transition: all var(--transition-base);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-2xl);
    flex-shrink: 0;
}

.stat-icon.blue { background: var(--primary-lighter); color: var(--primary); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.yellow { background: var(--warning-bg); color: var(--warning); }
.stat-icon.red { background: var(--danger-bg); color: var(--danger); }

.stat-info h4 {
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--gray-500);
    font-weight: 600;
    margin-bottom: var(--space-1);
}

.stat-info .stat-number {
    font-size: var(--font-size-3xl);
    font-weight: 800;
    color: var(--gray-900);
    line-height: 1;
}

/* ── Toast Notifications ── */
.toast-container {
    position: fixed;
    top: var(--space-6);
    right: var(--space-6);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    border-radius: var(--radius-md);
    background: var(--white);
    box-shadow: var(--shadow-xl);
    min-width: 300px;
    max-width: 450px;
    animation: slideInRight 0.4s ease;
    border-left: 4px solid var(--primary);
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }

.toast-icon {
    font-size: var(--font-size-xl);
    flex-shrink: 0;
}

.toast-close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    font-size: var(--font-size-lg);
    padding: var(--space-1);
}

/* ── Login Page ── */
.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Fondo plano – asimetría visual por el panel lateral */
    background: var(--gray-100);
    position: relative;
    overflow-y: auto;
    padding: clamp(1rem, 2.5vh, 2rem);
    -webkit-overflow-scrolling: touch;
}

/* Panel azul lateral de fondo – bloque sólido sin formas suavizadas */
.login-page::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 45%;
    height: 100%;
    background: var(--primary);
    z-index: 0;
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: clamp(1.5rem, 3.5vh, var(--space-12));
    z-index: 1;
    animation: fadeInUp 0.6s ease;
    margin: auto;
}

.login-logo {
    text-align: center;
    margin-bottom: var(--space-10);
}

.login-logo .logo-icon {
    width: 72px;
    height: 72px;
    background: var(--primary);
    border-radius: var(--radius-lg);
    margin: 0 auto var(--space-5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--white);
    box-shadow: var(--shadow-lg);
}

.login-logo h1 {
    font-size: var(--font-size-2xl);
    color: var(--primary);
    font-weight: 800;
    letter-spacing: -0.5px;
}

.login-logo p {
    color: var(--gray-500);
    font-size: var(--font-size-sm);
    font-weight: 500;
    margin-top: var(--space-1);
}

.login-form .input-group {
    position: relative;
    margin-bottom: var(--space-5);
}

.login-form .input-group .input-icon {
    position: absolute;
    left: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    font-size: 1.1rem;
    transition: color var(--transition-fast);
    z-index: 1;
}

.login-form .input-group:focus-within .input-icon {
    color: var(--primary);
}

.login-form .input-group input {
    padding-left: 2.8rem;
}

.login-forgot {
    text-align: center;
    margin-top: var(--space-6);
    font-size: var(--font-size-xs);
    color: var(--gray-400);
}

/* ── Generador (Kiosko) ── */
.kiosk-page {
    min-height: 100vh;
    background: var(--gray-100);
    display: flex;
    flex-direction: column;
}

.kiosk-header {
    /* Sólido – sin gradiente */
    background: var(--primary);
    color: var(--white);
    padding: var(--space-6) var(--space-8);
    text-align: center;
    box-shadow: 0 4px 0 var(--primary-dark);
}

.kiosk-header h1 {
    color: var(--white);
    font-size: var(--font-size-2xl);
    font-weight: 800;
}

.kiosk-header p {
    color: rgba(255, 255, 255, 0.8);
    font-size: var(--font-size-sm);
    font-weight: 500;
    margin-top: var(--space-1);
}

.kiosk-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: safe center;
    padding: clamp(1rem, 2.5vh, var(--space-8));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.kiosk-subtitle {
    font-size: var(--font-size-xl);
    color: var(--gray-700);
    margin-bottom: var(--space-8);
    font-weight: 600;
    text-align: center;
}

.service-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-6);
    width: 100%;
    max-width: 900px;
}

.service-btn {
    padding: var(--space-10) var(--space-8);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-xl);
    background: var(--white);
    cursor: pointer;
    transition: all var(--transition-base);
    text-align: center;
    font-family: var(--font-family);
    box-shadow: var(--shadow-sm);
}

.service-btn:hover {
    border-color: var(--primary);
    background: var(--primary);
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.service-btn:hover .service-name,
.service-btn:hover .service-desc {
    color: var(--white);
}

.service-btn .service-icon {
    font-size: 3rem;
    margin-bottom: var(--space-4);
    display: block;
}

.service-btn .service-name {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--gray-800);
    display: block;
}

.service-btn .service-desc {
    font-size: var(--font-size-sm);
    color: var(--gray-500);
    margin-top: var(--space-2);
    display: block;
}

/* Botones de prioridad */
.priority-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-6);
    width: 100%;
    max-width: 900px;
}

.priority-btn {
    padding: var(--space-10) var(--space-6);
    border-radius: var(--radius-xl);
    border: 3px solid;
    background: var(--white);
    cursor: pointer;
    transition: all var(--transition-base);
    text-align: center;
    font-family: var(--font-family);
}

.priority-btn .priority-icon {
    font-size: 3rem;
    margin-bottom: var(--space-3);
    display: block;
}

.priority-btn .priority-name {
    font-size: var(--font-size-xl);
    font-weight: 700;
    display: block;
}

.priority-btn.alta {
    border-color: var(--priority-alta);
    color: var(--priority-alta);
}
.priority-btn.alta:hover {
    background: var(--priority-alta);
    color: var(--white);
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(220, 53, 69, 0.3);
}

.priority-btn.media {
    border-color: var(--priority-media);
    color: #b8860b;
}
.priority-btn.media:hover {
    background: var(--priority-media);
    color: var(--white);
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(240, 173, 78, 0.3);
}

.priority-btn.normal {
    border-color: var(--priority-normal);
    color: var(--priority-normal);
}
.priority-btn.normal:hover {
    background: var(--priority-normal);
    color: var(--white);
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(40, 167, 69, 0.3);
}

/* Ticket generado */
.ticket-display {
    text-align: center;
    animation: fadeInUp 0.5s ease;
}

.ticket-number {
    font-size: var(--font-size-6xl);
    font-weight: 900;
    color: var(--primary);
    line-height: 1;
    margin-bottom: var(--space-4);
    letter-spacing: -2px;
}

.ticket-info {
    font-size: var(--font-size-lg);
    color: var(--gray-600);
    margin-bottom: var(--space-2);
}

.ticket-count {
    font-size: var(--font-size-sm);
    color: var(--gray-400);
    margin-top: var(--space-6);
}

/* ── Ventanilla (Operador) ── */
.operator-page {
    min-height: 100vh;
    background: var(--gray-100);
}

.operator-header {
    background: var(--white);
    padding: var(--space-3) var(--space-6);
    border-bottom: 3px solid var(--primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-3);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 40;
}

.operator-header-main {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.operator-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.operator-info .info-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--font-size-sm);
    color: var(--gray-700);
    background: var(--gray-50);
    padding: 4px 10px;
    border-radius: var(--radius-full);
    border: 1px solid var(--gray-200);
}

.operator-info .info-item strong {
    color: var(--primary);
}

.operator-header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.operator-secondary-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.btn-crear-turno-header {
    box-shadow: 0 2px 6px rgba(10, 59, 110, 0.25);
    white-space: nowrap;
}

.call-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-12) var(--space-8);
}

.call-btn {
    width: 260px;
    height: 260px;
    border-radius: 50%;
    /* Sólido sin gradiente */
    background: var(--primary);
    color: var(--white);
    border: 6px solid var(--primary-dark);
    cursor: pointer;
    font-family: var(--font-family);
    font-size: var(--font-size-xl);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    box-shadow: 0 10px 40px rgba(20, 67, 144, 0.35);
    transition: all var(--transition-base);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    position: relative;
}

.call-btn::before {
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    border: 3px solid rgba(20, 67, 144, 0.2);
    animation: pulse-ring 2s ease-out infinite;
}

.call-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
    box-shadow: 0 16px 50px rgba(20, 67, 144, 0.5);
}

.call-btn:active {
    transform: scale(0.95);
}

.call-btn .call-icon {
    font-size: 3rem;
}

.current-turn {
    margin-top: var(--space-8);
    text-align: center;
    animation: fadeInUp 0.4s ease;
}

.current-turn-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: var(--space-8) var(--space-12);
    box-shadow: var(--shadow-xl);
    border: 2px solid var(--primary);
    display: inline-block;
    min-width: 400px;
}

.current-turn-number {
    font-size: var(--font-size-5xl);
    font-weight: 900;
    color: var(--primary);
    line-height: 1;
}

.current-turn-service {
    font-size: var(--font-size-lg);
    color: var(--gray-600);
    margin-top: var(--space-2);
}

.current-turn-actions {
    display: flex;
    gap: var(--space-4);
    justify-content: center;
    margin-top: var(--space-6);
}

/* ── Queue stats mini ── */
.queue-stats {
    display: flex;
    gap: var(--space-4);
    justify-content: center;
    margin-top: var(--space-8);
    flex-wrap: wrap;
}

.queue-stat-item {
    background: var(--white);
    padding: var(--space-4) var(--space-6);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    text-align: center;
    min-width: 120px;
}

.queue-stat-item .count {
    font-size: var(--font-size-3xl);
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
}

.queue-stat-item .label {
    font-size: var(--font-size-xs);
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: var(--space-1);
    font-weight: 600;
}

/* ─────────────────────────────────────────────
   PANTALLA TV – Layout Asimétrico Corporativo
   35% Panel de Turnos (Azul sólido) / 65% Media (Video)
   ───────────────────────────────────────────── */

/* Página completa – sin scroll, sin overflow */
.tv-page {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: row;
    background: #0d1b3e;   /* Negro azulado de fondo de seguridad */
    font-family: var(--font-family);
    color: var(--white);
}

/* ─────────────────────────────────────────────
   PANEL IZQUIERDO (35%): Turnos
───────────────────────────────────────────── */
.tv-turns-panel {
    width: 35%;
    height: 100%;
    background: var(--primary);   /* Azul rey sólido – SIN gradiente */
    display: flex;
    flex-direction: column;
    padding: clamp(1.5rem, 3vw, 2.5rem);
    box-shadow: 6px 0 30px rgba(0, 0, 0, 0.25);
    z-index: 10;
    overflow: hidden;
}

/* Cabecera del panel: Logo + Reloj arriba, Sede abajo sin solapamiento */
.tv-panel-header {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: clamp(1rem, 2.5vh, 2.2rem);
    flex-shrink: 0;
    width: 100%;
}

.tv-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 0.75rem;
}

.tv-header-logo {
    height: clamp(38px, 4.8vh, 52px);
    width: auto;
    object-fit: contain;
}

.tv-panel-clock {
    font-size: clamp(0.95rem, 1.4vw, 1.35rem);
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 6px 14px;
    border-radius: var(--radius-md);
    white-space: nowrap;
}

.tv-panel-sede {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
}

.tv-panel-sede .sede-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.75);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tv-sede-dropdown {
    width: 100%;
    max-width: 100%;
    font-size: clamp(0.85rem, 1.1vw, 1rem);
    font-weight: 700;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    outline: none;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.tv-sede-dropdown:hover, .tv-sede-dropdown:focus {
    background: rgba(255, 255, 255, 0.22);
    border-color: #ffffff;
}

.tv-sede-dropdown option {
    background: #0f172a;
    color: #ffffff;
    font-weight: 600;
    padding: 8px;
}

.tv-sound-btn {
    position: absolute;
    bottom: 24px;
    right: 24px;
    z-index: 50;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 18px;
    border-radius: 9999px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}
.tv-sound-btn:hover {
    background: var(--primary);
    transform: scale(1.04);
}

/* Cabeceras de columna de la tabla */
.tv-table-header {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 0 1.25rem 0.75rem 1.25rem;
    margin-bottom: 0.75rem;
    border-bottom: 2px solid rgba(255,255,255,0.15);
    flex-shrink: 0;
}

.tv-table-header span {
    font-size: clamp(0.6rem, 1vw, 0.75rem);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.55);
}

.tv-table-header span:last-child {
    text-align: right;
}

/* Lista de turnos (las píldoras) */
.tv-turns-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: clamp(0.5rem, 1vh, 1rem);
    overflow: hidden;
    position: relative;
}

/* Píldora de turno – blanca sobre azul */
.tv-turn-pill {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    align-items: center;
    background: #ffffff;
    border-radius: var(--radius-xl);
    padding: clamp(0.75rem, 1.5vh, 1.25rem) clamp(1rem, 2vw, 1.5rem);
    box-shadow: var(--shadow-md);
    transition: all 0.5s ease-in-out;
    animation: pillSlideIn 0.45s ease;
    flex-shrink: 0;
    gap: 0.5rem;
}

/* Primer turno (activo / llamando) – más grande y más prominente */
.tv-turn-pill.is-active {
    border-left: 6px solid var(--accent);
    transform: scale(1.03);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
}

/* Turnos anteriores (historial) – ligeramente atenuados */
.tv-turn-pill.is-history {
    opacity: 0.75;
    transform: scale(0.97);
}

.tv-pill-turn-code {
    font-size: clamp(1.15rem, 1.9vw, 1.7rem);
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.5px;
    line-height: 1.2;
    text-transform: uppercase;
    word-break: break-word;
}

.tv-turn-pill.is-history .tv-pill-turn-code {
    color: var(--gray-600);
    font-size: clamp(1rem, 1.6vw, 1.35rem);
    font-weight: 700;
}

.tv-pill-ventanilla {
    font-size: clamp(1.15rem, 1.9vw, 1.7rem);
    font-weight: 800;
    color: var(--gray-900);
    text-align: right;
    line-height: 1.2;
    white-space: nowrap;
}

.tv-turn-pill.is-history .tv-pill-ventanilla {
    color: var(--gray-500);
    font-size: clamp(1rem, 1.6vw, 1.35rem);
}

/* Estado: sin turnos */
.tv-turns-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: rgba(255,255,255,0.3);
    gap: 1rem;
    text-align: center;
}

.tv-turns-empty .empty-icon { font-size: 3rem; }
.tv-turns-empty p { font-size: 1rem; font-weight: 500; }

/* ─────────────────────────────────────────────
   PANEL DERECHO (65%): Media (Video + Overlay)
───────────────────────────────────────────── */
.tv-media-panel {
    flex: 1;
    height: 100%;
    position: relative;
    overflow: hidden;
    background: #111827;
}

/* Video de fondo a pantalla completa */
.tv-media-panel video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Placeholder cuando no hay video */
.tv-video-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #0d1b3e;
    color: rgba(255,255,255,0.3);
    font-size: 1rem;
    gap: 1rem;
}

.tv-video-empty p:first-child { font-size: 4rem; }

/* ── Overlay de llamado (flasheo al llamar turno) ── */
/* Cubre el panel de medios completamente mientras se anuncia */
.tv-call-overlay {
    position: absolute;
    inset: 0;
    background: var(--primary);   /* Azul sólido – sin gradiente */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    z-index: 100;
    animation: overlayFlash 0.3s ease;
}

.tv-call-badge {
    background: var(--accent);
    color: #fff;
    font-size: clamp(0.8rem, 1.5vw, 1rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    padding: 8px 24px;
    border-radius: var(--radius-full);
}

.tv-call-label {
    font-size: clamp(1rem, 2vw, 1.5rem);
    font-weight: 600;
    color: rgba(255,255,255,0.7);
    text-transform: uppercase;
    letter-spacing: 4px;
}

/* Nombre del paciente en el overlay – destacado y elegante */
.tv-call-turno {
    font-size: clamp(3.5rem, 7.5vw, 6.5rem);
    font-weight: 900;
    color: #ffffff;
    letter-spacing: -1px;
    line-height: 1.15;
    text-align: center;
    text-transform: uppercase;
    max-width: 92%;
    word-break: break-word;
    animation: tvPulseIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tv-call-ventanilla-box {
    background: rgba(255,255,255,0.15);
    border-radius: var(--radius-lg);
    padding: 1rem 2.5rem;
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    font-weight: 700;
    color: #fff;
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* Clases de compatibilidad hacia atrás (usadas por pantalla.js) */
.tv-header { display: none; }
.tv-body { display: none; }
.tv-main { display: none; }
.tv-sidebar { display: none; }
.tv-footer { display: none; }

/* ─────────────────────────────────────────────
   VIDEO CONTAINER (compatibilidad)
───────────────────────────────────────────── */
.tv-video-container {
    width: 100%;
    height: 100%;
    position: relative;
}

.tv-main-video {
    padding: 0 !important;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.blink-animation {
    animation: pulse-badge 1.2s ease-in-out infinite;
}

/* ─────────────────────────────────────────────
   Animación de entrada de píldora (Slide-down)
───────────────────────────────────────────── */
@keyframes pillSlideIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0)     scale(1);    }
}

@keyframes overlayFlash {
    0%   { background: #ffffff; }
    20%  { background: var(--primary); }
    100% { background: var(--primary); }
}

/* ── Modal / Config Dialog ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: clamp(0.75rem, 2vh, 1.5rem);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    animation: fadeIn 0.3s ease;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: clamp(1.25rem, 2.5vh, 2rem);
    width: 94%;
    max-width: 480px;
    max-height: calc(100vh - 2.5rem);
    max-height: calc(100dvh - 2.5rem);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow: var(--shadow-xl);
    animation: fadeInUp 0.4s ease;
    margin: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--gray-300) transparent;
}

.modal::-webkit-scrollbar {
    width: 6px;
}
.modal::-webkit-scrollbar-track {
    background: transparent;
}
.modal::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: var(--radius-full);
}
.modal::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

.modal h2 {
    font-size: var(--font-size-xl);
    color: var(--primary);
    margin-bottom: var(--space-4);
    text-align: center;
}

/* ── Historial (tabla operador) ── */
.history-section {
    margin-top: var(--space-8);
    padding: 0 var(--space-8) var(--space-8);
}

/* ── Setup Screen (Ventanilla / TV) ── */
.setup-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-50);
}

.setup-card {
    width: 100%;
    max-width: 500px;
    text-align: center;
}

.setup-card .setup-icon {
    font-size: 4rem;
    margin-bottom: var(--space-6);
}

/* ── Animations ── */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes pulse-ring {
    0% { transform: scale(1); opacity: 0.5; }
    100% { transform: scale(1.15); opacity: 0; }
}

@keyframes tvPulseIn {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Print Styles (Ticket térmico) ── */
@media print {
    body * {
        visibility: hidden;
    }

    .print-ticket,
    .print-ticket * {
        visibility: visible;
    }

    .print-ticket {
        position: absolute;
        left: 0;
        top: 0;
        width: 80mm;
        padding: 5mm;
        font-family: 'Montserrat', sans-serif;
        text-align: center;
        color: #000 !important;
        background: #fff !important;
    }

    .print-ticket .ticket-header {
        border-bottom: 1px dashed #000;
        padding-bottom: 3mm;
        margin-bottom: 3mm;
    }

    .print-ticket .ticket-header h2 {
        font-size: 14pt;
        color: #000 !important;
    }

    .print-ticket .ticket-header p {
        font-size: 8pt;
        color: #333 !important;
    }

    .print-ticket .ticket-turno {
        font-size: 36pt;
        font-weight: 900;
        padding: 5mm 0;
        color: #000 !important;
    }

    .print-ticket .ticket-details {
        font-size: 9pt;
        color: #333 !important;
        line-height: 1.6;
    }

    .print-ticket .ticket-footer {
        border-top: 1px dashed #000;
        padding-top: 3mm;
        margin-top: 3mm;
        font-size: 8pt;
        color: #666 !important;
    }
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    .app-layout {
        flex-direction: column;
    }

    .main-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        height: 100vh !important;
        height: 100dvh !important;
        width: 280px !important;
        max-width: 85vw !important;
        z-index: 1000 !important;
        transform: translateX(-100%) !important;
        visibility: hidden !important;
        pointer-events: none !important;
        box-shadow: 10px 0 40px rgba(0, 0, 0, 0.45);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s !important;
        display: flex !important;
    }

    .app-layout.sidebar-mobile-open .sidebar,
    .sidebar.mobile-open {
        transform: translateX(0) !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }

    .tv-body {
        grid-template-columns: 1fr;
    }

    .tv-sidebar {
        display: none;
    }

    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    .priority-buttons {
        grid-template-columns: 1fr;
    }

    .service-buttons {
        grid-template-columns: 1fr;
    }

    .current-turn-card {
        min-width: auto;
        width: 100%;
    }

    .call-btn {
        width: 220px;
        height: 220px;
    }

    .tv-turn-number {
        font-size: 6rem;
    }
}

/* ── Hidden utility ── */
.hidden {
    display: none !important;
}

/* ── Visibility utility ── */
.invisible {
    visibility: hidden;
}

/* ── Loader / Spinner ── */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: var(--space-12) var(--space-8);
    color: var(--gray-400);
}

.empty-state .empty-icon {
    font-size: 4rem;
    margin-bottom: var(--space-4);
    opacity: 0.5;
}

.empty-state p {
    font-size: var(--font-size-lg);
    font-weight: 500;
}

.empty-state .empty-sub {
    font-size: var(--font-size-sm);
    margin-top: var(--space-2);
}

/* =====================================================
   NUEVAS MEJORAS: LOGO, TV VIDEO, OVERLAY, VENTANILLA
   ===================================================== */

/* ── Brand Logo ── */
.brand-logo-header {
    max-height: 48px;
    width: auto;
    object-fit: contain;
    display: inline-block;
}

.brand-logo-sidebar {
    max-height: 44px;
    max-width: 180px;
    object-fit: contain;
}

.brand-logo-kiosk {
    max-height: 60px;
    max-width: 260px;
    margin: 0 auto;
    object-fit: contain;
}

.brand-logo-tv {
    max-height: 52px;
    object-fit: contain;
}

.brand-logo-badge {
    background: var(--primary);
    padding: 6px 14px;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

/* ── TV Video & Superposición de Llamado ── */
.tv-main-video {
    position: relative;
    padding: 0;
    overflow: hidden;
    background: #020712;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tv-video-container {
    width: 100%;
    height: 100%;
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #020712;
}

.tv-video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tv-video-empty {
    color: rgba(255, 255, 255, 0.4);
    text-align: center;
    font-size: var(--font-size-xl);
}

.tv-call-overlay {
    position: absolute;
    inset: 0;
    z-index: 100;
    background: var(--primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(1rem, 3.5vw, 3rem);
    box-sizing: border-box;
    max-height: 100%;
    overflow: hidden;
    box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.4);
    animation: tvOverlayFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes tvOverlayFadeIn {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.tv-call-badge {
    background: rgba(255, 255, 255, 0.18);
    border: 2px solid rgba(255, 255, 255, 0.4);
    padding: clamp(6px, 1.2vh, 10px) clamp(16px, 2vw, 28px);
    border-radius: var(--radius-full);
    font-size: clamp(0.85rem, 1.3vw, 1.15rem);
    font-weight: 800;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: clamp(6px, 1.5vh, 16px);
    animation: pulse 1.5s infinite;
}

.tv-call-turno {
    font-size: clamp(2.4rem, 5.5vw, 4.8rem);
    font-weight: 900;
    line-height: 1.15;
    letter-spacing: -1px;
    color: #ffffff;
    text-shadow: 0 6px 30px rgba(0, 0, 0, 0.45);
    margin: 0 0 clamp(10px, 2vh, 24px) 0;
    text-align: center;
    text-transform: uppercase;
    max-width: 92%;
    word-break: break-word;
    overflow-wrap: break-word;
    animation: tvPulseIn 0.8s ease;
}

.tv-call-ventanilla-box {
    background: rgba(255, 255, 255, 0.96);
    color: var(--primary);
    padding: clamp(10px, 1.8vh, 18px) clamp(22px, 3vw, 48px);
    border-radius: var(--radius-xl);
    font-size: clamp(1.4rem, 2.8vw, 2.6rem);
    font-weight: 900;
    margin-top: 0;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    gap: clamp(8px, 1vw, 14px);
    letter-spacing: 0.5px;
    max-width: 90%;
    justify-content: center;
    text-align: center;
}

/* ── Lateral TV: Turnos Activos ── */
.tv-active-turn-card {
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-5);
    margin-bottom: var(--space-3);
    border-left: 6px solid #00a8e8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all var(--transition-base);
    animation: slideInRight 0.35s ease;
}

.tv-active-turn-card.status-llamando {
    border-left-color: #f0ad4e;
    background: rgba(240, 173, 78, 0.2);
    box-shadow: 0 0 16px rgba(240, 173, 78, 0.3);
}

.tv-active-turn-card.status-atendiendo {
    border-left-color: #28a745;
    background: rgba(40, 167, 69, 0.16);
}

.tv-active-code {
    font-size: 2.2rem;
    font-weight: 900;
    line-height: 1;
    color: #ffffff;
}

.tv-active-ventanilla {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: rgba(255, 255, 255, 0.9);
    margin-top: 4px;
}

.tv-active-badge {
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: var(--font-size-xs);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tv-active-badge.badge-llamando {
    background: #f0ad4e;
    color: #2b1f00;
    animation: pulse 1.2s infinite;
}

.tv-active-badge.badge-atendiendo {
    background: #28a745;
    color: #ffffff;
}

/* ── Dashboard Admin: Quick Links ── */
.quick-links-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-8);
}

.quick-link-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
}

.quick-link-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.quick-link-icon {
    font-size: 2.2rem;
    width: 54px;
    height: 54px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-lighter);
}

.quick-link-info h4 {
    font-size: var(--font-size-base);
    color: var(--primary-dark);
    margin: 0;
}

.quick-link-info p {
    font-size: var(--font-size-xs);
    color: var(--gray-500);
    margin: 2px 0 0 0;
}

/* ── Ventanilla: Selección de colas a llamar ── */
.call-queues-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.btn-queue-call {
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-5);
    cursor: pointer;
    text-align: left;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-sm);
}

.btn-queue-call:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-queue-call.primary-call {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(20, 67, 144, 0.04), rgba(20, 67, 144, 0.08));
}

.btn-queue-call .queue-title {
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--gray-700);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.btn-queue-call .queue-count {
    font-size: var(--font-size-2xl);
    font-weight: 800;
    color: var(--primary);
    margin: var(--space-2) 0;
}

.btn-queue-call .queue-action {
    font-size: var(--font-size-xs);
    color: var(--primary);
    font-weight: 700;
    text-transform: uppercase;
}

/* ── Kiosko: Botón de retorno inmediato ── */
.btn-immediate-return {
    background: linear-gradient(135deg, #144390 0%, #1a5bbf 100%);
    color: #ffffff !important;
    border: none;
    border-radius: var(--radius-xl);
    padding: var(--space-4) var(--space-8);
    font-size: var(--font-size-xl);
    font-weight: 800;
    box-shadow: 0 8px 25px rgba(20, 67, 144, 0.35);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    margin-top: var(--space-6);
    transition: all var(--transition-base);
    width: 100%;
    max-width: 480px;
}

.btn-immediate-return:hover {
    transform: scale(1.03);
    box-shadow: 0 12px 35px rgba(20, 67, 144, 0.45);
}

.btn-immediate-return:active {
    transform: scale(0.98);
}

/* ═══════════════════════════════════════════
   RESPONSIVE DESIGN (MÓVILES Y TABLETS)
   ═══════════════════════════════════════════ */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .call-queues-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    /* Layout Colapsable */
    .app-layout {
        flex-direction: column;
    }

    /* Grids y Tablas */
    .grid, .grid-2, .grid-4, .call-queues-grid {
        grid-template-columns: 1fr !important;
    }
    .table-wrapper {
        overflow-x: auto;
    }
    .table th, .table td {
        padding: var(--space-2);
        font-size: var(--font-size-sm);
    }
    
    /* Ventanilla y Kiosko Móvil */
    .operator-header {
        flex-direction: column;
        align-items: stretch !important;
        gap: var(--space-3) !important;
        padding: var(--space-3) var(--space-4) !important;
    }
    .operator-header-main {
        width: 100% !important;
        justify-content: space-between;
    }
    .operator-info {
        gap: 6px !important;
    }
    .operator-info .info-item {
        font-size: 0.78rem !important;
        padding: 3px 8px !important;
    }
    .operator-header-actions {
        width: 100% !important;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    .btn-crear-turno-header {
        width: 100% !important;
        justify-content: center;
        padding: 10px 14px !important;
        font-size: 0.95rem !important;
    }
    .operator-secondary-actions {
        width: 100% !important;
        display: flex;
        justify-content: space-between;
        gap: 4px !important;
    }
    .operator-secondary-actions .btn {
        flex: 1;
        justify-content: center;
        padding: 6px 4px !important;
        font-size: 0.75rem !important;
        white-space: nowrap;
    }
    .quick-links-grid {
        grid-template-columns: 1fr;
    }
    .service-grid {
        grid-template-columns: 1fr;
    }
    .main-content {
        padding: var(--space-4);
    }
}

/* ═══════════════════════════════════════════
   IMPRESIÓN (TICKET TÉRMICO)
   ═══════════════════════════════════════════ */
@media print {
    /* Quitar márgenes, encabezados y pies de página del navegador */
    @page { 
        margin: 0;
        size: 80mm auto;
    }

    /* Ocultar todo el sitio web excepto el ticket */
    body * {
        visibility: hidden;
        margin: 0;
        padding: 0;
    }
    
    /* Mostrar solo el ticket */
    #printTicket, #printTicket * {
        visibility: visible;
    }

    #printTicket {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        /* Ajustes precisos para impresora térmica de 80mm */
        padding: 10px 5px 20px 5px;
        background: white;
        text-align: center;
        font-family: monospace, sans-serif;
        color: #000;
        box-shadow: none;
        border: none;
    }

    .ticket-header h2 {
        font-size: 1.4rem;
        margin: 0;
        font-weight: 800;
        text-transform: uppercase;
        color: #000;
    }
    
    .ticket-header p { display: none; } /* Ocultar texto innecesario */

    .ticket-turno {
        font-size: 3.5rem;
        font-weight: 900;
        margin: 15px 0;
        color: #000;
        line-height: 1;
    }

    .ticket-details p {
        font-size: 1rem;
        margin: 5px 0;
        color: #000;
        font-weight: 600;
    }

    /* Ocultar elementos redundantes para ahorrar papel */
    .ticket-footer { display: none; }
}

/* ═══════════════════════════════════════════
   RESPONSIVIDAD EN EL EJE VERTICAL
   (Laptops 768px, Tablets, Kioskos y Ventanas Bajas)
   Garantiza que ningún botón, menú o modal quede cortado
   ═══════════════════════════════════════════ */

@media (max-height: 860px) {
    /* Sidebar Admin */
    .sidebar {
        padding: var(--space-3) 0 !important;
    }
    .sidebar-brand {
        margin-bottom: var(--space-3) !important;
        padding: 0 var(--space-4) !important;
    }
    .brand-logo-sidebar {
        max-height: 36px !important;
    }
    .sidebar-nav li a {
        padding: 7px var(--space-4) !important;
        font-size: 0.85rem !important;
    }
    .sidebar-footer {
        padding: var(--space-2) var(--space-4) !important;
    }

    /* Topbar y Dashboard */
    .topbar {
        padding: var(--space-2) var(--space-6) !important;
    }
    .topbar h1, #sectionTitle {
        font-size: 1.35rem !important;
    }
    .quick-links-grid {
        gap: var(--space-3) !important;
        margin-bottom: var(--space-4) !important;
    }
    .quick-link-card {
        padding: 10px 14px !important;
    }
    .quick-link-icon {
        font-size: 1.4rem !important;
    }
    .quick-link-info h4 {
        font-size: 0.95rem !important;
    }
    .quick-link-info p {
        font-size: 0.75rem !important;
    }
    .stat-card {
        padding: 10px 14px !important;
    }
    .stat-icon {
        width: 40px !important;
        height: 40px !important;
        font-size: 1.25rem !important;
    }
    .stat-number {
        font-size: 1.5rem !important;
    }
    .card {
        margin-bottom: var(--space-4) !important;
    }

    /* Ventanilla / Operador */
    .operator-header {
        padding: var(--space-2) var(--space-6) !important;
    }
    .call-section {
        padding: var(--space-3) var(--space-6) !important;
    }
    .call-btn {
        width: 185px !important;
        height: 185px !important;
        font-size: 0.95rem !important;
        border-width: 4px !important;
        gap: 6px !important;
    }
    .call-btn .call-icon {
        font-size: 2.2rem !important;
    }
    .current-turn {
        margin-top: var(--space-3) !important;
    }
    .current-turn-card {
        padding: 12px 20px !important;
        min-width: 320px !important;
    }
    .current-patient-name {
        font-size: 1.35rem !important;
    }
    .current-turn-number {
        font-size: 1.7rem !important;
    }
    .current-turn-actions .btn {
        padding: 8px 18px !important;
        font-size: 0.95rem !important;
    }
    .history-section {
        margin-top: var(--space-4) !important;
        padding: 0 var(--space-6) var(--space-4) !important;
    }

    /* Kiosko / Generador */
    .kiosk-header {
        padding: var(--space-3) var(--space-4) !important;
    }
    .kiosk-header img {
        height: 38px !important;
        margin-bottom: 2px !important;
    }
    .kiosk-body {
        padding: clamp(0.75rem, 2vh, 1.5rem) !important;
    }
    .kiosk-subtitle {
        font-size: 1.3rem !important;
        margin-bottom: var(--space-4) !important;
    }
    .service-btn {
        padding: 16px 14px !important;
    }
    .service-btn .service-icon {
        font-size: 2.2rem !important;
        margin-bottom: 4px !important;
    }
    .service-btn .service-name {
        font-size: 1.15rem !important;
    }
    .priority-btn {
        padding: 16px 12px !important;
    }
    .priority-btn .priority-icon {
        font-size: 2.2rem !important;
        margin-bottom: 4px !important;
    }
    #stepPaciente .card {
        padding: var(--space-4) !important;
    }
    #stepPaciente .form-group {
        margin-bottom: var(--space-3) !important;
    }
    #stepTicket .ticket-display {
        padding: var(--space-4) !important;
    }

    /* Modales */
    .modal {
        padding: var(--space-5) !important;
        max-height: calc(100vh - 1.5rem) !important;
        max-height: calc(100dvh - 1.5rem) !important;
    }
    .modal h2, .modal h3 {
        font-size: 1.25rem !important;
        margin-bottom: var(--space-3) !important;
    }
    .form-group {
        margin-bottom: var(--space-3) !important;
    }
    .form-control {
        padding: 8px 12px !important;
        font-size: 0.9rem !important;
    }
}

@media (max-height: 700px) {
    /* Sidebar ultra-compacto */
    .sidebar {
        padding: 4px 0 !important;
    }
    .sidebar-brand {
        margin-bottom: 4px !important;
        padding: 0 8px !important;
    }
    .brand-logo-sidebar {
        max-height: 28px !important;
    }
    .sidebar-nav li a {
        padding: 5px 12px !important;
        font-size: 0.8rem !important;
        gap: 6px !important;
    }
    .sidebar-nav li a .nav-icon {
        font-size: 1rem !important;
        width: 18px !important;
    }
    .sidebar-footer {
        padding: 4px 10px !important;
    }

    /* Topbar */
    .topbar {
        padding: 4px 12px !important;
    }
    .topbar h1, #sectionTitle {
        font-size: 1.15rem !important;
    }
    .topbar-user {
        gap: 6px !important;
    }
    .topbar-user .avatar {
        width: 30px !important;
        height: 30px !important;
        font-size: 0.85rem !important;
    }

    /* Ventanilla ultra-compacta */
    .call-section {
        padding: 4px 10px !important;
    }
    .call-btn {
        width: 145px !important;
        height: 145px !important;
        font-size: 0.8rem !important;
        border-width: 3px !important;
        gap: 4px !important;
    }
    .call-btn .call-icon {
        font-size: 1.7rem !important;
    }
    .current-turn-card {
        padding: 8px 14px !important;
        min-width: 270px !important;
    }
    .current-patient-name {
        font-size: 1.15rem !important;
    }
    .current-turn-number {
        font-size: 1.45rem !important;
    }
    .current-turn-actions .btn {
        padding: 6px 12px !important;
        font-size: 0.85rem !important;
    }

    /* Modales en pantallas muy bajas */
    .modal {
        padding: 12px 16px !important;
        max-height: calc(100vh - 1rem) !important;
        max-height: calc(100dvh - 1rem) !important;
    }
    .modal h2, .modal h3 {
        font-size: 1.1rem !important;
        margin-bottom: 6px !important;
    }
    .form-group {
        margin-bottom: 6px !important;
    }
    .form-control {
        padding: 6px 10px !important;
        font-size: 0.85rem !important;
    }
    .btn-lg {
        padding: 8px 16px !important;
        font-size: 0.9rem !important;
    }
    .login-card {
        padding: 16px !important;
    }
    .login-logo {
        margin-bottom: 8px !important;
    }
}

/* ═══════════════════════════════════════════
   PAGINACIÓN DE TABLAS (ADMINISTRACIÓN)
   ═══════════════════════════════════════════ */
.pagination-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-300);
    background: var(--white);
    color: var(--gray-700);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}
.pagination-btn:hover:not(:disabled) {
    background: var(--gray-100);
    border-color: var(--gray-400);
}
.pagination-btn.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
    box-shadow: 0 2px 6px rgba(20, 67, 144, 0.35);
}
.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}


