/* =========================================================
   RESPONSIVE PARA EL PANEL DE ADMINISTRACIÓN (CELULARES)
   ========================================================= */

@media (max-width: 768px) {
    
    /* 1. CABECERA: Hacer que el logo y el botón se organicen */
    .header {
        flex-wrap: wrap !important;
        gap: 10px !important;
        padding: 10px !important;
        justify-content: center !important;
    }
    .logo {
        height: 40px !important;
    }
    .titulo-header h1 {
        font-size: 1.1rem !important;
    }
    .titulo-header p {
        font-size: 0.8rem !important;
    }
    .btn-cerrar {
        font-size: 0.8rem !important;
        padding: 8px 12px !important;
        margin-top: 5px !important;
    }

    /* 2. MENÚ: Hacer que los botones sean táctiles y se envuelvan */
    .menu {
        gap: 6px !important;
        padding: 10px !important;
        margin: 10px !important;
    }
    .tab-btn {
        flex: 1 1 45% !important;
        padding: 10px !important;
        font-size: 0.85rem !important;
    }

    /* 3. CONTENEDOR PRINCIPAL: Convertir todo a 1 sola columna */
    .contenedor {
        padding: 10px !important;
    }
    .contenedor-principal,
    .grid-reportes,
    .config-grid,
    div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
    
    /* 4. TARJETAS Y CAJAS DE TEXTO */
    .tarjeta {
        padding: 15px !important;
    }
    .tarjeta-blanca {
        padding: 15px !important;
    }
    .header-usuarios {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 15px !important;
    }
    .header-usuarios h2 {
        font-size: 1.4rem !important;
    }

    /* 5. FORMULARIOS: Asegurar que los inputs no se desborden */
    .grid-form {
        grid-template-columns: 1fr !important;
    }
    input[type="text"], input[type="date"], input[type="email"], input[type="password"], select, textarea {
        font-size: 16px !important; /* Evita zoom en iPhone */
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* 6. BOTONES DE ACCIÓN (Editar, Activo, Eliminar) */
    .btn-tabla,
    .btn {
        display: block !important;
        width: 100% !important;
        margin-bottom: 8px !important;
        padding: 10px !important;
        box-sizing: border-box !important;
    }
    div[style*="display: flex"] {
        flex-wrap: wrap !important;
    }

    /* 7. TABLAS: Deslizar horizontalmente en lugar de desbordar */
    .tabla-wrapper {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        display: block !important;
    }
    table {
        min-width: 700px !important; 
        width: max-content !important;
    }

    /* 8. RESERVAS POR SEMANA: 3 columnas en lugar de 6 */
    div[style*="repeat(6, 1fr)"] {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 5px !important;
    }

    /* 9. TARJETAS DE ESTADÍSTICAS */
    .resumen-tarjetas {
        grid-template-columns: 1fr !important;
    }
    .resumen-caja {
        flex-direction: row !important;
    }

    /* 10. MODALES: Adaptarlos al ancho del celular */
    .modal, 
    #modalMes > div,
    #modalClaveAdmin > div,
    #modalAdvertencia > div,
    #modalEditarDocente > div,
    #modalReservasPasadasAdmin > div {
        width: 95% !important;
        max-width: 95% !important;
        padding: 15px !important;
        box-sizing: border-box !important;
    }

    /* 11. CONFIGURACIÓN: Bloques de colores a una columna */
    .config-grid {
        grid-template-columns: 1fr !important;
    }

    /* 12. PIE DE PÁGINA: Evitar que tape el contenido */
    .footer-institucional {
        position: relative !important;
        width: 100% !important;
        left: 0 !important;
        right: 0 !important;
        text-align: center !important;
        margin-top: 20px !important;
    }
}

/* =========================================================
   RESPONSIVE PARA EL LOGIN (CELULARES Y TABLETS)
   ========================================================= */

@media (max-width: 600px) {
    body {
        padding: 15px !important;
        height: auto !important;
        min-height: 100vh !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .tarjeta {
        width: 100% !important;
        max-width: 380px !important;
        padding: 25px 20px !important;
        margin: 10px auto !important;
        box-sizing: border-box !important;
        border-radius: 15px !important;
        /* Asegurar que esté centrada */
        margin-left: auto !important;
        margin-right: auto !important;
    }

    .tarjeta h1 {
        font-size: 1.5rem !important;
        margin-bottom: 20px !important;
    }

    .campo {
        margin-bottom: 16px !important;
    }

    .campo label {
        font-size: 0.9rem !important;
        margin-bottom: 4px !important;
    }

    input[type="text"],
    input[type="password"] {
        font-size: 16px !important; /* Evita zoom en iOS */
        padding: 14px 12px !important;
        border-radius: 8px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .boton {
        font-size: 1rem !important;
        padding: 14px !important;
        border-radius: 8px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .enlace {
        font-size: 0.9rem !important;
        margin-top: 20px !important;
    }

    .error {
        font-size: 0.85rem !important;
        padding: 10px !important;
        border-radius: 8px !important;
        margin-bottom: 15px !important;
    }

    .primer-ingreso {
        font-size: 0.75rem !important;
        margin-bottom: 12px !important;
    }

    .footer-institucional {
        font-size: 0.7rem !important;
        padding-top: 12px !important;
        margin-top: 20px !important;
    }
}

/* Para pantallas muy pequeñas (menos de 380px) */
@media (max-width: 380px) {
    .tarjeta {
        padding: 18px 15px !important;
    }
    .tarjeta h1 {
        font-size: 1.3rem !important;
    }
    input[type="text"],
    input[type="password"] {
        padding: 12px 10px !important;
        font-size: 15px !important;
    }
    .boton {
        padding: 12px !important;
        font-size: 0.95rem !important;
    }
}