/* ======================================================
   SISTEMA DE AGENDA DE CIRUGÍAS - ESTILOS INSTITUCIONALES
   ====================================================== */

/* --- VARIABLES INSTITUCIONALES ---
   Modifica estos valores para cambiar la paleta
   de colores en toda la aplicación.
   ---------------------------------------------------- */
:root {
    /* Colores Institucionales */
    --color-primary: #17A3A3;
    --color-primary-dark: #119C9C;
    --color-primary-light: #9DC43E;
    --color-primary-rgb: 23, 163, 163;

    --color-secondary: #C8C8C8;
    --color-secondary-dark: #9E9E9E;
    --color-secondary-light: #E0E0E0;
    --color-secondary-rgb: 200, 200, 200;

    /* Colores de Estado */
    --color-success: #2E7D32;
    --color-warning: #F9A825;
    --color-info: #0288D1;
    --color-danger: #C62828;

    /* Colores de Estado de Pabellón */
    --status-reagendado: #1A237E;
    --status-agendado: #2196F3;
    --status-confirmado: #8BC34A;
    --status-realizado: #81C784;
    --status-cancelado: #C10015;
    --status-suspendido: #F44336;

    /* Colores de Rol */
    --role-cirujano-1: #0D47A1;
    --role-cirujano-2: #1565C0;
    --role-cirujano-3: #1976D2;
    --role-cirujano-4: #1E88E5;
    --role-cirujano-5: #42A5F5;
    --role-cirujano-6: #90CAF9;
    --role-anestesista: #6A1B9A;
    --role-anestesista-staff: #8E24AA;
    --role-pediatra: #F9A825;
    --role-patologo: #455A64;

    /* Superficies y Texto */
    --bg-body: #F5F5F5;
    --bg-surface: #FFFFFF;
    --bg-surface-alt: #FAFAFA;
    --text-primary: #212121;
    --text-secondary: #616161;
    --text-muted: #9E9E9E;
    --border-color: #E0E0E0;
    --border-color-light: #EEEEEE;

    /* Sombras */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08), 0 4px 10px rgba(0, 0, 0, 0.04);

    /* Espaciado */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
}

/* ======================================================
   BASE
   ====================================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Evitar zoom en inputs en iOS < 16 */
    touch-action: manipulation;
}

main {
    flex: 1;
    /* Safe area para notch (iPhone X+, Huawei P40+) */
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

::selection {
    background-color: rgba(var(--color-primary-rgb), 0.15);
    color: var(--color-primary-dark);
}

/* Inputs: prevenir zoom en iOS con font-size < 16px */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="url"],
input[type="number"],
input[type="date"],
select,
textarea {
    font-size: 16px !important;
}

/* Quitar highlight azul en tap (Android/Huawei) */
a, button, input, select, textarea, [role="button"] {
    -webkit-tap-highlight-color: transparent;
}

/* Quitar estilo nativo de botones en iOS */
input[type="submit"],
input[type="button"],
button {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Scrollbar delgada para Android/Chrome */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--color-secondary);
    border-radius: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

/* ======================================================
   NAVBAR / HEADER INSTITUCIONAL
   ====================================================== */

.navbar-institutional {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    box-shadow: 0 2px 12px rgba(var(--color-primary-rgb), 0.3);
    padding: 0.85rem 1.5rem;
    padding-top: calc(0.85rem + env(safe-area-inset-top));
    padding-left: calc(1.5rem + env(safe-area-inset-left));
    padding-right: calc(1.5rem + env(safe-area-inset-right));
    z-index: 1030;
}

.navbar-institutional .navbar-brand {
    font-size: 1.35rem;
    font-weight: 700;
    color: #FFFFFF;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.navbar-institutional .navbar-brand .brand-icon {
    background: rgba(255, 255, 255, 0.2);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
}

.navbar-institutional .navbar-date {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.875rem;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.12);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
}

/* Logos centrados en el navbar */
.navbar-logos {
    position: absolute;
    left: 50%;
    top: 50%;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    gap: 12px;
}

.navbar-logos img {
    height: 36px;
    width: auto;
    max-width: 160px;
    object-fit: contain;
}

/* ======================================================
   TARJETAS / CARDS
   ====================================================== */

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.25s ease, transform 0.25s ease;
}

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

.card-body {
    padding: 1.75rem;
}

.card-title {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.2px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title .title-icon {
    color: var(--color-primary);
    font-size: 1rem;
}

.card-title .title-line {
    flex: 1;
    height: 1px;
    background: var(--border-color-light);
    margin-left: 8px;
}

/* ======================================================
   FILTROS
   ====================================================== */

.filters-section {
    margin-bottom: 1.75rem;
}

.form-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-label i {
    color: var(--color-primary);
    font-size: 0.85rem;
}

.form-control,
.form-select {
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.7rem 1rem;
    font-size: 0.95rem;
    color: var(--text-primary);
    background-color: var(--bg-surface);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.12);
    outline: none;
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-control-lg,
.form-select-lg {
    padding: 0.8rem 1rem;
    font-size: 0.95rem;
}

/* ======================================================
   BOTONES
   ====================================================== */

.btn {
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: var(--radius-sm);
    padding: 0.7rem 1.5rem;
    border: none;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
}

.btn-institutional {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: #FFFFFF;
    box-shadow: 0 2px 6px rgba(var(--color-primary-rgb), 0.3);
}

.btn-institutional:hover {
    background: linear-gradient(135deg, var(--color-primary-light) 0%, var(--color-primary) 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--color-primary-rgb), 0.35);
    color: #FFFFFF;
}

.btn-institutional:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(var(--color-primary-rgb), 0.3);
}

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

.btn-outline-institutional:hover {
    background: rgba(var(--color-primary-rgb), 0.06);
    color: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
}

/* Botón confirmar asistencia (check) - desktop */
.btn-outline-institutional.btn-confirm-surgery {
    color: var(--color-success);
    border-color: var(--color-success);
}

.btn-outline-institutional.btn-confirm-surgery:hover {
    background: var(--color-success);
    color: #fff;
    border-color: var(--color-success);
}

/* Botón gestión (gear) - desktop */
.btn-outline-institutional.btn-view-gestion {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.btn-outline-institutional.btn-view-gestion:hover {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(var(--color-primary-rgb), 0.3);
}

.btn-outline-institutional.btn-view-gestion:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(var(--color-primary-rgb), 0.3);
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 0.8rem 1.5rem;
    font-size: 0.95rem;
}

/* ======================================================
   TABLA DE CIRUGÍAS
   ====================================================== */

.table-wrapper {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color-light);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table {
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
}

.table thead th {
    background: #17A3A3;
    color: #FFFFFF;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 1rem 0.85rem;
    border: none;
    white-space: nowrap;
}

.table thead th i {
    margin-right: 5px;
    opacity: 0.7;
    font-size: 0.75rem;
}

.table thead th:first-child {
    border-left: 3px solid var(--color-primary);
}

.table tbody tr {
    border-bottom: 1px solid var(--border-color-light);
    transition: background-color 0.15s ease;
    animation: fadeInRow 0.3s ease forwards;
}

.table tbody tr.row-status--confirmed > td:first-child {
    border-left: 4px solid var(--status-confirmado);
}

.table tbody tr.row-status--scheduled > td:first-child {
    border-left: 4px solid var(--status-agendado);
}

.table tbody tr.row-status--resolved > td:first-child {
    border-left: 4px solid var(--status-realizado);
}

.table tbody tr.row-status--reagendado > td:first-child {
    border-left: 4px solid var(--status-reagendado);
}

.table tbody tr.row-status--cancelado > td:first-child {
    border-left: 4px solid var(--status-cancelado);
}

.table tbody tr.row-status--suspendido > td:first-child {
    border-left: 4px solid var(--status-suspendido);
}

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

.table tbody tr:hover {
    background-color: rgba(var(--color-primary-rgb), 0.03);
}

.table tbody td {
    padding: 0.9rem 0.85rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    vertical-align: middle;
    border: none;
}

/* Celda de hora destacada */
.cell-time {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    white-space: nowrap;
}

.cell-time i {
    color: var(--color-primary);
    margin-right: 4px;
    font-size: 0.8rem;
}

/* Celda de médico */
.cell-doctor {
    line-height: 1.4;
}

.cell-doctor .doctor-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.cell-doctor .doctor-specialty {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Celda de quirófano */
.cell-room {
    font-weight: 700;
    text-align: center;
}

/* Centrar header de Pabellón */
.table thead th.th-room {
    text-align: center;
}

/* ======================================================
   BADGES / ETIQUETAS DE ESTADO
   ====================================================== */

.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0.4rem 0.75rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.2px;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge-status--confirmed {
    background: rgba(139, 195, 74, 0.12);
    color: var(--status-confirmado);
}

.badge-status--confirmed::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--status-confirmado);
}

.badge-status--scheduled {
    background: rgba(33, 150, 243, 0.12);
    color: var(--status-agendado);
}

.badge-status--scheduled::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--status-agendado);
}

.badge-status--resolved {
    background: rgba(129, 199, 132, 0.12);
    color: var(--status-realizado);
}

.badge-status--resolved::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--status-realizado);
}

.badge-status--reagendado {
    background: rgba(26, 35, 126, 0.1);
    color: var(--status-reagendado);
}

.badge-status--reagendado::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--status-reagendado);
}

.badge-status--cancelado {
    background: rgba(193, 0, 21, 0.1);
    color: var(--status-cancelado);
}

.badge-status--cancelado::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--status-cancelado);
}

.badge-status--suspendido {
    background: rgba(244, 67, 54, 0.1);
    color: var(--status-suspendido);
}

.badge-status--suspendido::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--status-suspendido);
}

.badge-room {
    display: inline-block;
    background: #9DC43E;
    color: #fff;
    font-weight: 700;
    font-size: 0.78rem;
    padding: 0.35rem 0.7rem;
    border-radius: 6px;
    letter-spacing: 0.5px;
}

.badge-room--default {
    background: #9DC43E;
}

.badge-room--pdv {
    background: #f36340;
}

.badge-room--tf {
    background: #56ccc1;
}

/* ---- Badge Rol (estilo similar a badge-status) ---- */
.badge-role {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0.4rem 0.75rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.badge-role::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.badge-role--default {
    background: rgba(96, 125, 139, 0.12);
    color: #607D8B;
}
.badge-role--default::before {
    background: #607D8B;
}

.badge-role--cirujano-1 {
    background: rgba(13, 71, 161, 0.12);
    color: var(--role-cirujano-1);
}
.badge-role--cirujano-1::before {
    background: var(--role-cirujano-1);
}

.badge-role--cirujano-2 {
    background: rgba(21, 101, 192, 0.12);
    color: var(--role-cirujano-2);
}
.badge-role--cirujano-2::before {
    background: var(--role-cirujano-2);
}

.badge-role--cirujano-3 {
    background: rgba(25, 118, 210, 0.12);
    color: var(--role-cirujano-3);
}
.badge-role--cirujano-3::before {
    background: var(--role-cirujano-3);
}

.badge-role--cirujano-4 {
    background: rgba(30, 136, 229, 0.12);
    color: var(--role-cirujano-4);
}
.badge-role--cirujano-4::before {
    background: var(--role-cirujano-4);
}

.badge-role--cirujano-5 {
    background: rgba(66, 165, 245, 0.12);
    color: var(--role-cirujano-5);
}
.badge-role--cirujano-5::before {
    background: var(--role-cirujano-5);
}

.badge-role--cirujano-6 {
    background: rgba(144, 202, 249, 0.15);
    color: #1565C0;
}
.badge-role--cirujano-6::before {
    background: var(--role-cirujano-6);
}

.badge-role--anestesista {
    background: rgba(106, 27, 154, 0.12);
    color: var(--role-anestesista);
}
.badge-role--anestesista::before {
    background: var(--role-anestesista);
}

.badge-role--anestesista-staff {
    background: rgba(142, 36, 170, 0.12);
    color: var(--role-anestesista-staff);
}
.badge-role--anestesista-staff::before {
    background: var(--role-anestesista-staff);
}

.badge-role--pediatra {
    background: rgba(249, 168, 37, 0.12);
    color: #F57F17;
}
.badge-role--pediatra::before {
    background: var(--role-pediatra);
}

.badge-role--patologo {
    background: rgba(69, 90, 100, 0.12);
    color: var(--role-patologo);
}
.badge-role--patologo::before {
    background: var(--role-patologo);
}
/* ======================================================
   NAVBAR USER BUTTON
   ====================================================== */

.navbar-user-btn {
    background: rgba(255, 255, 255, 0.15);
    color: #FFFFFF;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s ease;
}

.navbar-user-btn:hover,
.navbar-user-btn:focus {
    background: rgba(255, 255, 255, 0.25);
    color: #FFFFFF;
}

.navbar-user-btn .fa-user-circle {
    font-size: 1.15rem;
}

/* ======================================================
   SELECTOR DE FECHA (Mobile-First)
   ====================================================== */

.date-selector-section {
    margin-bottom: 1rem;
}

/* Month filter (resueltas page) */
.month-filter-section {
    margin-bottom: 1rem;
}

.month-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-surface);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color-light);
    box-shadow: var(--shadow-sm);
}

.month-display {
    flex: 1;
    text-align: center;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.5rem;
    min-height: 40px;
}

.month-display i {
    color: var(--color-primary);
}

/* Filter mode toggle (mes/día) */
.filter-mode-toggle {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    background: var(--bg-surface);
    padding: 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color-light);
}

.filter-mode-btn {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    touch-action: manipulation;
}

.filter-mode-btn i {
    font-size: 0.85rem;
}

.filter-mode-btn:hover {
    background: rgba(var(--color-primary-rgb), 0.06);
    color: var(--color-primary);
}

.filter-mode-btn.active {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: #fff;
    box-shadow: 0 2px 4px rgba(var(--color-primary-rgb), 0.25);
}

.filter-mode-btn:active {
    transform: scale(0.97);
}

/* Navbar back button style */
.navbar-brand--back {
    text-decoration: none;
    color: inherit;
}

.navbar-brand--back:hover {
    color: inherit;
}

.navbar-brand--back .brand-icon {
    background: rgba(255,255,255,0.2);
}

/* Date tag in cards (resueltas) */
.surgery-card__date-tag {
    display: inline-block;
    background: rgba(21, 101, 192, 0.1);
    color: #1565C0;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    margin-right: 4px;
}

/* Date cell in table */
.cell-date {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.date-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-surface);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color-light);
    box-shadow: var(--shadow-sm);
}

.date-nav-btn {
    width: 40px;
    height: 40px;
    min-width: 44px;
    min-height: 44px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-secondary);
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    -webkit-justify-content: center;
    justify-content: center;
    cursor: pointer;
    -webkit-transition: all 0.2s ease;
    transition: all 0.2s ease;
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
    font-size: 0.9rem;
    touch-action: manipulation;
}

.date-nav-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: rgba(var(--color-primary-rgb), 0.04);
}

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

.date-display {
    flex: 1;
    position: relative;
    text-align: center;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: background 0.2s ease;
    min-height: 40px;
}

.date-display:hover {
    background: rgba(var(--color-primary-rgb), 0.04);
}

.date-display i {
    color: var(--color-primary);
    font-size: 0.9rem;
}

.date-today-btn {
    border: 1.5px solid var(--color-primary);
    background: rgba(var(--color-primary-rgb), 0.06);
    color: var(--color-primary);
    font-weight: 700;
    font-size: 0.8rem;
    padding: 0.45rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    white-space: nowrap;
}

.date-today-btn:hover {
    background: var(--color-primary);
    color: #FFFFFF;
}

/* =============================================
   CALENDARIO PERSONALIZADO
   ============================================= */
.date-selector-section {
    position: relative;
}

.custom-calendar {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    margin-top: 6px;
    background: #FFFFFF;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18), 0 2px 10px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border-color-light);
    padding: 1rem;
    -webkit-animation: calendarSlideIn 0.2s ease;
    animation: calendarSlideIn 0.2s ease;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

@-webkit-keyframes calendarSlideIn {
    from { opacity: 0; -webkit-transform: translateY(-8px); transform: translateY(-8px); }
    to   { opacity: 1; -webkit-transform: translateY(0); transform: translateY(0); }
}

@keyframes calendarSlideIn {
    from { opacity: 0; -webkit-transform: translateY(-8px); transform: translateY(-8px); }
    to   { opacity: 1; -webkit-transform: translateY(0); transform: translateY(0); }
}

.custom-calendar__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.custom-calendar__month {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    text-transform: capitalize;
}

.custom-calendar__nav {
    width: 36px;
    height: 36px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    -webkit-justify-content: center;
    justify-content: center;
    cursor: pointer;
    -webkit-transition: all 0.2s;
    transition: all 0.2s;
    font-size: 0.8rem;
}

.custom-calendar__nav:hover {
    background: rgba(var(--color-primary-rgb), 0.08);
    color: var(--color-primary);
}

.custom-calendar__weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    margin-bottom: 0.4rem;
}

.custom-calendar__weekdays span {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 4px 0;
}

.custom-calendar__grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.cal-day {
    position: relative;
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: column;
    flex-direction: column;
    -webkit-align-items: center;
    align-items: center;
    -webkit-justify-content: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    -webkit-transition: all 0.15s;
    transition: all 0.15s;
    padding: 0;
    /* Minimum touch target (WCAG 2.5.5) */
    touch-action: manipulation;
}

.cal-day:hover {
    background: rgba(var(--color-primary-rgb), 0.08);
}

.cal-day--other-month {
    color: var(--text-muted);
    opacity: 0.4;
}

.cal-day--today {
    font-weight: 800;
    color: var(--color-primary);
    background: rgba(var(--color-primary-rgb), 0.08);
}

.cal-day--selected {
    background: var(--color-primary) !important;
    color: #fff !important;
    font-weight: 700;
}

.cal-day--selected .cal-day__dot {
    background: #fff !important;
}

.cal-day--has-surgery::after {
    content: '';
    position: absolute;
    bottom: 3px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--color-primary);
}

/* Punto amarillo: participa como staff (rol distinto a 1er cirujano) */
.cal-day--has-surgery-staff::before {
    content: '';
    position: absolute;
    bottom: 3px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #f0ad4e;
}

/* Cuando tiene ambos puntos (cirujano + staff), separar horizontalmente */
.cal-day--has-surgery.cal-day--has-surgery-staff::after {
    left: calc(50% + 2px);
}
.cal-day--has-surgery.cal-day--has-surgery-staff::before {
    left: calc(50% - 7px);
}

.cal-day--selected.cal-day--has-surgery::after {
    background: #fff;
}

.cal-day--selected.cal-day--has-surgery-staff::before {
    background: rgba(255,255,255,0.7);
}

.cal-day--today.cal-day--has-surgery::after {
    background: var(--color-primary-dark);
}

.cal-day--today.cal-day--has-surgery-staff::before {
    background: #e69500;
}

/* ======================================================
   SUMMARY CARDS (Resumen rápido)
   ====================================================== */

.summary-cards {
    margin-bottom: 1.25rem;
}

.summary-card {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: 0.85rem 0.75rem;
    text-align: center;
    border: 1px solid var(--border-color-light);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease;
}

.summary-card:active {
    transform: scale(0.98);
}

.summary-card__value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 4px;
}

.summary-card__label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
}

.summary-card--total .summary-card__value {
    color: var(--color-primary);
}

.summary-card--confirmed .summary-card__value {
    color: var(--color-success);
}

.summary-card--scheduled .summary-card__value {
    color: #E65100;
}

.summary-card--pending .summary-card__value {
    color: var(--color-warning);
}

.summary-card--rejected .summary-card__value {
    color: var(--color-danger);
}

/* Filter cards: clickable + active states */
.summary-card--filter {
    cursor: pointer;
    transition: all 0.25s ease;
}

.summary-card--filter:hover {
    border-color: var(--border-color-light);
    box-shadow: var(--shadow-md);
}

/* Total (primary teal) */
.summary-card--total.summary-card--active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    box-shadow: 0 4px 14px rgba(var(--color-primary-rgb), 0.45);
}
.summary-card--total.summary-card--active .summary-card__value,
.summary-card--total.summary-card--active .summary-card__label {
    color: #fff;
}

/* Confirmadas (green) */
.summary-card--confirmed.summary-card--active {
    background: var(--color-success);
    border-color: var(--color-success);
    box-shadow: 0 4px 14px rgba(46, 125, 50, 0.45);
}
.summary-card--confirmed.summary-card--active .summary-card__value,
.summary-card--confirmed.summary-card--active .summary-card__label {
    color: #fff;
}

/* Pendientes (amber) */
.summary-card--pending.summary-card--active {
    background: var(--color-warning);
    border-color: var(--color-warning);
    box-shadow: 0 4px 14px rgba(249, 168, 37, 0.45);
}
.summary-card--pending.summary-card--active .summary-card__value,
.summary-card--pending.summary-card--active .summary-card__label {
    color: #fff;
}

/* Rechazadas (red) */
.summary-card--rejected.summary-card--active {
    background: var(--color-danger);
    border-color: var(--color-danger);
    box-shadow: 0 4px 14px rgba(198, 40, 40, 0.45);
}
.summary-card--rejected.summary-card--active .summary-card__value,
.summary-card--rejected.summary-card--active .summary-card__label {
    color: #fff;
}

.summary-card--resolved .summary-card__value {
    color: #1565C0;
}

/* Card clickable (Resueltas) */
.summary-card--clickable {
    display: block;
    text-decoration: none;
    color: inherit;
    position: relative;
    cursor: pointer;
}

.summary-card--clickable:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md);
}

.summary-card--clickable:active {
    transform: scale(0.96);
}

.summary-card__arrow {
    position: absolute;
    top: 6px;
    right: 6px;
    font-size: 0.55rem;
    color: var(--text-muted);
    opacity: 0.6;
}

/* Título superior de la card doble-columna */
.summary-card__label--main {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

/* Contenedor de las dos estadísticas */
.summary-card__stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.summary-card__stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.summary-card__stat-divider {
    width: 1px;
    height: 38px;
    background: var(--border-color-light);
    margin: 0 10px;
    flex-shrink: 0;
}

/* Color ámbar para el mes anterior — contrasta con el azul #1565C0 del mes actual */
.summary-card__value--prev,
.summary-card--resolved .summary-card__value.summary-card__value--prev {
    color: #D4850A;
}

/* Card "Total del mes" */
.summary-card--total-month {
    position: relative;
}
.summary-card--total-month .summary-card__value {
    color: #2E7D32;
}
.summary-card--total-month .summary-card__icon {
    position: absolute;
    top: 6px;
    right: 6px;
    font-size: 0.65rem;
    color: #2E7D32;
    opacity: 0.5;
}

/* ======================================================
   SURGERY CARDS (Vista Móvil)
   ====================================================== */

.surgery-cards-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 1.5rem;
}

.surgery-card {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color-light);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow 0.2s ease;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    border-left: 4px solid transparent;
}

.surgery-card.card-status--confirmed {
    border-left: 4px solid var(--status-confirmado);
}

.surgery-card.card-status--scheduled {
    border-left: 4px solid var(--status-agendado);
}
.surgery-card.card-status--resolved {
    border-left: 4px solid var(--status-realizado);
}

.surgery-card.card-status--reagendado {
    border-left: 4px solid var(--status-reagendado);
}

.surgery-card.card-status--cancelado {
    border-left: 4px solid var(--status-cancelado);
}

.surgery-card.card-status--suspendido {
    border-left: 4px solid var(--status-suspendido);
}

.surgery-card:active {
    box-shadow: var(--shadow-md);
}

.surgery-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color-light);
    background: var(--bg-surface-alt);
}

.surgery-card__time {
    font-weight: 800;
    font-size: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.surgery-card__time i {
    color: var(--color-primary);
    font-size: 0.75rem;
}

.surgery-card__room {
    display: flex;
    align-items: center;
    gap: 6px;
}

.surgery-card__body {
    padding: 0.85rem 1rem;
}

.surgery-card__patient {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.surgery-card__procedure {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    line-height: 1.4;
}

.surgery-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.surgery-card__footer--actions {
    padding-top: 8px;
    border-top: 1px solid var(--border-color-light);
    margin-top: 8px;
}

.surgery-card__role {
    font-size: 0.78rem;
    font-weight: 600;
}

.surgery-card__role .badge-role {
    font-size: 0.72rem;
    padding: 3px 10px;
}

/* ------ Card Action Buttons (móvil) ------ */
.surgery-card__actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-card-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1.5px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    -webkit-tap-highlight-color: transparent;
}

.btn-card-action:active {
    transform: scale(0.92);
}

.btn-card-action.btn-confirm-surgery {
    border-color: var(--color-success);
    color: var(--color-success);
}

.btn-card-action.btn-confirm-surgery:active {
    background: var(--color-success);
    color: #fff;
}

.btn-card-action.btn-view-gestion {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
    box-shadow: 0 6px 12px rgba(var(--color-primary-rgb), 0.25);
}
.btn-card-action.btn-view-gestion:hover {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
    box-shadow: 0 8px 16px rgba(var(--color-primary-rgb), 0.3);
}

.btn-card-action.btn-view-gestion:active {
    background: var(--color-primary-dark);
    color: #fff;
    
}

.btn-card-action.btn-view-detail {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.btn-card-action.btn-view-detail:active {
    background: var(--color-primary);
    color: #fff;
}

.btn-card-action:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn-card-action:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.25);
}

/* Status icon buttons (confirmed/rejected state) */
.btn-status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid;
    background: var(--bg-surface);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    -webkit-tap-highlight-color: transparent;
}

.btn-status-icon--confirmed {
    border-color: #2E7D32;
    background: #2E7D32;
    color: #fff;
    box-shadow: 0 6px 12px rgba(46, 125, 50, 0.35);
}

.btn-status-icon--confirmed:hover {
    background: #1B5E20;
    border-color: #1B5E20;
    transform: scale(1.05);
}

.btn-status-icon--rejected {
    border-color: #C62828;
    background: #C62828;
    color: #fff;
    box-shadow: 0 6px 12px rgba(198, 40, 40, 0.35);
}

.btn-status-icon--rejected:hover {
    background: #B71C1C;
    border-color: #B71C1C;
    transform: scale(1.05);
}

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

.btn-status-icon:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.25);
}

/* Gestion modal buttons */
#btnConfirmGestion.active,
#btnRejectGestion.active {
    opacity: 0.7;
    position: relative;
}

#btnConfirmGestion.active::after,
#btnRejectGestion.active::after {
    content: '✓';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
}

#gestionModal .modal-footer .btn {
    box-shadow: none;
    background-image: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-appearance: none;
    appearance: none;
    transform: translateZ(0);
}

#gestionModal .modal-footer .btn:active,
#gestionModal .modal-footer .btn:focus,
#gestionModal .modal-footer .btn:focus-visible {
    box-shadow: none;
    background-image: none;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

#btnConfirmGestion:active {
    background-color: var(--color-success);
    border-color: var(--color-success);
}

#btnRejectGestion:active {
    background-color: var(--color-danger);
    border-color: var(--color-danger);
}

#btnConfirmGestion:focus-visible {
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.25);
}

#btnRejectGestion:focus-visible {
    box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.25);
}

/* Disabled state para botones desktop confirm */
.btn-outline-institutional.btn-confirm-surgery:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ======================================================
   RESULT MODAL (éxito / error)
   ====================================================== */
.result-modal-content {
    text-align: center;
    padding: 0.5rem 1rem 1rem;
}

.result-modal-icon {
    font-size: 3.5rem;
    margin-bottom: 0.75rem;
}

.result-modal-icon i {
    line-height: 1;
}

.result-success .result-modal-icon {
    color: var(--color-success);
}

.result-error .result-modal-icon {
    color: #D32F2F;
}

.result-modal-title {
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.result-modal-message {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0;
    line-height: 1.5;
}

.btn-institutional {
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.5rem 1.5rem;
    transition: background 0.2s ease;
}

.btn-institutional:hover,
.btn-institutional:focus {
    background: var(--color-primary-dark);
    color: #fff;
}

/* ======================================================
   BUDGET BUTTON & PDF VIEWER
   ====================================================== */

.cell-budget {
    white-space: nowrap;
}

.btn-budget {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.3rem 0.6rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-primary);
    background: rgba(23, 163, 163, 0.08);
    border: 1.5px solid var(--color-primary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
}

.btn-budget:hover {
    background: var(--color-primary);
    color: #fff;
}

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

.btn-budget:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Budget en card móvil */
.btn-budget--card {
    font-size: 0.72rem;
    padding: 0.25rem 0.5rem;
}

/* PDF iframe dentro del modal */
.budget-pdf-frame {
    width: 100%;
    height: 65vh;
    border: none;
    background: #fff;
}

@media (max-width: 576px) {
    .budget-pdf-frame {
        height: calc(100vh - 120px);
    }
}

/* ======================================================
   LOADING STATE
   ====================================================== */

.loading-state {
    text-align: center;
    padding: 3rem 1rem;
}

.loading-state .spinner-border {
    width: 2.5rem;
    height: 2.5rem;
    border-width: 3px;
    color: var(--color-primary);
}

.loading-state p {
    font-size: 0.9rem;
    font-weight: 500;
}

/* =============================================
   BUSCADOR DE PACIENTE
   ============================================= */
.search-section {
    margin-bottom: 1rem;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
    background: #FFFFFF;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color-light);
    transition: box-shadow 0.2s, border-color 0.2s;
}

.search-box:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.12);
}

.search-box__icon {
    color: var(--color-primary);
    font-size: 1rem;
    margin-right: 0.6rem;
    flex-shrink: 0;
}

.search-box__input {
    border: none;
    background: transparent;
    font-size: 0.9rem;
    padding: 0.35rem 0;
    flex: 1;
    min-width: 0;
}

.search-box__input::placeholder {
    color: #aab0b8;
    font-size: 0.85rem;
}

.search-box__input:focus {
    box-shadow: none;
    outline: none;
}

.search-box__clear {
    background: none;
    border: none;
    color: #aab0b8;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 0.85rem;
    flex-shrink: 0;
    transition: color 0.2s;
}

.search-box__clear:hover {
    color: var(--color-primary);
}

/* ======================================================
   RESULTADOS HEADER
   ====================================================== */

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.results-header h5 {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.results-header h5 i {
    color: var(--color-primary);
}

.results-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.results-count strong {
    color: var(--color-primary);
}

/* ======================================================
   EMPTY STATE / SIN RESULTADOS
   ====================================================== */

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--border-color);
}

.empty-state .empty-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(var(--color-primary-rgb), 0.08);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.25rem;
}

.empty-state .empty-icon i {
    font-size: 2rem;
    color: var(--color-primary);
}

.empty-state h6 {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
}

/* ======================================================
   MODAL DE DETALLES
   ====================================================== */

.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.modal-header {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: #FFFFFF;
    border: none;
    padding: 1.25rem 1.5rem;
}

.modal-header .modal-title {
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-header .btn-close {
    filter: brightness(0) invert(1);
    opacity: 0.8;
}

.modal-header .btn-close:hover {
    opacity: 1;
}

.modal-body {
    padding: 1.75rem;
}

.detail-row {
    display: flex;
    align-items: flex-start;
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--border-color-light);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-row .detail-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(var(--color-primary-rgb), 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 14px;
    flex-shrink: 0;
}

.detail-row .detail-icon i {
    color: var(--color-primary);
    font-size: 0.85rem;
}

.detail-row .detail-content {
    flex: 1;
}

.detail-row .detail-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.detail-row .detail-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-footer {
    border-top: 1px solid var(--border-color-light);
    padding: 1rem 1.5rem;
}

/* ======================================================
   FOOTER INSTITUCIONAL
   ====================================================== */

.footer-institutional {
    background: var(--text-primary);
    color: rgba(255, 255, 255, 0.7);
    padding: 1.25rem 0;
    margin-top: auto;
}

.footer-institutional .footer-brand {
    font-weight: 600;
    color: #FFFFFF;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.footer-institutional .footer-brand i {
    color: var(--color-primary);
}

.footer-institutional .footer-copy {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 4px;
}

/* ======================================================
   ANIMACIONES
   ====================================================== */

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

/* ======================================================
   RESPONSIVE - TABLET
   ====================================================== */

@media (max-width: 992px) {
    .card-body {
        padding: 1.25rem;
    }
}

@media (max-width: 768px) {
    .navbar-institutional {
        padding: 0.55rem 0.75rem;
    }

    .navbar-institutional .navbar-brand {
        font-size: 1rem;
    }

    .navbar-institutional .navbar-brand .brand-icon {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }

    .navbar-logos img {
        height: 28px;
        max-width: 120px;
    }

    .card-body {
        padding: 1rem;
    }

    .table thead th {
        font-size: 0.72rem;
        padding: 0.75rem 0.6rem;
    }

    .table tbody td {
        font-size: 0.82rem;
        padding: 0.7rem 0.6rem;
    }

    .btn-lg {
        padding: 0.65rem 1rem;
        font-size: 0.9rem;
    }

    .form-control,
    .form-select {
        font-size: 16px;
    }

    main {
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }

    .results-header {
        margin-bottom: 0.75rem;
    }

    .results-header h5 {
        font-size: 0.95rem;
    }

    .summary-card__value {
        font-size: 1.5rem;
    }
}

/* ======================================================
   RESPONSIVE - MÓVIL
   ====================================================== */

@media (max-width: 576px) {
    .container-fluid {
        padding-left: 0.65rem;
        padding-right: 0.65rem;
    }

    .navbar-institutional {
        padding: 0.5rem 0.65rem;
    }

    .navbar-institutional .navbar-brand {
        font-size: 0.9rem;
        gap: 6px;
    }

    .navbar-institutional .navbar-brand .brand-icon {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
        border-radius: 7px;
    }

    .navbar-logos {
        position: static;
        -webkit-transform: none;
        transform: none;
        gap: 6px;
    }

    .navbar-logos img {
        height: 22px;
        max-width: 90px;
    }

    .navbar-user-btn {
        padding: 0.35rem 0.5rem;
        font-size: 0.8rem;
    }

    .navbar-user-btn .fa-user-circle {
        font-size: 1.1rem;
    }

    .date-selector {
        gap: 6px;
        padding: 6px 8px;
    }

    .date-nav-btn {
        width: 36px;
        height: 36px;
    }

    .date-display {
        font-size: 0.88rem;
    }

    .date-today-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }

    .summary-card {
        padding: 0.7rem 0.5rem;
    }

    .summary-card__value {
        font-size: 1.35rem;
    }

    .summary-card__label {
        font-size: 0.62rem;
    }

    .surgery-card__header {
        padding: 0.6rem 0.85rem;
    }

    .surgery-card__body {
        padding: 0.7rem 0.85rem 1rem;
    }

    .surgery-card__patient {
        font-size: 0.9rem;
    }

    .surgery-card__procedure {
        font-size: 0.82rem;
    }

    .badge-status {
        font-size: 0.65rem;
        padding: 0.3rem 0.5rem;
    }

    .badge-room {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
    }

    .btn {
        font-size: 0.85rem;
    }

    .empty-state {
        padding: 2.5rem 1.5rem;
    }

    .empty-state .empty-icon {
        width: 60px;
        height: 60px;
    }

    .empty-state .empty-icon i {
        font-size: 1.5rem;
    }

    .modal-body {
        padding: 1.25rem;
    }

    .detail-row .detail-icon {
        width: 30px;
        height: 30px;
        margin-right: 10px;
    }

    .detail-row .detail-icon i {
        font-size: 0.75rem;
    }

    .detail-row .detail-value {
        font-size: 0.88rem;
    }

    #gestionModal .modal-footer {
        gap: 10px;
    }

    #gestionModal .modal-footer .btn {
        width: 100%;
        justify-content: center;
    }

    #gestionModal .modal-footer .btn + .btn {
        margin-left: 0;
    }

    .surgery-card__actions {
        gap: 10px;
    }

    .btn-card-action {
        width: 40px;
        height: 40px;
        font-size: 0.95rem;
        border-radius: 10px;
    }

    .btn-status-icon {
        width: 42px;
        height: 42px;
        font-size: 1rem;
    }
}

/* ======================================================
   SAFE-AREA BOTTOM (iPhone Home bar, Huawei gesture bar)
   ====================================================== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    main {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .modal-footer {
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    }
}

/* ======================================================
   iOS 100vh FIX
   ====================================================== */
@supports (-webkit-touch-callout: none) {
    body {
        min-height: -webkit-fill-available;
    }
}

/* ======================================================
   LANDSCAPE PHONE ADJUSTMENTS
   ====================================================== */
@media (max-height: 500px) and (orientation: landscape) {
    .navbar-institutional {
        padding-top: 0.4rem;
        padding-bottom: 0.4rem;
    }

    .date-selector-section {
        margin-bottom: 0.5rem;
    }

    .summary-cards {
        margin-bottom: 0.5rem;
    }

    .summary-card {
        padding: 0.5rem 0.4rem;
    }

    .summary-card__value {
        font-size: 1.1rem;
    }

    .custom-calendar {
        max-height: 60vh;
        overflow-y: auto;
    }
}

/* ======================================================
   HIGH-DPI / RETINA BORDER FIX
   ====================================================== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .surgery-card,
    .summary-card,
    .search-box,
    .custom-calendar {
        border-width: 0.5px;
    }
}

/* ======================================================
   DARK STATUS BAR FIX (Samsung, Huawei AMOLED)
   ====================================================== */
@media (prefers-color-scheme: dark) {
    meta[name="theme-color"] {
        content: "#119C9C";
    }
}

/* ======================================================
   UTILIDADES
   ====================================================== */

.text-institutional {
    color: var(--color-primary) !important;
}

.bg-institutional {
    background-color: var(--color-primary) !important;
}

.border-institutional {
    border-color: var(--color-primary) !important;
}

/* --- BOTÓN STAFF QUIRÚRGICO --- */
.btn-staff-icon {
    color: var(--color-primary);
    border: 1.5px solid var(--color-primary);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 14px;
    transition: all 0.2s ease;
    cursor: pointer;
    background: transparent;
}

.btn-staff-icon:hover,
.btn-staff-icon:focus {
    background: var(--color-primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(var(--color-primary-rgb), 0.3);
}

/* --- POPOVER DE STAFF QUIRÚRGICO --- */
.staff-popover {
    max-width: 360px;
    border: 1px solid var(--color-primary);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.staff-popover .popover-header {
    background: var(--color-primary);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    border-bottom: none;
    border-radius: 9px 9px 0 0;
    padding: 10px 14px;
}

.staff-popover .popover-body {
    padding: 6px 10px;
}

.staff-popover .popover-arrow::before {
    border-left-color: var(--color-primary);
}

.staff-popover .popover-arrow::after {
    border-left-color: var(--color-primary);
}

/* Staff list dentro del popover */
.staff-list {
    min-width: 240px;
    max-height: 320px;
    overflow-y: auto;
}

.staff-card {
    padding: 8px 6px;
    border-bottom: 1px solid #eef2f5;
}

.staff-card:last-child {
    border-bottom: none;
}

.staff-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.staff-card__info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.staff-card__name {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.staff-card__role {
    font-size: 11px;
    color: var(--text-muted);
}

.staff-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

.staff-badge--confirmado {
    background: #d4edda;
    color: #155724;
}

.staff-badge--rechazado {
    background: #f8d7da;
    color: #721c24;
}

.staff-badge--pendiente {
    background: #fff3cd;
    color: #856404;
}

.staff-card__obs {
    font-size: 11px;
    color: #6c757d;
    margin-top: 4px;
    padding: 4px 8px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid var(--color-primary);
}

/* --- BUDGET TABS --- */
.budget-tabs-wrapper {
    border-bottom: 1px solid #dee2e6;
    padding: 0 1rem;
    background: #f8f9fa;
}

.budget-tabs {
    border-bottom: none;
    gap: 2px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.budget-tabs .nav-link {
    font-size: 12px;
    font-weight: 500;
    padding: 8px 14px;
    color: var(--text-muted);
    border: none;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.budget-tabs .nav-link:hover {
    color: var(--color-primary);
    background: rgba(var(--color-primary-rgb), 0.05);
}

.budget-tabs .nav-link.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    font-weight: 600;
    background: transparent;
}

.budget-tab-date {
    font-size: 10px;
    opacity: 0.7;
}

.budget-loading {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

@media (max-width: 575.98px) {
    .staff-popover {
        max-width: 280px;
    }
    .budget-tabs .nav-link {
        font-size: 11px;
        padding: 6px 10px;
    }
}
