/* ============================================================
   RESPONSIVE DESIGN - OPTIMIZADO PARA TODOS LOS DISPOSITIVOS
   ============================================================ */

/* ============================================================
   MOBILE FIRST - Base para móviles
   ============================================================ */

/* Mejorar scroll horizontal en tablas para móviles */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 20px;
}

.data-table {
    min-width: 800px; /* Evitar que la tabla se comprima demasiado */
}

/* ============================================================
   TABLETS Y MÓVILES HORIZONTALES (max-width: 1024px)
   ============================================================ */
@media (max-width: 1024px) {
    /* Dashboard grid a 2 columnas */
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    /* Stats grid a 2 columnas */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    /* Mensajes layout a 1 columna */
    .mensajes-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .mensajes-list {
        max-height: 400px;
    }
    
    /* Modal más pequeño */
    .modal-content {
        max-width: 90%;
        margin: 30px auto;
    }
    
    .modal-large {
        max-width: 95%;
    }
    
    /* Form rows en columna */
    .form-row {
        flex-direction: column;
    }
    
    .form-row .form-group {
        width: 100%;
    }
}

/* ============================================================
   TABLETS Y MÓVILES (max-width: 768px)
   ============================================================ */
@media (max-width: 768px) {
    /* Root variables para móvil */
    :root {
        --sidebar-width: 280px;
        --header-height: 60px;
    }
    
    /* ========== SIDEBAR ========== */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        width: var(--sidebar-width);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    /* Overlay para cerrar sidebar */
    body.sidebar-open::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }
    
    /* ========== MAIN CONTENT ========== */
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    
    /* ========== HEADER ========== */
    .header {
        height: var(--header-height);
        padding: 0 15px;
    }
    
    /* Botón hamburguesa para abrir menú */
    .menu-toggle {
        display: block !important;
        background: none;
        border: none;
        font-size: 24px;
        color: var(--text-primary);
        cursor: pointer;
        padding: 5px;
        margin-right: 15px;
    }
    
    .user-info {
        font-size: 13px;
    }
    
    .user-name {
        display: none; /* Ocultar nombre en móvil */
    }
    
    /* ========== DASHBOARD ========== */
    .dashboard-grid,
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .stat-card {
        padding: 15px;
    }
    
    .stat-value {
        font-size: 28px;
    }
    
    /* ========== SECTION HEADER ========== */
    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .section-header h2 {
        font-size: 20px;
    }
    
    .filter-group {
        flex-direction: column;
        max-width: 100%;
        gap: 8px;
    }
    
    .filter-group select,
    .filter-group input {
        width: 100%;
        font-size: 14px;
    }
    
    /* ========== BUTTONS ========== */
    .btn {
        padding: 10px 16px;
        font-size: 14px;
        width: 100%;
        justify-content: center;
    }
    
    .btn-sm {
        padding: 6px 10px;
        font-size: 13px;
    }
    
    .action-buttons {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    /* ========== TABLES ========== */
    .table-container {
        border-radius: 6px;
    }
    
    .data-table {
        font-size: 13px;
    }
    
    .data-table th,
    .data-table td {
        padding: 10px 8px;
        white-space: nowrap;
    }
    
    /* Ocultar columnas menos importantes en móvil */
    .data-table .hide-mobile {
        display: none;
    }
    
    /* ========== MODALS ========== */
    .modal-content {
        max-width: 95%;
        margin: 20px auto;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .modal-large {
        max-width: 98%;
    }
    
    .modal-header {
        padding: 15px;
    }
    
    .modal-header h2 {
        font-size: 18px;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    /* ========== FORMS ========== */
    .form-group label {
        font-size: 13px;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 14px;
        padding: 10px;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .form-actions .btn {
        width: 100%;
    }
    
    /* ========== BADGES ========== */
    .badge {
        font-size: 11px;
        padding: 4px 8px;
    }
    
    /* ========== TABS ========== */
    .tabs-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        margin-bottom: 15px;
    }
    
    .tab-btn {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    /* ========== MENSAJES ========== */
    .mensaje-card {
        padding: 12px;
    }
    
    .mensaje-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    /* ========== ASISTENCIAS ========== */
    .asistencia-card {
        padding: 12px;
    }
    
    .asistencia-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .asistencia-actions .btn {
        width: 100%;
    }
    
    /* ========== EVALUACIONES ========== */
    .permisos-section {
        padding: 12px;
    }
    
    .checkbox-group {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

/* ============================================================
   MÓVILES PEQUEÑOS (max-width: 480px)
   ============================================================ */
@media (max-width: 480px) {
    /* ========== GENERAL ========== */
    body {
        font-size: 14px;
    }
    
    /* ========== HEADER ========== */
    .header {
        padding: 0 10px;
    }
    
    .logo h1 {
        font-size: 16px;
    }
    
    .logo i {
        font-size: 20px;
    }
    
    /* ========== STATS ========== */
    .stat-card {
        padding: 12px;
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .stat-value {
        font-size: 24px;
    }
    
    .stat-label {
        font-size: 12px;
    }
    
    /* ========== SECTION HEADER ========== */
    .section-header h2 {
        font-size: 18px;
    }
    
    /* ========== TABLES ========== */
    .data-table {
        font-size: 12px;
        min-width: 700px;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px 6px;
    }
    
    /* ========== MODALS ========== */
    .modal-content {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    .modal-header h2 {
        font-size: 16px;
    }
    
    /* ========== BUTTONS ========== */
    .btn {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    .btn i {
        font-size: 14px;
    }
    
    /* ========== FORMS ========== */
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 14px;
        padding: 8px;
    }
    
    /* ========== BADGES ========== */
    .badge {
        font-size: 10px;
        padding: 3px 6px;
    }
    
    /* ========== SIDEBAR ========== */
    .sidebar {
        width: 260px;
    }
    
    .nav-item {
        padding: 12px 15px;
        font-size: 14px;
    }
}

/* ============================================================
   LANDSCAPE MODE - Móviles en horizontal
   ============================================================ */
@media (max-height: 500px) and (orientation: landscape) {
    .modal-content {
        max-height: 95vh;
        overflow-y: auto;
    }
    
    .sidebar {
        overflow-y: auto;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ============================================================
   TABLETS ESPECÍFICAS (768px - 1024px)
   ============================================================ */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        transform: translateX(0);
        position: relative;
    }
    
    .main-content {
        margin-left: var(--sidebar-width);
    }
    
    .menu-toggle {
        display: none !important;
    }
    
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================================
   DESKTOP GRANDE (min-width: 1400px)
   ============================================================ */
@media (min-width: 1400px) {
    .dashboard-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .modal-content {
        max-width: 600px;
    }
    
    .modal-large {
        max-width: 1000px;
    }
}

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
    .sidebar,
    .header,
    .action-buttons,
    .btn,
    .filter-group {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0;
        padding: 0;
    }
    
    .data-table {
        font-size: 10px;
    }
    
    .section-header h2 {
        font-size: 16px;
        margin-bottom: 10px;
    }
}

/* ============================================================
   UTILITIES PARA RESPONSIVE
   ============================================================ */

/* Mostrar/ocultar según dispositivo */
.show-mobile { display: none !important; }
.hide-mobile { display: block !important; }

@media (max-width: 768px) {
    .show-mobile { display: block !important; }
    .hide-mobile { display: none !important; }
}

/* Scroll suave */
* {
    -webkit-overflow-scrolling: touch;
}

/* Mejorar tap targets para móvil */
@media (max-width: 768px) {
    button,
    a,
    .btn,
    .nav-item {
        min-height: 44px; /* Tamaño mínimo táctil recomendado */
        min-width: 44px;
    }
}

/* Prevenir zoom en inputs en iOS */
@media (max-width: 768px) {
    input,
    select,
    textarea {
        font-size: 16px !important; /* iOS no hace zoom si es >= 16px */
    }
}

/* ============================================================
   INSCRIPCIONES - TARJETAS MÓVILES
   ============================================================ */
@media (max-width: 768px) {
    /* Ocultar tabla en móvil */
    #section-inscripciones .table-container {
        display: none !important;
    }
    
    /* Mostrar tarjetas en móvil */
    #inscripcionesCardsMobile {
        display: block !important;
    }
    
    .inscripcion-card-mobile {
        background: white;
        border-radius: 12px;
        padding: 15px;
        margin-bottom: 15px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        border-left: 4px solid #667eea;
    }
    
    .inscripcion-card-mobile.estado-Baja {
        border-left-color: #f39c12;
        opacity: 0.85;
    }
    
    .inscripcion-card-mobile.estado-Finalizado {
        border-left-color: #95a5a6;
        opacity: 0.75;
    }
    
    .card-mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: start;
        margin-bottom: 12px;
        padding-bottom: 12px;
        border-bottom: 1px solid #ecf0f1;
    }
    
    .card-mobile-nombre {
        font-weight: 600;
        font-size: 16px;
        color: #2c3e50;
        margin-bottom: 4px;
    }
    
    .card-mobile-dni {
        font-size: 13px;
        color: #7f8c8d;
    }
    
    .card-mobile-badge {
        padding: 4px 10px;
        border-radius: 12px;
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
    }
    
    .card-mobile-badge.badge-Activo {
        background: #d4edda;
        color: #155724;
    }
    
    .card-mobile-badge.badge-Baja {
        background: #fff3cd;
        color: #856404;
    }
    
    .card-mobile-badge.badge-Finalizado {
        background: #e2e3e5;
        color: #383d41;
    }
    
    .card-mobile-curso {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        padding: 10px;
        border-radius: 8px;
        margin-bottom: 12px;
        font-weight: 500;
        font-size: 14px;
    }
    
    .card-mobile-body {
        margin-bottom: 12px;
    }
    
    .card-mobile-row {
        display: flex;
        align-items: center;
        padding: 6px 0;
        font-size: 13px;
    }
    
    .card-mobile-icon {
        width: 20px;
        color: #667eea;
        margin-right: 8px;
    }
    
    .card-mobile-label {
        color: #7f8c8d;
        margin-right: 6px;
        min-width: 70px;
    }
    
    .card-mobile-value {
        color: #2c3e50;
        font-weight: 500;
    }
    
    .card-mobile-actions {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
        padding-top: 12px;
        border-top: 1px solid #ecf0f1;
    }
    
    .card-mobile-actions .btn {
        flex: 1;
        min-width: 45px;
        padding: 8px;
        font-size: 14px;
    }
}

/* ========================================
   MOBILE CARDS: ESTUDIANTES
   ======================================== */
.estudiante-card-mobile {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 16px;
    margin-bottom: 12px;
    border-left: 4px solid #3498db;
}

.estudiante-card-mobile .mobile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 2px solid #ecf0f1;
}

.estudiante-card-mobile .mobile-card-nombre {
    font-size: 16px;
    font-weight: bold;
    color: #2c3e50;
    word-break: break-word;
}

.estudiante-card-mobile .mobile-card-dni {
    font-size: 13px;
    color: #7f8c8d;
    margin-top: 4px;
}

.estudiante-card-mobile .mobile-card-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.estudiante-card-mobile .mobile-card-row {
    display: flex;
    align-items: center;
    font-size: 14px;
}

.estudiante-card-mobile .mobile-card-icon {
    color: #3498db;
    margin-right: 8px;
    min-width: 20px;
}

.estudiante-card-mobile .mobile-card-label {
    color: #7f8c8d;
    margin-right: 6px;
    font-weight: 500;
}

.estudiante-card-mobile .mobile-card-value {
    color: #2c3e50;
    word-break: break-word;
}

.estudiante-card-mobile .mobile-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 12px;
    border-top: 1px solid #ecf0f1;
}

.estudiante-card-mobile .mobile-card-actions .btn {
    flex: 1;
    min-width: 80px;
    padding: 10px;
    font-size: 13px;
}

/* ========================================
   MOBILE CARDS: CURSOS
   ======================================== */
.curso-card-mobile {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 16px;
    margin-bottom: 12px;
    border-left: 4px solid #9b59b6;
}

.curso-card-mobile .mobile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 2px solid #ecf0f1;
}

.curso-card-mobile .mobile-card-nombre {
    font-size: 16px;
    font-weight: bold;
    color: #2c3e50;
    word-break: break-word;
}

.curso-card-mobile .mobile-card-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: bold;
}

.curso-card-mobile .mobile-card-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.curso-card-mobile .mobile-card-row {
    display: flex;
    align-items: center;
    font-size: 14px;
}

.curso-card-mobile .mobile-card-icon {
    color: #9b59b6;
    margin-right: 8px;
    min-width: 20px;
}

.curso-card-mobile .mobile-card-label {
    color: #7f8c8d;
    margin-right: 6px;
    font-weight: 500;
}

.curso-card-mobile .mobile-card-value {
    color: #2c3e50;
    word-break: break-word;
}

.curso-card-mobile .mobile-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 12px;
    border-top: 1px solid #ecf0f1;
}

.curso-card-mobile .mobile-card-actions .btn {
    flex: 1;
    min-width: 80px;
    padding: 10px;
    font-size: 13px;
}

/* ========================================
   MOBILE CARDS: PAGOS (Cuotas/Morosos/Historial)
   ======================================== */
.pago-card-mobile {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 16px;
    margin-bottom: 12px;
    border-left: 4px solid #27ae60;
}

.pago-card-mobile.moroso {
    border-left-color: #e74c3c;
}

.pago-card-mobile.vencida {
    border-left-color: #f39c12;
}

.pago-card-mobile .mobile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 2px solid #ecf0f1;
}

.pago-card-mobile .mobile-card-nombre {
    font-size: 16px;
    font-weight: bold;
    color: #2c3e50;
    word-break: break-word;
}

.pago-card-mobile .mobile-card-dni {
    font-size: 13px;
    color: #7f8c8d;
    margin-top: 4px;
}

.pago-card-mobile .mobile-card-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: bold;
}

.pago-card-mobile .mobile-card-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.pago-card-mobile .mobile-card-row {
    display: flex;
    align-items: center;
    font-size: 14px;
}

.pago-card-mobile .mobile-card-icon {
    color: #27ae60;
    margin-right: 8px;
    min-width: 20px;
}

.pago-card-mobile.moroso .mobile-card-icon {
    color: #e74c3c;
}

.pago-card-mobile .mobile-card-label {
    color: #7f8c8d;
    margin-right: 6px;
    font-weight: 500;
    min-width: 90px;
}

.pago-card-mobile .mobile-card-value {
    color: #2c3e50;
    word-break: break-word;
}

.pago-card-mobile .mobile-card-monto {
    font-size: 18px;
    font-weight: bold;
    color: #27ae60;
    margin-top: 8px;
}

.pago-card-mobile.moroso .mobile-card-monto {
    color: #e74c3c;
}

.pago-card-mobile .mobile-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 12px;
    border-top: 1px solid #ecf0f1;
}

.pago-card-mobile .mobile-card-actions .btn {
    flex: 1;
    min-width: 100px;
    padding: 10px;
    font-size: 13px;
}

/* ========================================
   OCULTAR TABLAS Y MOSTRAR CARDS EN MOBILE
   ======================================== */
@media (max-width: 768px) {
    /* Ocultar tablas */
    #tablaEstudiantes,
    #tablaCursos,
    #tablaCuotasPendientes,
    #tablaCuotasVencidas,
    #tablaHistorialPagos {
        display: none !important;
    }
    
    /* Mostrar contenedores móviles */
    #estudiantesCardsMobile,
    #cursosCardsMobile,
    #cuotasPendientesCardsMobile,
    #morososCardsMobile,
    #historialPagosCardsMobile {
        display: flex !important;
        flex-direction: column;
        width: 100%;
        padding: 10px;
        opacity: 1;
    }
}
