/* ========================================
   ESTILOS RESPONSIVE PARA MÓVILES
   Sistema de Gestión Financiera San Miguel S.A.
   ======================================== */

/* Botón de login móvil - Oculto en desktop */
.mobile-login-toggle {
    display: none;
}

/* Mostrar en móviles */
@media (max-width: 768px) {
    .mobile-login-toggle {
        display: block !important;
        width: 90%;
        max-width: 400px;
        padding: 1rem 1.5rem;
        background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
        color: white;
        border: none;
        border-radius: 12px;
        font-size: 1.1rem;
        font-weight: 600;
        margin: 1.5rem auto;
        cursor: pointer;
        transition: all 0.3s;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
        text-align: center;
    }
    
    .mobile-login-toggle:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    }
    
    .mobile-login-toggle i {
        margin-left: 8px;
        transition: transform 0.3s;
    }
}

/* ========================================
   1. HEADER MÓVIL
   ======================================== */

/* Ocultar menú de usuario de escritorio en móviles */
@media (max-width: 768px) {
    /* Ocultar el dropdown de usuario del header de escritorio */
    main .d-flex.align-items-center .dropdown,
    main .d-flex.align-items-center .btn.dropdown-toggle {
        display: none !important;
    }
    
    /* Ocultar la fecha en el header también */
    main .d-flex.align-items-center .text-muted {
        display: none !important;
    }
}

/* Header móvil - visible solo en pantallas pequeñas */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1050;
    padding: 0 15px;
    align-items: center;
    justify-content: space-between;
}

.mobile-header-logo {
    color: white;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-header-logo i {
    font-size: 20px;
}

/* Botón menú hamburguesa */
.mobile-menu-toggle {
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background-color 0.3s;
}

.mobile-menu-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.mobile-menu-toggle:active {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Menú de usuario móvil */
.mobile-user-menu {
    position: relative;
}

.mobile-user-button {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.4);
    color: white;
    padding: 8px 14px;
    border-radius: 25px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.mobile-user-button:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

.mobile-user-button i {
    font-size: 16px;
}

.mobile-user-dropdown {
    position: absolute;
    top: 50px;
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    min-width: 220px;
    display: none;
    z-index: 1060;
    overflow: hidden;
}

.mobile-user-dropdown.show {
    display: block;
}

.mobile-user-dropdown-header {
    padding: 16px 18px;
    border-bottom: 1px solid #e8e8e8;
    background-color: #f9f9f9;
}

.mobile-user-dropdown-header .user-name {
    font-weight: 700;
    color: #222;
    font-size: 15px;
    margin-bottom: 5px;
}

.mobile-user-dropdown-header .user-role {
    font-size: 12px;
    color: #666;
}

.mobile-user-dropdown-item {
    padding: 14px 18px;
    color: #333;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background-color 0.2s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.mobile-user-dropdown-item:hover {
    background-color: #f5f5f5;
}

.mobile-user-dropdown-item i {
    width: 22px;
    text-align: center;
    color: #20b2aa;
    font-size: 16px;
}

.mobile-user-dropdown-divider {
    height: 1px;
    background-color: #e8e8e8;
    margin: 8px 0;
}

/* ========================================
   2. SIDEBAR MÓVIL
   ======================================== */

/* Overlay para cerrar el menú */
.mobile-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
}

.mobile-sidebar-overlay.show {
    display: block;
}

/* Sidebar adaptado para móvil */
@media (max-width: 768px) {
    .sidebar-nav {
        position: fixed !important;
        left: -280px;
        top: 60px;
        width: 280px !important;
        height: calc(100vh - 60px) !important;
        transition: left 0.3s ease-in-out;
        z-index: 1045 !important;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }

    .sidebar-nav.show {
        left: 0;
    }

    /* Ocultar el logo del sidebar en móvil (ya está en el header) */
    .sidebar-nav > div:first-child {
        display: none;
    }
}

/* ========================================
   3. CONTENIDO PRINCIPAL MÓVIL
   ======================================== */

@media (max-width: 768px) {
    /* Ajustar el contenido principal */
    main {
        margin-left: 0 !important;
        margin-top: 60px !important;
        padding: 1rem !important;
    }

    /* Header de página */
    .d-flex.justify-content-between.align-items-center.mb-4 {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 15px;
    }

    .d-flex.justify-content-between.align-items-center.mb-4 > div {
        width: 100%;
    }

    /* Indicador de sección actual */
    .current-section-indicator {
        display: none !important;
    }

    /* Títulos */
    h1.h2 {
        font-size: 1.5rem !important;
    }

    h2 {
        font-size: 1.3rem !important;
    }

    h3 {
        font-size: 1.1rem !important;
    }
}

/* ========================================
   4. TARJETAS Y CARDS
   ======================================== */

@media (max-width: 768px) {
    /* Cards en columna completa */
    .card {
        margin-bottom: 1rem;
    }

    .card-body {
        padding: 1rem !important;
    }

    .card-header {
        padding: 0.75rem 1rem !important;
        font-size: 0.95rem !important;
    }

    /* Tarjetas de estadísticas */
    .row > [class*="col-"] {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    .card.text-center {
        padding: 1rem 0.5rem !important;
    }

    .card h3 {
        font-size: 1.8rem !important;
    }

    .card p {
        font-size: 0.85rem !important;
    }
}

/* ========================================
   5. TABLAS RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    /* Contenedor de tabla con scroll horizontal */
    .table-responsive {
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        margin-bottom: 1rem;
    }

    /* Tablas más compactas */
    .table {
        font-size: 0.85rem !important;
        margin-bottom: 0;
    }

    .table th,
    .table td {
        padding: 0.5rem !important;
        white-space: nowrap;
    }

    .table thead th {
        position: sticky;
        top: 0;
        background-color: #20b2aa;
        color: white;
        z-index: 10;
    }

    /* Botones de acción en tablas */
    .btn-group {
        display: flex !important;
        flex-direction: column !important;
        gap: 4px;
    }

    .btn-group .btn {
        width: 100%;
        margin: 0 !important;
    }

    /* Badges más pequeños */
    .badge {
        font-size: 0.7rem !important;
        padding: 0.25rem 0.5rem !important;
    }
}

/* ========================================
   6. FORMULARIOS Y MODALES
   ======================================== */

@media (max-width: 768px) {
    /* Modales a pantalla completa */
    .modal-dialog {
        margin: 0 !important;
        max-width: 100% !important;
        height: 100vh;
    }

    .modal-content {
        height: 100vh;
        border-radius: 0 !important;
        border: none;
    }

    .modal-header {
        padding: 1rem !important;
    }

    .modal-body {
        padding: 1rem !important;
        overflow-y: auto;
    }

    .modal-footer {
        padding: 1rem !important;
        flex-direction: column !important;
        gap: 10px;
    }

    .modal-footer .btn {
        width: 100% !important;
        margin: 0 !important;
    }

    /* Formularios */
    .form-label {
        font-size: 0.9rem !important;
        margin-bottom: 0.3rem !important;
    }

    .form-control,
    .form-select {
        font-size: 0.9rem !important;
        padding: 0.5rem !important;
    }

    .input-group {
        flex-wrap: nowrap !important;
    }

    .input-group-text {
        font-size: 0.85rem !important;
        padding: 0.5rem !important;
    }

    /* Checkboxes y permisos */
    .form-check {
        margin-bottom: 0.5rem !important;
    }

    .form-check-label {
        font-size: 0.85rem !important;
    }

    /* Contenedor de permisos */
    #permisosContainer .col-md-6,
    #editPermisosContainer .col-md-6 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
}

/* ========================================
   7. BOTONES
   ======================================== */

@media (max-width: 768px) {
    /* Botones más grandes y táctiles */
    .btn {
        padding: 0.6rem 1rem !important;
        font-size: 0.9rem !important;
    }

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

    .btn-lg {
        padding: 0.8rem 1.5rem !important;
        font-size: 1rem !important;
    }

    /* Botones de acción flotantes */
    .btn-group-vertical {
        width: 100%;
    }

    /* Botones en fila */
    .d-flex.gap-2 {
        flex-direction: column !important;
        gap: 10px !important;
    }

    .d-flex.gap-2 .btn {
        width: 100% !important;
    }
}

/* ========================================
   8. FILTROS Y BÚSQUEDA
   ======================================== */

@media (max-width: 768px) {
    /* Barra de filtros */
    .row.mb-4 {
        margin-bottom: 1rem !important;
    }

    .row.mb-4 > [class*="col-"] {
        margin-bottom: 0.75rem;
    }

    /* Input de búsqueda */
    .input-group {
        margin-bottom: 0.75rem;
    }

    /* Selects de filtro */
    .form-select {
        margin-bottom: 0.75rem;
    }

    /* Botones de filtro */
    .btn-outline-primary,
    .btn-outline-secondary {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* ========================================
   9. GRÁFICOS Y VISUALIZACIONES
   ======================================== */

@media (max-width: 768px) {
    /* Canvas de gráficos */
    canvas {
        max-height: 250px !important;
    }

    /* Contenedor de gráficos */
    .chart-container {
        position: relative;
        height: 250px !important;
        margin-bottom: 1rem;
    }
}

/* ========================================
   10. LISTAS Y GRUPOS
   ======================================== */

@media (max-width: 768px) {
    .list-group-item {
        padding: 0.75rem !important;
        font-size: 0.9rem !important;
    }

    .list-group-item .badge {
        font-size: 0.75rem !important;
    }
}

/* ========================================
   11. ALERTAS Y NOTIFICACIONES
   ======================================== */

@media (max-width: 768px) {
    .alert {
        padding: 0.75rem !important;
        font-size: 0.9rem !important;
        margin-bottom: 1rem !important;
    }

    .toast {
        max-width: calc(100% - 2rem) !important;
        margin: 1rem !important;
    }
}

/* ========================================
   12. UTILIDADES MÓVILES
   ======================================== */

@media (max-width: 768px) {
    /* Ocultar en móvil */
    .hide-mobile {
        display: none !important;
    }

    /* Mostrar solo en móvil */
    .show-mobile {
        display: block !important;
    }

    /* Texto más pequeño en móvil */
    .text-muted {
        font-size: 0.85rem !important;
    }

    /* Espaciado reducido */
    .mb-4 {
        margin-bottom: 1rem !important;
    }

    .mt-4 {
        margin-top: 1rem !important;
    }

    .p-4 {
        padding: 1rem !important;
    }

    /* Grid responsive */
    .row {
        margin-left: -0.5rem !important;
        margin-right: -0.5rem !important;
    }

    .row > [class*="col-"] {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
}

/* ========================================
   13. ANIMACIONES MÓVILES
   ======================================== */

@media (max-width: 768px) {
    /* Transiciones suaves */
    .card,
    .btn,
    .form-control,
    .modal {
        transition: all 0.3s ease-in-out;
    }

    /* Efecto al tocar */
    .btn:active {
        transform: scale(0.98);
    }

    .card:active {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    }
}

/* ========================================
   14. HEADER MÓVIL - MOSTRAR EN MÓVIL
   ======================================== */

@media (max-width: 768px) {
    .mobile-header {
        display: flex !important;
    }
}

/* ========================================
   15. AJUSTES ESPECÍFICOS POR PÁGINA
   ======================================== */

/* Dashboard móvil */
@media (max-width: 768px) {
    /* Tarjetas de estadísticas en 2 columnas */
    .row > .col-md-3 {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }

    /* Accesos rápidos en 2 columnas */
    .row > .col-md-6 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
}

/* Usuarios móvil */
@media (max-width: 768px) {
    /* Avatar más pequeño */
    .bg-primary.rounded-circle {
        width: 28px !important;
        height: 28px !important;
        font-size: 11px !important;
    }

    /* Información de usuario compacta */
    .fw-medium {
        font-size: 0.9rem !important;
    }

    .text-muted.small {
        font-size: 0.75rem !important;
    }
}

/* ========================================
   16. MEJORAS DE ACCESIBILIDAD MÓVIL
   ======================================== */

@media (max-width: 768px) {
    /* Área táctil mínima de 44x44px */
    button,
    a.btn,
    .form-check-input {
        min-height: 44px;
        min-width: 44px;
    }

    /* Contraste mejorado */
    .text-muted {
        color: #666 !important;
    }

    /* Focus visible */
    *:focus {
        outline: 2px solid #20b2aa;
        outline-offset: 2px;
    }
}

/* ========================================
   17. ORIENTACIÓN HORIZONTAL (LANDSCAPE)
   ======================================== */

@media (max-width: 768px) and (orientation: landscape) {
    .mobile-header {
        height: 50px;
    }

    main {
        margin-top: 50px !important;
    }

    .sidebar-nav {
        top: 50px;
        height: calc(100vh - 50px) !important;
    }

    .modal-dialog {
        height: 100vh;
    }
}

/* ========================================
   18. PANTALLAS MUY PEQUEÑAS (< 576px)
   ======================================== */

@media (max-width: 576px) {
    .mobile-header-logo {
        font-size: 14px;
    }

    .mobile-user-button {
        padding: 5px 10px;
        font-size: 11px;
    }

    main {
        padding: 0.75rem !important;
    }

    .card-body {
        padding: 0.75rem !important;
    }

    .table {
        font-size: 0.75rem !important;
    }

    .btn {
        font-size: 0.85rem !important;
    }
}

/* ========================================
   19. PÁGINA DE LOGIN RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    /* Ajustar body para móviles */
    body {
        padding: 0 !important;
        margin: 0 !important;
        overflow-x: hidden !important;
    }
    
    /* Login container */
    .login-container {
        margin: 0.5rem !important;
        border-radius: 15px !important;
        max-width: calc(100% - 1rem) !important;
        width: calc(100% - 1rem) !important;
        box-sizing: border-box !important;
    }

    /* Hacer que el layout sea vertical en móviles */
    .login-container .row {
        flex-direction: column !important;
        height: auto !important;
        overflow: visible !important;
    }

    .login-container .col-md-6,
    .login-container .col-lg-5,
    .login-container .col-lg-7 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    /* Panel izquierdo (información) */
    .login-left {
        padding: 1.5rem 1rem !important;
        min-height: auto !important;
        box-sizing: border-box !important;
    }

    .login-left h2 {
        font-size: 1.5rem !important;
        margin-bottom: 0.5rem !important;
    }

    .login-left h4 {
        font-size: 1.1rem !important;
        margin-bottom: 1rem !important;
    }

    .login-left p {
        font-size: 0.9rem !important;
        margin-bottom: 1rem !important;
    }

    .login-left .company-logo,
    .login-left .icon-circle {
        width: 100px !important;
        height: 100px !important;
        margin-bottom: 1.5rem !important;
        font-size: 3rem !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2) !important;
    }

    .login-left .icon-circle i {
        font-size: 3rem !important;
    }

    /* Lista de características */
    .login-left ul {
        text-align: left !important;
        padding-left: 1rem !important;
        margin-top: 1rem !important;
    }

    .login-left ul li {
        font-size: 0.85rem !important;
        margin-bottom: 0.5rem !important;
        padding-left: 0.5rem !important;
    }

    .login-left ul li i {
        font-size: 0.9rem !important;
        margin-right: 0.5rem !important;
    }

    /* Panel derecho (formulario) - Oculto por defecto en móviles */
    .login-right {
        padding: 0.5rem 1rem !important;
        box-sizing: border-box !important;
        display: none !important;
        overflow-y: auto !important;
        max-height: 100vh !important;
    }
    
    /* Mostrar formulario cuando está activo */
    .login-right.show {
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start !important;
    }
    
    /* Ocultar panel de información cuando el formulario está activo */
    .login-left.hide {
        display: none !important;
    }
    


    .login-right h3 {
        font-size: 1.1rem !important;
        margin-bottom: 0.25rem !important;
        margin-top: 0 !important;
        text-align: center !important;
    }
    
    .login-right p {
        font-size: 0.75rem !important;
        margin-bottom: 0.5rem !important;
        text-align: center !important;
        color: #6c757d !important;
    }

    .login-right .form-label {
        font-size: 0.85rem !important;
        margin-bottom: 0.3rem !important;
    }

    .login-right .form-control {
        font-size: 0.8rem !important;
        padding: 0.5rem 0.7rem !important;
        margin-bottom: 0 !important;
    }
    
    .login-right .form-floating {
        margin-bottom: 0.4rem !important;
    }

    .login-right .btn {
        padding: 0.5rem 0.8rem !important;
        font-size: 0.85rem !important;
        margin-top: 0.4rem !important;
        font-weight: 600 !important;
    }

    /* Logo en el login */
    .login-logo {
        max-width: 150px !important;
        margin-bottom: 1rem !important;
    }

    /* Alertas en login */
    .login-right .alert {
        font-size: 0.7rem !important;
        padding: 0.4rem !important;
        margin-bottom: 0.5rem !important;
    }

    /* Links en login */
    .login-right a {
        font-size: 0.8rem !important;
    }

    /* Checkbox "Recordarme" */
    .form-check {
        font-size: 0.75rem !important;
        margin-bottom: 0.3rem !important;
        margin-top: 0.2rem !important;
    }
    
    /* Separador "O continúa con" */
    .login-right .text-center {
        margin: 0.4rem 0 !important;
        font-size: 0.7rem !important;
    }
    
    /* Botones de redes sociales */
    .login-right .btn-outline-secondary {
        padding: 0.4rem !important;
        font-size: 0.75rem !important;
    }

    /* Ajustar espaciado */
    .login-right .mb-3 {
        margin-bottom: 0.75rem !important;
    }

    .login-right .mb-4 {
        margin-bottom: 1rem !important;
    }
}

/* Pantallas muy pequeñas */
@media (max-width: 576px) {
    .login-container {
        margin: 0.25rem !important;
        border-radius: 12px !important;
        max-width: calc(100% - 0.5rem) !important;
        width: calc(100% - 0.5rem) !important;
    }

    .login-left {
        padding: 1.25rem 0.75rem !important;
    }

    .login-right {
        padding: 1.25rem 0.75rem !important;
    }
    
    .login-left .company-logo,
    .login-left .icon-circle {
        width: 60px !important;
        height: 60px !important;
        font-size: 1.75rem !important;
    }

    .login-left h2 {
        font-size: 1.3rem !important;
    }

    .login-left h4 {
        font-size: 1rem !important;
    }

    .login-left p {
        font-size: 0.85rem !important;
    }

    .login-right h3 {
        font-size: 1.2rem !important;
    }
}

/* Orientación horizontal en móviles */
@media (max-width: 768px) and (orientation: landscape) {
    .login-container {
        max-height: 90vh;
        overflow-y: auto;
    }

    .login-left {
        padding: 1.5rem 1rem !important;
    }

    .login-left .icon-circle {
        width: 60px !important;
        height: 60px !important;
    }

    .login-left ul {
        display: none; /* Ocultar lista en landscape para ahorrar espacio */
    }
}

/* ========================================
   OCULTAR HEADER MÓVIL EN LOGIN
   ======================================== */
   
/* Ocultar header móvil en la página de login */
body.login-page .mobile-header,
body.login-page .mobile-sidebar-overlay,
body.login-page .sidebar {
    display: none !important;
}

/* Asegurar que el contenido del login ocupe toda la pantalla */
body.login-page {
    padding-top: 0 !important;
}


/* ========================================
   MODAL DE PERFIL - ESTILOS MÓVILES
   ======================================== */

@media (max-width: 768px) {
    /* Modal de perfil responsivo */
    #modalPerfil .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    #modalPerfil .modal-content {
        border-radius: 16px;
        overflow: hidden;
    }
    
    #modalPerfil .modal-header {
        padding: 1rem;
    }
    
    #modalPerfil .modal-header .modal-title {
        font-size: 1.1rem;
    }
    
    #modalPerfil .modal-body {
        padding: 1rem;
    }
    
    /* Foto de perfil en móvil */
    #modalPerfil .modal-body .text-center.mb-4 {
        margin-bottom: 1rem !important;
    }
    
    #modalPerfil #fotoPerfil {
        width: 100px !important;
        height: 100px !important;
        border-width: 2px !important;
    }
    
    /* Botón de cámara */
    #modalPerfil label[for="inputFotoPerfil"] {
        width: 32px !important;
        height: 32px !important;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    #modalPerfil label[for="inputFotoPerfil"] i {
        font-size: 0.85rem;
    }
    
    /* Campos del formulario */
    #modalPerfil .form-label {
        font-size: 0.9rem;
        margin-bottom: 0.25rem;
    }
    
    #modalPerfil .form-control {
        font-size: 0.95rem;
        padding: 0.5rem 0.75rem;
    }
    
    #modalPerfil .mb-3 {
        margin-bottom: 0.75rem !important;
    }
    
    /* Footer del modal */
    #modalPerfil .modal-footer {
        padding: 0.75rem 1rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    #modalPerfil .modal-footer .btn {
        width: 100%;
        margin: 0 !important;
        padding: 0.75rem;
        font-size: 1rem;
        border-radius: 10px;
    }
    
    /* Mensaje de alerta */
    #modalPerfil #mensajePerfil {
        font-size: 0.9rem;
        padding: 0.5rem 0.75rem;
        margin-bottom: 0.75rem;
    }
}

/* Pantallas muy pequeñas */
@media (max-width: 400px) {
    #modalPerfil #fotoPerfil {
        width: 80px !important;
        height: 80px !important;
    }
    
    #modalPerfil label[for="inputFotoPerfil"] {
        width: 28px !important;
        height: 28px !important;
    }
    
    #modalPerfil .form-control {
        font-size: 0.9rem;
    }
}

/* ========================================
   MODAL DE CAMBIAR CONTRASEÑA - ESTILOS MÓVILES
   ======================================== */

@media (max-width: 768px) {
    #modalCambiarPassword .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    #modalCambiarPassword .modal-content {
        border-radius: 16px;
    }
    
    #modalCambiarPassword .modal-header {
        padding: 1rem;
    }
    
    #modalCambiarPassword .modal-body {
        padding: 1rem;
    }
    
    #modalCambiarPassword .modal-footer {
        padding: 0.75rem 1rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    #modalCambiarPassword .modal-footer .btn {
        width: 100%;
        margin: 0 !important;
        padding: 0.75rem;
        border-radius: 10px;
    }
}

/* ========================================
   MODAL DE TIMEOUT DE SESIÓN - ESTILOS MÓVILES
   ======================================== */

@media (max-width: 768px) {
    #sessionTimeoutModal .modal-dialog {
        margin: 1rem;
        max-width: calc(100% - 2rem);
    }
    
    #sessionTimeoutModal .modal-content {
        border-radius: 16px;
    }
    
    #sessionTimeoutModal .modal-header {
        padding: 1rem;
    }
    
    #sessionTimeoutModal .modal-body {
        padding: 1.5rem 1rem;
    }
    
    #sessionTimeoutModal .modal-body .fa-4x {
        font-size: 3rem !important;
    }
    
    #sessionTimeoutModal .modal-body h5 {
        font-size: 1.1rem;
    }
    
    #sessionTimeoutModal .modal-body p {
        font-size: 0.9rem;
    }
    
    #sessionTimeoutModal .modal-footer {
        padding: 0.75rem 1rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    #sessionTimeoutModal .modal-footer .btn {
        width: 100%;
        margin: 0 !important;
        padding: 0.75rem;
        border-radius: 10px;
    }
}


/* ========================================
   22. MODAL DE CLIENTES - MÓVIL
   Corrección específica para el formulario de clientes
   ======================================== */

@media (max-width: 768px) {
    /* NO usar position fixed en body - causa problemas de scroll */
    body.modal-open {
        overflow: hidden !important;
    }
    
    /* Modal de clientes - Pantalla completa optimizada */
    #modalCliente .modal-dialog,
    #modalDetallesCliente .modal-dialog {
        margin: 0 !important;
        max-width: 100% !important;
        height: 100% !important;
        width: 100% !important;
    }
    
    #modalCliente .modal-content,
    #modalDetallesCliente .modal-content {
        height: 100% !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        border: none !important;
        display: flex !important;
        flex-direction: column !important;
    }
    
    /* Header del modal fijo */
    #modalCliente .modal-header,
    #modalDetallesCliente .modal-header {
        flex-shrink: 0 !important;
        background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%) !important;
        color: white !important;
        padding: 1rem !important;
        border-bottom: none !important;
    }
    
    #modalCliente .modal-header .modal-title,
    #modalDetallesCliente .modal-header .modal-title {
        color: white !important;
        font-size: 1.1rem !important;
        font-weight: 600 !important;
    }
    
    #modalCliente .modal-header .btn-close,
    #modalDetallesCliente .modal-header .btn-close {
        filter: brightness(0) invert(1) !important;
        opacity: 1 !important;
    }
    
    /* Body del modal con scroll - CLAVE para que funcione */
    #modalCliente .modal-body,
    #modalDetallesCliente .modal-body {
        flex: 1 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        padding: 1rem !important;
        -webkit-overflow-scrolling: touch !important;
        background-color: #f8f9fa !important;
        overscroll-behavior: contain !important; /* Evita scroll del fondo */
    }
    
    /* Footer del modal fijo */
    #modalCliente .modal-footer,
    #modalDetallesCliente .modal-footer {
        flex-shrink: 0 !important;
        background: white !important;
        padding: 1rem !important;
        border-top: 1px solid #e0e0e0 !important;
        flex-direction: column !important;
        gap: 0.5rem !important;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1) !important;
    }
    
    #modalCliente .modal-footer .btn,
    #modalDetallesCliente .modal-footer .btn {
        width: 100% !important;
        margin: 0 !important;
        padding: 0.75rem 1rem !important;
        font-size: 1rem !important;
        border-radius: 10px !important;
    }
    
    /* Formulario dentro del modal */
    #modalCliente .row.g-3 {
        margin: 0 !important;
    }
    
    #modalCliente .row.g-3 > [class*="col-"] {
        padding: 0.5rem !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
    
    /* Campos del formulario */
    #modalCliente .form-label {
        font-size: 0.9rem !important;
        font-weight: 600 !important;
        color: #333 !important;
        margin-bottom: 0.4rem !important;
    }
    
    #modalCliente .form-control,
    #modalCliente .form-select {
        font-size: 16px !important; /* Evita zoom en iOS */
        padding: 0.75rem !important;
        border-radius: 8px !important;
        border: 1px solid #ddd !important;
        background-color: white !important;
    }
    
    #modalCliente .form-control:focus,
    #modalCliente .form-select:focus {
        border-color: #2563eb !important;
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15) !important;
    }
    
    #modalCliente textarea.form-control {
        min-height: 80px !important;
    }
    
    /* Input group (para el campo de ingresos) */
    #modalCliente .input-group {
        flex-wrap: nowrap !important;
    }
    
    #modalCliente .input-group-text {
        font-size: 1rem !important;
        padding: 0.75rem !important;
        background-color: #e9ecef !important;
        border-radius: 8px 0 0 8px !important;
    }
    
    #modalCliente .input-group .form-control {
        border-radius: 0 8px 8px 0 !important;
    }
    
    /* Sección de referencias */
    #modalCliente hr.my-4 {
        margin: 1.5rem 0 !important;
    }
    
    #modalCliente h6.text-primary {
        font-size: 1rem !important;
        padding: 0.75rem !important;
        background-color: rgba(37, 99, 235, 0.1) !important;
        border-radius: 8px !important;
        margin-bottom: 1rem !important;
    }
    
    /* Texto de ayuda */
    #modalCliente .form-text {
        font-size: 0.75rem !important;
        color: #666 !important;
    }
    
    /* Campos requeridos */
    #modalCliente .text-danger {
        color: #dc3545 !important;
    }
}

/* ========================================
   23. MODAL DE AUTENTICACIÓN - MÓVIL
   ======================================== */

@media (max-width: 768px) {
    #modalAuthEditarCliente .modal-dialog {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        min-height: 100vh !important;
        margin: 0 !important;
        padding: 1rem !important;
    }
    
    #modalAuthEditarCliente .modal-content {
        height: auto !important;
        max-height: 90vh !important;
        border-radius: 16px !important;
        margin: auto !important;
    }
    
    #modalAuthEditarCliente .modal-header {
        border-radius: 16px 16px 0 0 !important;
    }
    
    #modalAuthEditarCliente .modal-body {
        background-color: white !important;
    }
    
    #modalAuthEditarCliente .modal-footer {
        border-radius: 0 0 16px 16px !important;
        box-shadow: none !important;
    }
}

/* ========================================
   24. MEJORAS ADICIONALES PARA FORMULARIOS MÓVILES
   ======================================== */

@media (max-width: 768px) {
    /* Evitar que los inputs hagan zoom en iOS */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    input[type="password"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px !important;
    }
    
    /* Flatpickr en móviles */
    .flatpickr-calendar {
        width: calc(100vw - 2rem) !important;
        max-width: 350px !important;
    }
    
    .flatpickr-calendar.open {
        z-index: 99999 !important;
    }
    
    /* Asegurar que los selects sean táctiles */
    select.form-select {
        -webkit-appearance: none !important;
        -moz-appearance: none !important;
        appearance: none !important;
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e") !important;
        background-repeat: no-repeat !important;
        background-position: right 0.75rem center !important;
        background-size: 16px 12px !important;
        padding-right: 2.5rem !important;
    }
}

/* ========================================
   25. CORRECCIÓN DE Z-INDEX PARA MODALES
   ======================================== */

@media (max-width: 768px) {
    /* Asegurar que los modales estén sobre todo */
    .modal {
        z-index: 1055 !important;
    }
    
    .modal-backdrop {
        z-index: 1050 !important;
    }
    
    /* Modal de autenticación sobre el modal de cliente */
    #modalAuthEditarCliente {
        z-index: 1060 !important;
    }
    
    #modalAuthEditarCliente + .modal-backdrop {
        z-index: 1057 !important;
    }
}
