/* =====================================================
   RESPONSIVE UNIVERSAL - MENTALFAM
   Optimización completa para todos los dispositivos
   Sin alterar funcionalidad existente
   ===================================================== */

/* ===== VARIABLES RESPONSIVE ===== */
:root {
    --mobile-padding: 0.75rem;
    --tablet-padding: 1.5rem;
    --desktop-padding: 2rem;
    --touch-target-min: 44px;
    --font-size-mobile: 14px;
    --font-size-tablet: 15px;
    --font-size-desktop: 16px;
}

/* ===== OPTIMIZACIONES GENERALES PARA TODOS LOS DISPOSITIVOS ===== */

/* Mejorar scroll en todos los dispositivos */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Mejorar rendimiento de animaciones */
.modal,
.sidebar,
.stat-card,
.nav-menu a,
.btn-primary,
.btn-secondary {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* ===== PANTALLAS 4K Y ULTRA WIDE (2560px+) ===== */
@media (min-width: 2560px) {
    body {
        font-size: 18px;
    }
    
    .sidebar {
        width: 350px;
    }
    
    .main-content {
        margin-left: 350px;
        padding: 3.5rem;
        max-width: 2400px;
        margin-right: auto;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 3rem;
        max-width: 2000px;
    }
    
    .stat-card {
        padding: 3rem;
    }
    
    .stat-card h3 {
        font-size: 3rem;
    }
    
    .stat-card i {
        font-size: 4rem;
    }
    
    .modal-content {
        max-width: 1400px;
    }
    
    .table-container {
        font-size: 1.2rem;
    }
    
    table th,
    table td {
        padding: 1.5rem;
    }
    
    .btn-primary,
    .btn-secondary {
        padding: 1.25rem 2.5rem;
        font-size: 1.2rem;
    }
    
    .top-bar h1 {
        font-size: 2.5rem;
    }
    
    .welcome-section h2 {
        font-size: 3rem;
    }
}

/* ===== MONITORES GRANDES (1920px - 2560px) ===== */
@media (min-width: 1920px) and (max-width: 2559px) {
    body {
        font-size: 17px;
    }
    
    .sidebar {
        width: 320px;
    }
    
    .main-content {
        margin-left: 320px;
        padding: 3rem;
        max-width: 1800px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 2.5rem;
    }
    
    .stat-card {
        padding: 2.5rem;
    }
    
    .stat-card h3 {
        font-size: 2.5rem;
    }
    
    .modal-content {
        max-width: 1200px;
    }
    
    .table-container {
        font-size: 1.1rem;
    }
    
    .btn-primary,
    .btn-secondary {
        padding: 1rem 2rem;
        font-size: 1.1rem;
    }
}

/* ===== LAPTOPS GRANDES Y MONITORES ESTÁNDAR (1440px - 1920px) ===== */
@media (min-width: 1440px) and (max-width: 1919px) {
    .sidebar {
        width: 300px;
    }
    
    .main-content {
        margin-left: 300px;
        padding: 2.5rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 2rem;
    }
    
    .stat-card {
        padding: 2rem;
    }
    
    .modal-content {
        max-width: 1000px;
    }
}

/* ===== LAPTOPS MEDIANAS (1200px - 1440px) ===== */
@media (min-width: 1200px) and (max-width: 1439px) {
    .sidebar {
        width: 280px;
    }
    
    .main-content {
        margin-left: 280px;
        padding: 2rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 1.5rem;
    }
    
    .modal-content {
        max-width: 900px;
    }
    
    /* Optimizar tabla de clientes */
    #clientes table {
        font-size: 0.9rem;
    }
    
    #clientes table th,
    #clientes table td {
        padding: 0.8rem 0.5rem;
    }
}

/* ===== LAPTOPS PEQUEÑAS Y TABLETS GRANDES HORIZONTAL (1024px - 1200px) ===== */
@media (min-width: 1024px) and (max-width: 1199px) {
    .sidebar {
        width: 260px;
    }
    
    .main-content {
        margin-left: 260px;
        padding: 1.75rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .stat-card {
        padding: 1.75rem;
    }
    
    .modal-content {
        max-width: 800px;
        padding: 1.75rem;
    }
    
    .table-container {
        font-size: 0.95rem;
    }
    
    /* Optimizar tabla de clientes */
    #clientes table {
        font-size: 0.85rem;
    }
    
    #clientes table th,
    #clientes table td {
        padding: 0.7rem 0.4rem;
    }
    
    .btn-primary,
    .btn-secondary {
        padding: 0.875rem 1.5rem;
        font-size: 0.95rem;
    }
}

/* ===== iPAD PRO 12.9" Y TABLETS GRANDES (1024px horizontal) ===== */
@media (min-width: 1024px) and (max-width: 1366px) and (orientation: landscape) {
    .sidebar {
        width: 240px;
    }
    
    .main-content {
        margin-left: 240px;
        padding: 1.5rem;
    }
    
    .nav-menu a {
        padding: 0.875rem 1.25rem;
        font-size: 0.9rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }
    
    /* Mejorar interacción táctil */
    .btn-primary,
    .btn-secondary,
    button,
    .nav-menu a {
        min-height: var(--touch-target-min);
    }
}

/* ===== TABLETS MEDIANAS Y iPAD (768px - 1024px) ===== */
@media (min-width: 768px) and (max-width: 1023px) {
    /* Reorganizar layout para tablets */
    .dashboard {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        order: 1;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    .main-content {
        margin-left: 0;
        padding: var(--tablet-padding);
        order: 2;
    }
    
    /* Menú horizontal optimizado para tablets */
    .nav-menu {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 0.5rem;
        padding: 1rem;
    }
    
    .nav-menu li:last-child {
        grid-column: span 4;
    }
    
    .nav-menu a {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
        padding: 1rem 0.75rem;
        font-size: 0.9rem;
        text-align: center;
        min-height: var(--touch-target-min);
    }
    
    .nav-menu a i {
        font-size: 1.3rem;
    }
    
    /* Optimizar estadísticas */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }
    
    .stat-card {
        padding: 1.5rem;
    }
    
    .stat-card h3 {
        font-size: 1.75rem;
    }
    
    /* Optimizar modales */
    .modal-content {
        max-width: 700px;
        padding: 1.5rem;
        margin: 3% auto;
    }
    
    /* Optimizar tablas */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 12px;
    }
    
    table {
        font-size: 0.9rem;
    }
    
    table th,
    table td {
        padding: 0.75rem 0.5rem;
    }
    
    /* Optimizar tabla de clientes */
    #clientes table {
        min-width: 900px;
        font-size: 0.8rem;
    }
    
    #clientes table th,
    #clientes table td {
        padding: 0.6rem 0.3rem;
    }
    
    /* Botones táctiles */
    .btn-primary,
    .btn-secondary {
        min-height: var(--touch-target-min);
        padding: 0.875rem 1.5rem;
        font-size: 0.95rem;
    }
    
    /* Top bar responsive */
    .top-bar {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
        padding: 1.25rem;
    }
    
    .top-bar h1 {
        font-size: 1.6rem;
    }
    
    /* Historia clínica responsive */
    .historia-grid-modern {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .historia-actions-modern {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .historia-btn-modern {
        flex: 1;
        min-width: 150px;
    }
}

/* ===== iPAD VERTICAL Y TABLETS MEDIANAS (768px - 1024px vertical) ===== */
@media (min-width: 768px) and (max-width: 1023px) and (orientation: portrait) {
    .nav-menu {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .nav-menu li:last-child {
        grid-column: span 3;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .modal-content {
        width: 90%;
        max-width: 600px;
    }
    
    /* Optimizar formularios */
    .form-row {
        flex-direction: column;
        gap: 1rem;
    }
    
    .historia-section-modern {
        padding: 1.5rem;
    }
}

/* ===== TABLETS PEQUEÑAS Y MÓVILES GRANDES HORIZONTAL (600px - 768px) ===== */
@media (min-width: 600px) and (max-width: 767px) {
    body {
        font-size: var(--font-size-tablet);
    }
    
    .dashboard {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }
    
    .main-content {
        margin-left: 0;
        padding: 1.25rem;
    }
    
    /* Menú optimizado */
    .nav-menu {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
        padding: 0.75rem;
    }
    
    .nav-menu li:last-child {
        grid-column: span 3;
    }
    
    .nav-menu a {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.4rem;
        padding: 0.875rem 0.5rem;
        font-size: 0.85rem;
        text-align: center;
        min-height: var(--touch-target-min);
    }
    
    .nav-menu a i {
        font-size: 1.2rem;
    }
    
    /* Estadísticas */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1.25rem;
    }
    
    .stat-card h3 {
        font-size: 1.5rem;
    }
    
    .stat-card i {
        font-size: 2rem;
    }
    
    /* Modales */
    .modal-content {
        width: 95%;
        max-width: 550px;
        padding: 1.25rem;
        margin: 2rem auto;
    }
    
    /* Tablas */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 700px;
        font-size: 0.85rem;
    }
    
    table th,
    table td {
        padding: 0.6rem 0.4rem;
    }
    
    #clientes table {
        min-width: 750px;
        font-size: 0.75rem;
    }
    
    #clientes table th,
    #clientes table td {
        padding: 0.5rem 0.25rem;
    }
    
    /* Botones */
    .btn-primary,
    .btn-secondary {
        width: 100%;
        margin-bottom: 0.5rem;
        padding: 0.875rem;
        font-size: 0.9rem;
        min-height: var(--touch-target-min);
    }
    
    /* Top bar */
    .top-bar {
        flex-direction: column;
        gap: 0.875rem;
        text-align: center;
        padding: 1rem;
    }
    
    .top-bar h1 {
        font-size: 1.5rem;
    }
    
    /* Welcome section */
    .welcome-section {
        padding: 1.5rem 1rem;
    }
    
    .welcome-section h2 {
        font-size: 1.75rem;
    }
    
    /* Historia clínica */
    .historia-header-professional {
        padding: 1.25rem;
    }
    
    .historia-section-modern {
        padding: 1.25rem;
    }
    
    .historia-grid-modern {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .historia-actions-modern {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .historia-btn-modern {
        width: 100%;
    }
    
    /* Contabilidad */
    .resumen-contabilidad {
        grid-template-columns: 1fr;
        gap: 0.875rem;
    }
}

/* ===== MÓVILES GRANDES (480px - 600px) ===== */
@media (min-width: 480px) and (max-width: 599px) {
    body {
        font-size: var(--font-size-mobile);
    }
    
    /* Login */
    .login-container {
        padding: 1rem;
    }
    
    .login-box {
        padding: 1.5rem;
        max-width: 400px;
    }
    
    .logo {
        width: 160px;
    }
    
    /* Dashboard */
    .dashboard {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }
    
    .main-content {
        margin-left: 0;
        padding: var(--mobile-padding);
    }
    
    /* Menú */
    .nav-menu {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.4rem;
        padding: 0.75rem;
    }
    
    .nav-menu li:last-child {
        grid-column: span 2;
    }
    
    .nav-menu a {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.3rem;
        padding: 0.75rem 0.5rem;
        font-size: 0.8rem;
        text-align: center;
        min-height: var(--touch-target-min);
    }
    
    .nav-menu a i {
        font-size: 1.1rem;
    }
    
    /* Estadísticas */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.875rem;
    }
    
    .stat-card {
        padding: 1.25rem;
    }
    
    .stat-card h3 {
        font-size: 1.5rem;
    }
    
    .stat-card i {
        font-size: 2rem;
    }
    
    .stat-card p {
        font-size: 0.9rem;
    }
    
    /* Modales */
    .modal-content {
        width: 98%;
        max-width: 450px;
        padding: 1rem;
        margin: 1.5rem auto;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .modal-content h2 {
        font-size: 1.3rem;
    }
    
    /* Formularios */
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-group label {
        font-size: 0.9rem;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Previene zoom en iOS */
        padding: 0.75rem;
    }
    
    /* Tablas */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
    }
    
    table {
        min-width: 600px;
        font-size: 0.8rem;
    }
    
    table th,
    table td {
        padding: 0.5rem 0.3rem;
    }
    
    #clientes table {
        min-width: 650px;
        font-size: 0.7rem;
    }
    
    #clientes table th,
    #clientes table td {
        padding: 0.4rem 0.2rem;
    }
    
    /* Botones */
    .btn-primary,
    .btn-secondary {
        width: 100%;
        margin-bottom: 0.5rem;
        padding: 0.875rem;
        font-size: 0.9rem;
        min-height: var(--touch-target-min);
    }
    
    table button {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
        margin: 0.25rem;
        min-height: 36px;
    }
    
    /* Top bar */
    .top-bar {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
        padding: 1rem;
    }
    
    .top-bar h1 {
        font-size: 1.4rem;
    }
    
    .user-info {
        font-size: 0.85rem;
    }
    
    /* Welcome section */
    .welcome-section {
        padding: 1.25rem 0.875rem;
    }
    
    .welcome-section h2 {
        font-size: 1.6rem;
        line-height: 1.3;
    }
    
    .welcome-section p {
        font-size: 0.95rem;
    }
    
    /* Section header */
    .section-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .section-header h2 {
        font-size: 1.3rem;
    }
    
    /* Search bar */
    .search-bar input {
        width: 100%;
        font-size: 16px; /* Previene zoom en iOS */
        padding: 0.75rem;
    }
    
    /* Historia clínica */
    .historia-header-professional {
        padding: 1.25rem;
        margin: -1rem -1rem 1.5rem -1rem;
    }
    
    .historia-header-professional h2 {
        font-size: 1.4rem;
    }
    
    .historia-section-modern {
        padding: 1.25rem;
        margin-bottom: 1.5rem;
    }
    
    .historia-section-modern h3 {
        font-size: 1.1rem;
    }
    
    .historia-textarea-modern {
        min-height: 100px;
        font-size: 16px; /* Previene zoom en iOS */
    }
    
    .historia-grid-modern {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .historia-actions-modern {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .historia-btn-modern {
        width: 100%;
        padding: 1rem;
    }
    
    /* Contabilidad */
    .resumen-contabilidad {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .resumen-card {
        padding: 1rem;
    }
}

/* ===== MÓVILES MEDIANOS - iPhone 12/13/14, Galaxy S21/S22 (375px - 480px) ===== */
@media (min-width: 375px) and (max-width: 479px) {
    body {
        font-size: var(--font-size-mobile);
    }
    
    /* Login */
    .login-container {
        padding: 0.875rem;
    }
    
    .login-box {
        width: 100%;
        max-width: 360px;
        padding: 1.25rem;
    }
    
    .logo {
        width: 140px;
    }
    
    .logo-section h2 {
        font-size: 1.2rem;
    }
    
    /* Sidebar */
    .sidebar-header {
        padding: 1rem;
    }
    
    .sidebar-header h2 {
        font-size: 1.2rem;
    }
    
    /* Menú */
    .nav-menu {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.3rem;
        padding: 0.75rem;
    }
    
    .nav-menu li:last-child {
        grid-column: span 2;
    }
    
    .nav-menu a {
        padding: 0.75rem 0.5rem;
        font-size: 0.75rem;
        min-height: var(--touch-target-min);
    }
    
    .nav-menu a i {
        font-size: 1rem;
    }
    
    /* Main content */
    .main-content {
        padding: 0.75rem;
    }
    
    .section {
        padding: 1rem;
        border-radius: 10px;
    }
    
    /* Estadísticas */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .stat-card {
        padding: 1.25rem;
    }
    
    .stat-card h3 {
        font-size: 1.4rem;
    }
    
    .stat-card i {
        font-size: 1.875rem;
    }
    
    .stat-card p {
        font-size: 0.85rem;
    }
    
    /* Modales */
    .modal-content {
        width: 98%;
        max-width: 360px;
        padding: 1rem;
        margin: 1rem auto;
        max-height: 92vh;
    }
    
    .modal-content h2 {
        font-size: 1.2rem;
        margin-bottom: 1rem;
    }
    
    .close {
        font-size: 1.75rem;
        right: 1rem;
        top: 1rem;
    }
    
    /* Formularios */
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-group label {
        font-size: 0.85rem;
        margin-bottom: 0.4rem;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Previene zoom en iOS */
        padding: 0.75rem;
        border-radius: 8px;
    }
    
    /* Tablas */
    table {
        min-width: 550px;
        font-size: 0.75rem;
    }
    
    table th,
    table td {
        padding: 0.5rem 0.25rem;
    }
    
    #clientes table {
        min-width: 600px;
        font-size: 0.65rem;
    }
    
    #clientes table th,
    #clientes table td {
        padding: 0.4rem 0.15rem;
    }
    
    /* Botones */
    .btn-primary,
    .btn-secondary {
        padding: 0.875rem;
        font-size: 0.875rem;
        border-radius: 8px;
        min-height: var(--touch-target-min);
    }
    
    table button {
        padding: 0.5rem 0.625rem;
        font-size: 0.7rem;
        margin: 0.2rem;
        min-height: 36px;
    }
    
    /* Top bar */
    .top-bar {
        padding: 0.875rem;
    }
    
    .top-bar h1 {
        font-size: 1.3rem;
    }
    
    .user-info {
        font-size: 0.8rem;
    }
    
    /* Welcome section */
    .welcome-section {
        padding: 1rem 0.75rem;
    }
    
    .welcome-section h2 {
        font-size: 1.5rem;
        line-height: 1.3;
    }
    
    .welcome-section p {
        font-size: 0.9rem;
    }
    
    /* Section header */
    .section-header h2 {
        font-size: 1.2rem;
    }
    
    /* Search bar */
    .search-bar input {
        font-size: 16px; /* Previene zoom en iOS */
        padding: 0.75rem;
    }
    
    /* Historia clínica */
    .historia-header-professional {
        padding: 1rem;
        margin: -1rem -1rem 1rem -1rem;
    }
    
    .historia-header-professional h2 {
        font-size: 1.3rem;
        line-height: 1.3;
    }
    
    .historia-header-professional p {
        font-size: 0.85rem;
    }
    
    .historia-section-modern {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .historia-section-modern h3 {
        font-size: 1rem;
        margin-bottom: 1rem;
    }
    
    .historia-textarea-modern {
        min-height: 90px;
        font-size: 16px; /* Previene zoom en iOS */
        padding: 0.75rem;
    }
    
    .historia-actions-modern {
        padding: 1rem;
        gap: 0.625rem;
    }
    
    .historia-btn-modern {
        padding: 0.875rem;
        font-size: 0.875rem;
    }
    
    /* Contabilidad */
    .resumen-card {
        padding: 0.875rem;
    }
    
    .resumen-card h3 {
        font-size: 0.9rem;
    }
    
    .resumen-card p {
        font-size: 1.2rem;
    }
}

/* ===== MÓVILES PEQUEÑOS - iPhone SE, Galaxy S10e (320px - 375px) ===== */
@media (min-width: 320px) and (max-width: 374px) {
    body {
        font-size: 13px;
    }
    
    /* Login */
    .login-container {
        padding: 0.5rem;
    }
    
    .login-box {
        width: 100%;
        max-width: 320px;
        padding: 1rem;
        margin: 0.5rem auto;
    }
    
    .logo {
        width: 120px;
    }
    
    .logo-section h2 {
        font-size: 1rem;
    }
    
    /* Sidebar */
    .sidebar-header {
        padding: 0.875rem;
    }
    
    .sidebar-header h2 {
        font-size: 1.1rem;
    }
    
    /* Menú */
    .nav-menu {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.25rem;
        padding: 0.5rem;
    }
    
    .nav-menu li:last-child {
        grid-column: span 1;
    }
    
    .nav-menu a {
        padding: 0.75rem;
        font-size: 0.7rem;
        min-height: var(--touch-target-min);
    }
    
    .nav-menu a i {
        font-size: 0.95rem;
    }
    
    /* Main content */
    .main-content {
        padding: 0.5rem;
    }
    
    .section {
        padding: 0.875rem;
        border-radius: 8px;
    }
    
    /* Estadísticas */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-card h3 {
        font-size: 1.3rem;
    }
    
    .stat-card i {
        font-size: 1.75rem;
    }
    
    .stat-card p {
        font-size: 0.8rem;
    }
    
    /* Modales */
    .modal-content {
        width: 98%;
        max-width: 310px;
        padding: 0.875rem;
        margin: 0.75rem auto;
        max-height: 95vh;
        border-radius: 10px;
    }
    
    .modal-content h2 {
        font-size: 1.1rem;
        margin-bottom: 0.875rem;
    }
    
    .close {
        font-size: 1.5rem;
        right: 0.875rem;
        top: 0.875rem;
    }
    
    /* Formularios */
    .form-group {
        margin-bottom: 0.875rem;
    }
    
    .form-group label {
        font-size: 0.8rem;
        margin-bottom: 0.3rem;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Previene zoom en iOS */
        padding: 0.7rem;
        border-radius: 6px;
    }
    
    /* Tablas */
    table {
        min-width: 500px;
        font-size: 0.7rem;
    }
    
    table th,
    table td {
        padding: 0.4rem 0.2rem;
    }
    
    #clientes table {
        min-width: 550px;
        font-size: 0.6rem;
    }
    
    #clientes table th,
    #clientes table td {
        padding: 0.3rem 0.1rem;
    }
    
    /* Botones */
    .btn-primary,
    .btn-secondary {
        padding: 0.8rem;
        font-size: 0.8rem;
        border-radius: 6px;
        min-height: var(--touch-target-min);
    }
    
    table button {
        padding: 0.4rem 0.5rem;
        font-size: 0.65rem;
        margin: 0.15rem;
        min-height: 36px;
    }
    
    /* Top bar */
    .top-bar {
        padding: 0.75rem;
    }
    
    .top-bar h1 {
        font-size: 1.2rem;
    }
    
    .user-info {
        font-size: 0.75rem;
    }
    
    /* Welcome section */
    .welcome-section {
        padding: 0.875rem 0.625rem;
    }
    
    .welcome-section h2 {
        font-size: 1.4rem;
        line-height: 1.3;
    }
    
    .welcome-section p {
        font-size: 0.85rem;
    }
    
    /* Section header */
    .section-header h2 {
        font-size: 1.1rem;
    }
    
    /* Search bar */
    .search-bar input {
        font-size: 16px; /* Previene zoom en iOS */
        padding: 0.7rem;
    }
    
    /* Historia clínica */
    .historia-header-professional {
        padding: 0.875rem;
        margin: -0.875rem -0.875rem 0.875rem -0.875rem;
    }
    
    .historia-header-professional h2 {
        font-size: 1.2rem;
        line-height: 1.3;
    }
    
    .historia-header-professional p {
        font-size: 0.8rem;
    }
    
    .historia-section-modern {
        padding: 0.875rem;
        margin-bottom: 0.875rem;
    }
    
    .historia-section-modern h3 {
        font-size: 0.95rem;
        margin-bottom: 0.875rem;
    }
    
    .historia-textarea-modern {
        min-height: 80px;
        font-size: 16px; /* Previene zoom en iOS */
        padding: 0.7rem;
    }
    
    .historia-actions-modern {
        padding: 0.875rem;
        gap: 0.5rem;
    }
    
    .historia-btn-modern {
        padding: 0.8rem;
        font-size: 0.8rem;
    }
    
    /* Contabilidad */
    .resumen-card {
        padding: 0.75rem;
    }
    
    .resumen-card h3 {
        font-size: 0.85rem;
    }
    
    .resumen-card p {
        font-size: 1.1rem;
    }
}

/* ===== ORIENTACIÓN HORIZONTAL EN MÓVILES ===== */
@media (max-width: 768px) and (orientation: landscape) {
    .sidebar {
        height: auto;
    }
    
    .nav-menu {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        padding: 0.5rem;
    }
    
    .nav-menu li {
        flex: 1;
        min-width: 90px;
        max-width: 140px;
    }
    
    .nav-menu a {
        padding: 0.5rem 0.3rem;
        font-size: 0.75rem;
    }
    
    .modal-content {
        max-height: 85vh;
        overflow-y: auto;
    }
    
    .login-box {
        max-width: 500px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.5rem;
    }
    
    .stat-card {
        padding: 0.875rem;
    }
    
    .stat-card h3 {
        font-size: 1.3rem;
    }
    
    .stat-card p {
        font-size: 0.75rem;
    }
}

/* ===== MEJORAS PARA DISPOSITIVOS TÁCTILES ===== */
@media (hover: none) and (pointer: coarse) {
    /* Aumentar áreas táctiles */
    .btn-primary,
    .btn-secondary,
    button,
    .nav-menu a,
    .stat-card,
    .resumen-card,
    table button {
        min-height: var(--touch-target-min);
        touch-action: manipulation;
    }
    
    /* Mejorar navegación */
    .nav-menu a {
        display: flex;
        align-items: center;
        justify-content: center;
        flex-direction: column;
        gap: 0.3rem;
        padding: 0.75rem 0.5rem;
    }
    
    /* Scroll suave */
    .table-container,
    .modal-content {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Prevenir zoom en inputs */
    input,
    select,
    textarea {
        font-size: 16px !important;
        -webkit-appearance: none;
        border-radius: 8px;
    }
    
    /* Mejorar botones táctiles */
    .historia-btn-modern,
    .btn-primary,
    .btn-secondary {
        min-height: 48px;
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
        font-weight: 600;
    }
    
    /* Espaciado mejorado para táctil */
    .historia-actions-modern {
        gap: 1rem;
        padding: 1.5rem;
    }
    
    .form-group {
        margin-bottom: 1.5rem;
    }
    
    .nav-menu {
        gap: 0.5rem;
    }
    
    /* Feedback visual mejorado */
    button:active,
    .btn-primary:active,
    .btn-secondary:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
}

/* ===== OPTIMIZACIONES PARA iOS ===== */
@supports (-webkit-touch-callout: none) {
    /* Prevenir zoom en inputs */
    input,
    select,
    textarea {
        font-size: 16px !important;
    }
    
    /* Mejorar scroll */
    .table-container,
    .modal-content,
    .main-content {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Mejorar rendimiento */
    .modal,
    .sidebar,
    .stat-card {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
}

/* ===== OPTIMIZACIONES PARA ANDROID ===== */
@media screen and (-webkit-min-device-pixel-ratio: 0) and (min-resolution: .001dpcm) {
    /* Mejorar scroll */
    .table-container {
        overflow-x: auto;
        overflow-y: hidden;
    }
    
    /* Mejorar rendimiento */
    * {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
}

/* ===== MODO OSCURO (PREFERENCIA DEL SISTEMA) ===== */
@media (prefers-color-scheme: dark) {
    /* Mantener colores originales pero ajustar contraste */
    .table-container,
    .modal-content,
    .section {
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    }
}

/* ===== REDUCIR MOVIMIENTO (ACCESIBILIDAD) ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== IMPRESIÓN ===== */
@media print {
    /* Ocultar elementos no necesarios */
    .sidebar,
    .top-bar,
    .section-header button,
    table button,
    .modal,
    .custom-alert,
    .nav-menu,
    .btn-primary,
    .btn-secondary {
        display: none !important;
    }
    
    /* Ajustar layout */
    .main-content {
        margin-left: 0;
        padding: 1rem;
    }
    
    body {
        background: white;
        font-size: 12pt;
        line-height: 1.4;
    }
    
    /* Optimizar tablas */
    .table-container {
        overflow: visible;
    }
    
    table {
        font-size: 10pt;
        page-break-inside: avoid;
    }
    
    /* Optimizar secciones */
    .section,
    .historia-section-modern {
        box-shadow: none;
        border: 1px solid #ccc;
        break-inside: avoid;
        margin-bottom: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}

/* ===== MEJORAS DE RENDIMIENTO ===== */
@media (prefers-reduced-data: reduce) {
    /* Reducir efectos visuales para ahorrar datos */
    *::before,
    *::after {
        background-image: none !important;
    }
    
    .stat-card,
    .modal-content,
    .section {
        box-shadow: none;
    }
}

/* ===== SOLUCIÓN PARA BOTONES EN TABLAS MÓVILES ===== */

/* Hacer que los botones de acción siempre sean visibles en móviles */
@media (max-width: 768px) {
    /* Optimizar tabla de clientes para móviles */
    #clientes .table-container {
        position: relative;
    }
    
    /* Hacer la columna de acciones sticky (fija) en móviles */
    #clientes table th:last-child,
    #clientes table td:last-child {
        position: sticky;
        right: 0;
        background: white;
        box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1);
        z-index: 10;
        min-width: 140px !important;
        width: 140px !important;
    }
    
    #clientes table th:last-child {
        background: linear-gradient(135deg, rgba(123, 67, 151, 0.1) 0%, rgba(30, 154, 138, 0.1) 100%);
        font-weight: 700;
    }
    
    /* Mejorar botones en tablas para móviles */
    table button {
        display: inline-block !important;
        padding: 0.6rem 0.8rem !important;
        font-size: 0.75rem !important;
        margin: 0.2rem !important;
        min-height: 40px !important;
        min-width: 60px !important;
        white-space: nowrap;
        border-radius: 6px;
        font-weight: 600;
    }
    
    /* Hacer que todos los botones de tabla sean visibles */
    #clientes table td:last-child {
        display: flex !important;
        flex-direction: column;
        gap: 0.3rem;
        padding: 0.5rem !important;
        align-items: stretch;
    }
    
    #clientes table td:last-child button {
        width: 100% !important;
        margin: 0 !important;
    }
    
    /* Aplicar lo mismo a todas las tablas */
    .table-container table th:last-child,
    .table-container table td:last-child {
        position: sticky;
        right: 0;
        background: white;
        box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1);
        z-index: 10;
    }
    
    .table-container table th:last-child {
        background: linear-gradient(135deg, rgba(123, 67, 151, 0.1) 0%, rgba(30, 154, 138, 0.1) 100%);
    }
    
    /* Mejorar visualización de celdas en móviles */
    table tbody tr:hover td:last-child {
        background: white;
    }
    
    /* Indicador visual de scroll */
    .table-container::after {
        content: '← Desliza para ver más →';
        position: absolute;
        bottom: 10px;
        left: 50%;
        transform: translateX(-50%);
        background: linear-gradient(135deg, #7B4397 0%, #1E9A8A 100%);
        color: white;
        padding: 0.5rem 1rem;
        border-radius: 20px;
        font-size: 0.75rem;
        font-weight: 600;
        pointer-events: none;
        opacity: 0.8;
        animation: scrollHint 2s ease-in-out infinite;
        z-index: 5;
    }
    
    @keyframes scrollHint {
        0%, 100% { transform: translateX(-50%) scale(1); }
        50% { transform: translateX(-50%) scale(1.05); }
    }
    
    /* Ocultar indicador cuando se hace scroll */
    .table-container.scrolled::after {
        display: none;
    }
}

/* Optimizaciones específicas para iPhone */
@media (max-width: 480px) {
    /* Botones más grandes en móviles pequeños */
    table button {
        padding: 0.7rem 0.9rem !important;
        font-size: 0.8rem !important;
        min-height: 44px !important;
        min-width: 70px !important;
    }
    
    /* Columna de acciones más ancha en móviles pequeños */
    #clientes table th:last-child,
    #clientes table td:last-child {
        min-width: 150px !important;
        width: 150px !important;
    }
    
    .table-container table th:last-child,
    .table-container table td:last-child {
        min-width: 150px !important;
    }
    
    /* Mejorar espaciado entre botones */
    #clientes table td:last-child {
        gap: 0.4rem !important;
        padding: 0.6rem !important;
    }
}

/* Optimizaciones para tablets - MEJORADO PARA iPADS */
@media (min-width: 768px) and (max-width: 1023px) {
    /* Columna de acciones sticky también en tablets */
    .table-container table th:last-child,
    .table-container table td:last-child {
        position: sticky !important;
        right: 0 !important;
        background: white !important;
        box-shadow: -3px 0 8px rgba(0, 0, 0, 0.15) !important;
        z-index: 100 !important;
        min-width: 180px !important;
        width: 180px !important;
    }
    
    .table-container table th:last-child {
        background: linear-gradient(135deg, rgba(123, 67, 151, 0.15) 0%, rgba(30, 154, 138, 0.15) 100%) !important;
        font-weight: 700 !important;
    }
    
    /* Botones en columna para iPads */
    .table-container table td:last-child {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.5rem !important;
        padding: 0.75rem !important;
        align-items: stretch !important;
    }
    
    .table-container table td:last-child button {
        width: 100% !important;
        margin: 0 !important;
        padding: 0.75rem 1rem !important;
        font-size: 0.9rem !important;
        min-height: 48px !important;
        font-weight: 600 !important;
        border-radius: 8px !important;
    }
    
    /* Asegurar que los botones sean visibles */
    table button {
        display: inline-block !important;
        padding: 0.75rem 1rem !important;
        font-size: 0.9rem !important;
        min-height: 48px !important;
    }
}

/* ===== MEJORAS ADICIONALES PARA EXPERIENCIA MÓVIL ===== */

/* Mejorar contraste en móviles */
@media (max-width: 768px) {
    /* Mejorar legibilidad de textos */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-rendering: optimizeLegibility;
    }
    
    /* Mejorar contraste de botones */
    .btn-primary,
    .btn-secondary,
    table button {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    }
    
    /* Mejorar feedback táctil */
    .btn-primary:active,
    .btn-secondary:active,
    table button:active {
        transform: scale(0.95) !important;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2) !important;
    }
    
    /* Mejorar visibilidad de enlaces */
    a {
        text-decoration: underline;
        text-decoration-color: rgba(123, 67, 151, 0.3);
        text-underline-offset: 2px;
    }
    
    a:hover {
        text-decoration-color: rgba(123, 67, 151, 1);
    }
    
    /* Mejorar separación visual en listas */
    table tbody tr {
        border-bottom: 2px solid rgba(123, 67, 151, 0.1);
    }
    
    /* Mejorar contraste de inputs */
    input,
    select,
    textarea {
        border: 2px solid rgba(123, 67, 151, 0.2) !important;
    }
    
    input:focus,
    select:focus,
    textarea:focus {
        border-color: var(--primary-teal) !important;
        box-shadow: 0 0 0 3px rgba(30, 154, 138, 0.15) !important;
    }
}

/* ===== OPTIMIZACIONES PARA RENDIMIENTO EN MÓVILES ===== */

/* Reducir animaciones en móviles para mejor rendimiento */
@media (max-width: 768px) {
    * {
        animation-duration: 0.3s !important;
    }
    
    .stat-card,
    .modal-content,
    .nav-menu a {
        transition-duration: 0.2s !important;
    }
}

/* ===== MEJORAS PARA SCROLL EN TABLAS ===== */

/* Indicador de scroll mejorado */
@media (max-width: 768px) {
    .table-container {
        position: relative;
        padding-bottom: 40px;
    }
    
    /* Sombra para indicar que hay más contenido */
    .table-container::before {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 40px;
        width: 30px;
        background: linear-gradient(to left, rgba(0, 0, 0, 0.1), transparent);
        pointer-events: none;
        z-index: 5;
    }
    
    /* Scrollbar personalizada para móviles */
    .table-container::-webkit-scrollbar {
        height: 8px;
    }
    
    .table-container::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 10px;
    }
    
    .table-container::-webkit-scrollbar-thumb {
        background: linear-gradient(135deg, #7B4397 0%, #1E9A8A 100%);
        border-radius: 10px;
    }
    
    .table-container::-webkit-scrollbar-thumb:hover {
        background: linear-gradient(135deg, #6a3a85 0%, #1a8778 100%);
    }
}

/* ===== MEJORAS PARA MODALES EN MÓVILES ===== */

@media (max-width: 768px) {
    /* Hacer modales más accesibles en móviles */
    .modal {
        padding: 0.5rem;
    }
    
    .modal-content {
        border-radius: 16px;
        max-height: 92vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Botón cerrar más grande en móviles */
    .close {
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(0, 0, 0, 0.05);
        border-radius: 50%;
        font-size: 1.5rem;
    }
    
    .close:active {
        background: rgba(0, 0, 0, 0.1);
        transform: scale(0.95);
    }
    
    /* Mejorar formularios en modales móviles */
    .modal .form-group {
        margin-bottom: 1.25rem;
    }
    
    .modal .form-group label {
        font-size: 0.9rem;
        font-weight: 600;
        margin-bottom: 0.5rem;
    }
    
    /* Inputs más grandes en móviles */
    .modal input,
    .modal select,
    .modal textarea {
        font-size: 16px !important;
        padding: 0.875rem !important;
        border-radius: 8px;
        min-height: 48px;
    }
    
    /* Botones de formulario más grandes */
    .modal button[type="submit"],
    .modal .btn-primary,
    .modal .btn-secondary {
        min-height: 50px !important;
        font-size: 1rem !important;
        padding: 1rem 1.5rem !important;
        font-weight: 600;
    }
}

/* ===== MEJORAS PARA NAVEGACIÓN EN MÓVILES ===== */

@media (max-width: 768px) {
    /* Hacer el menú más accesible */
    .nav-menu a {
        min-height: 60px !important;
        padding: 0.875rem 0.5rem !important;
        border-radius: 12px;
        margin: 0.25rem;
    }
    
    .nav-menu a i {
        font-size: 1.4rem !important;
        margin-bottom: 0.25rem;
    }
    
    /* Feedback visual mejorado */
    .nav-menu a:active {
        transform: scale(0.95);
        background: linear-gradient(135deg, rgba(123, 67, 151, 0.2) 0%, rgba(30, 154, 138, 0.2) 100%);
    }
    
    /* Sidebar header más compacto en móviles */
    .sidebar-header {
        padding: 1rem;
    }
    
    .sidebar-logo {
        max-width: 100px;
    }
    
    .sidebar-header h2 {
        font-size: 1.1rem;
        margin: 0.5rem 0 0.25rem 0;
    }
    
    .sidebar-header p {
        font-size: 0.8rem;
        margin: 0;
    }
}

/* ===== MEJORAS PARA ESTADÍSTICAS EN MÓVILES ===== */

@media (max-width: 768px) {
    .stat-card {
        min-height: 120px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding: 1.5rem 1rem;
    }
    
    .stat-card i {
        font-size: 2.5rem !important;
        margin-bottom: 0.75rem;
    }
    
    .stat-card h3 {
        font-size: 1.75rem !important;
        margin-bottom: 0.5rem;
    }
    
    .stat-card p {
        font-size: 0.9rem !important;
        text-align: center;
    }
}

/* ===== MEJORAS PARA BÚSQUEDA EN MÓVILES ===== */

@media (max-width: 768px) {
    .search-bar {
        margin-bottom: 1.25rem;
    }
    
    .search-bar input {
        width: 100% !important;
        max-width: 100% !important;
        font-size: 16px !important;
        padding: 0.875rem 1rem !important;
        border-radius: 10px;
        min-height: 48px;
        border: 2px solid rgba(123, 67, 151, 0.2);
    }
    
    .search-bar input:focus {
        border-color: var(--primary-teal);
        box-shadow: 0 0 0 3px rgba(30, 154, 138, 0.15);
    }
}

/* ===== MEJORAS PARA SECTION HEADER EN MÓVILES ===== */

@media (max-width: 768px) {
    .section-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
        margin-bottom: 1.5rem;
    }
    
    .section-header h2 {
        font-size: 1.4rem;
        text-align: center;
    }
    
    .section-header button,
    .section-header .btn-primary,
    .section-header .btn-secondary {
        width: 100%;
        min-height: 50px;
        font-size: 1rem;
        padding: 1rem;
    }
    
    .section-header > div {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .section-header > div button {
        width: 100%;
    }
}

/* ===== MEJORAS PARA WELCOME SECTION EN MÓVILES ===== */

@media (max-width: 768px) {
    .welcome-section {
        padding: 1.5rem 1rem;
        text-align: center;
    }
    
    .welcome-section h2 {
        font-size: 1.6rem !important;
        line-height: 1.3;
        margin-bottom: 0.75rem;
    }
    
    .welcome-section p {
        font-size: 1rem !important;
    }
}

/* ===== MEJORAS PARA TOP BAR EN MÓVILES ===== */

@media (max-width: 768px) {
    .top-bar {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
        padding: 1rem;
        border-radius: 12px;
    }
    
    .top-bar h1 {
        font-size: 1.4rem !important;
        line-height: 1.3;
    }
    
    .user-info {
        font-size: 0.9rem;
        justify-content: center;
    }
    
    .user-info i {
        font-size: 1.3rem;
    }
}

/* ===== MEJORAS PARA CONTABILIDAD EN MÓVILES ===== */

@media (max-width: 768px) {
    .resumen-contabilidad {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .resumen-card {
        padding: 1.25rem;
        text-align: center;
        min-height: 100px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    
    .resumen-card h3 {
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }
    
    .resumen-card p {
        font-size: 1.5rem !important;
        font-weight: 700;
    }
}

/* ===== MEJORAS PARA HISTORIA CLÍNICA EN MÓVILES ===== */

@media (max-width: 768px) {
    #historiaModal .modal-content {
        width: 98%;
        max-width: 100%;
        margin: 1rem auto;
        padding: 1rem;
        max-height: 95vh;
    }
    
    .historia-header-professional {
        padding: 1.25rem;
        margin: -1rem -1rem 1.25rem -1rem;
        border-radius: 16px 16px 0 0;
    }
    
    .historia-header-professional h2 {
        font-size: 1.3rem !important;
        line-height: 1.3;
    }
    
    .historia-header-professional p {
        font-size: 0.85rem;
    }
    
    .historia-section-modern {
        padding: 1.25rem;
        margin-bottom: 1.25rem;
        border-radius: 10px;
    }
    
    .historia-section-modern h3 {
        font-size: 1.1rem !important;
        margin-bottom: 1rem;
    }
    
    .historia-grid-modern {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
    
    .historia-textarea-modern {
        min-height: 120px;
        font-size: 16px !important;
        padding: 1rem;
        line-height: 1.6;
    }
    
    .historia-actions-modern {
        flex-direction: column;
        gap: 0.75rem;
        padding: 1.25rem;
    }
    
    .historia-btn-modern {
        width: 100% !important;
        min-height: 50px !important;
        font-size: 1rem !important;
        padding: 1rem 1.5rem !important;
    }
    
    /* Botón cerrar más accesible */
    .historia-header-professional button {
        width: 40px !important;
        height: 40px !important;
        font-size: 20px !important;
    }
}

/* ===== MEJORAS PARA SESIONES EN MÓVILES ===== */

@media (max-width: 768px) {
    .sesiones-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)) !important;
        gap: 0.75rem;
    }
    
    .sesion-card {
        padding: 1rem;
        min-height: 100px;
        border-radius: 10px;
    }
    
    .sesion-numero {
        font-size: 1.3rem;
        font-weight: 700;
    }
    
    .sesion-fecha {
        font-size: 0.8rem;
    }
    
    .sesion-estado {
        font-size: 0.75rem;
        font-weight: 600;
    }
}

/* ===== MEJORAS PARA ARCHIVOS EN MÓVILES ===== */

@media (max-width: 768px) {
    .archivos-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
    
    .archivo-paciente-card {
        padding: 1.25rem;
        border-radius: 12px;
    }
    
    .archivo-paciente-icon i {
        font-size: 2.5rem !important;
    }
    
    .archivo-paciente-nombre {
        font-size: 1rem;
        line-height: 1.4;
    }
    
    .archivo-paciente-acciones {
        flex-direction: column;
        gap: 0.5rem;
        margin-top: 1rem;
    }
    
    .btn-archivo-accion {
        width: 100% !important;
        min-height: 44px;
        padding: 0.75rem 1rem !important;
        font-size: 0.9rem !important;
    }
}

/* ===== MEJORAS PARA CALENDARIO EN MÓVILES ===== */

@media (max-width: 768px) {
    .calendar-main-container {
        flex-direction: column;
    }
    
    .calendar-left-sidebar {
        width: 100%;
        margin-bottom: 1rem;
    }
    
    .calendar-main-area {
        width: 100%;
    }
    
    .calendar-navigation {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-controls {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .view-controls {
        justify-content: center;
        width: 100%;
    }
    
    .view-btn {
        flex: 1;
        min-height: 44px;
        font-size: 0.9rem;
    }
}

/* ===== MEJORAS PARA NOTAS EN MÓVILES ===== */

@media (max-width: 768px) {
    .notas-toolbar {
        flex-direction: column;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .notas-filters {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        width: 100%;
    }
    
    .notas-filters select {
        width: 100%;
        font-size: 16px;
        padding: 0.875rem;
        min-height: 48px;
    }
    
    .notas-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
}

/* ===== SCRIPT PARA DETECTAR SCROLL EN TABLAS ===== */

/* Este estilo se aplicará dinámicamente con JavaScript */
.table-scrolled::after {
    opacity: 0 !important;
}

/* ===== FIN DEL ARCHIVO ===== */
