/**
 * ============================================================================
 * RESPONSIVE CSS - ADAPTACIÓN MÓVIL PROFESIONAL (CELULARES Y TABLETS)
 * ENERVIDA - Sistema de Inscripciones
 * ============================================================================
 */

/* --------------------------------------------------------------------------
 * 1. PANTALLAS TABLET Y MENORES (≤ 991.98px)
 * -------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
    /* Barra lateral estilo Drawer off-canvas */
    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: 270px;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1045;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
    }

    .sidebar.show {
        transform: translateX(0);
    }

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

    .btn-sidebar-toggle {
        display: inline-flex !important;
    }

    /* Fondo semitransparente al abrir el menú */
    .sidebar-backdrop {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(13, 59, 102, 0.55);
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
        z-index: 1040;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .sidebar-backdrop.show {
        display: block;
        opacity: 1;
    }

    .topbar {
        padding: 0 1rem;
        height: 60px;
    }

    .page-body {
        padding: 1rem;
    }
}

/* --------------------------------------------------------------------------
 * 2. PANTALLAS MÓVILES GENERALES (≤ 767.98px)
 * -------------------------------------------------------------------------- */
@media (max-width: 767.98px) {
    /* Prevenir zoom automático indeseado en inputs en iOS Safari */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px !important;
    }

    .page-body {
        padding: 0.85rem 0.65rem;
    }

    .topbar {
        padding: 0 0.75rem;
        height: 56px;
    }

    .topbar-title {
        font-size: 1.05rem;
        font-weight: 700;
        max-width: 170px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Tarjetas KPI del Dashboard */
    .kpi-card {
        padding: 0.85rem 1rem;
        border-radius: 12px;
    }

    .kpi-icon-wrapper {
        width: 44px;
        height: 44px;
        font-size: 1.25rem;
        margin-right: 0.75rem;
        border-radius: 10px;
    }

    .kpi-value {
        font-size: 1.35rem;
        letter-spacing: -0.5px;
    }

    .kpi-label {
        font-size: 0.78rem;
    }

    /* Cabecera de tarjetas institucionales */
    .card-enervida {
        border-radius: 12px;
        margin-bottom: 1rem;
    }

    .card-enervida-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 0.85rem 1rem;
    }

    .card-enervida-body {
        padding: 1rem;
    }

    /* Pestañas horizontales scrolleables en celular */
    .nav-tabs-enervida {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        padding-bottom: 4px;
        scrollbar-width: thin;
    }

    .nav-tabs-enervida::-webkit-scrollbar {
        height: 3px;
    }

    /* Tablas responsivas en pantalla táctil */
    .table-responsive {
        border-radius: 10px;
        border: 1px solid #e2e8f0;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 0.5rem;
    }

    .table th,
    .table td {
        padding: 0.65rem 0.65rem;
        font-size: 0.85rem;
    }

    /* Botones de acción en tablas */
    .table .btn-sm {
        padding: 0.35rem 0.6rem;
        font-size: 0.8rem;
        border-radius: 6px;
    }

    /* Modal adaptado a pantalla táctil */
    .modal-dialog {
        margin: 0.5rem auto;
        width: calc(100% - 1rem);
        max-width: 100%;
    }

    .modal-content {
        border-radius: 14px;
        max-height: 94vh;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .modal-header {
        padding: 0.85rem 1rem;
    }

    .modal-title {
        font-size: 1.05rem;
    }

    .modal-body {
        padding: 1rem !important;
        max-height: calc(94vh - 125px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-footer {
        position: sticky;
        bottom: 0;
        background: #ffffff;
        z-index: 105;
        padding: 0.75rem 1rem;
        border-top: 1px solid #e2e8f0;
    }

    /* Diálogos SweetAlert2 en celular */
    div:where(.swal2-container) .swal2-popup {
        width: 92% !important;
        padding: 1.25rem 1rem !important;
        border-radius: 16px !important;
    }

    div:where(.swal2-container) .swal2-title {
        font-size: 1.2rem !important;
    }

    div:where(.swal2-container) .swal2-html-container {
        font-size: 0.9rem !important;
    }

    div:where(.swal2-container) .swal2-actions {
        width: 100% !important;
        gap: 0.5rem;
        margin-top: 1rem !important;
    }

    div:where(.swal2-container) .swal2-actions button {
        flex: 1 1 auto;
        padding: 0.65rem 1rem !important;
        font-size: 0.9rem !important;
        border-radius: 8px !important;
    }
}

/* --------------------------------------------------------------------------
 * 3. PANTALLAS MÓVILES PEQUEÑAS (≤ 575.98px)
 * -------------------------------------------------------------------------- */
@media (max-width: 575.98px) {
    /* Botones de pie de modal a ancho completo o en columna */
    .modal-footer {
        flex-direction: column-reverse;
        gap: 0.5rem;
    }

    .modal-footer .btn {
        width: 100%;
        margin: 0 !important;
        padding: 0.7rem 1rem;
        font-size: 0.95rem;
    }

    /* Filtros y formularios que se apilan */
    .btn-primary-enervida,
    .btn-outline-secondary {
        border-radius: 8px;
    }

    /* Gráficos en celular */
    .chart-container-mobile {
        min-height: 220px;
    }

    /* Tarjetas de cursos en móvil */
    .curso-card {
        border-radius: 12px;
        overflow: hidden;
    }

    .curso-card .card-body {
        padding: 0.9rem;
    }
}

/* --------------------------------------------------------------------------
 * 4. PANTALLA DE LOGIN EN CELULAR
 * -------------------------------------------------------------------------- */
@media (max-width: 480px) {
    body.login-page,
    .login-wrapper {
        padding: 0.75rem !important;
    }

    .login-card {
        border-radius: 14px;
        box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    }

    .login-header {
        padding: 1.5rem 1.25rem 1rem 1.25rem;
    }

    .login-header img {
        max-height: 48px;
    }

    .login-header h2 {
        font-size: 1.25rem;
    }

    .login-body {
        padding: 1.25rem;
    }

    .login-footer {
        padding: 0.75rem 1rem;
        font-size: 0.75rem;
    }
}
