/* ===================================
   RESPONSIVE.CSS - Media Queries
   =================================== */

/* Tablet Landscape */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .content-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .main-content {
        margin-left: calc(var(--sidebar-width) - 20px);
    }
    
    .top-header {
        padding: 1.5rem 2rem;
    }
    
    .section {
        padding: 2rem;
    }
}

/* Tablet Portrait */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 280px;
    }
    
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 1000;
        box-shadow: var(--box-shadow-lg);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    
    .top-header {
        padding: 1rem 1.5rem;
        padding-left: 4rem; /* Espacio para botón menu */
    }
    
    #page-title {
        font-size: 1.5rem;
    }
    
    .header-actions {
        gap: 1rem;
    }
    
    .current-date {
        display: none;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .section {
        padding: 1.5rem;
    }
    
    .card {
        padding: 1.5rem;
    }
    
    .stat-number {
        font-size: 2.5rem;
    }
    
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        min-width: 600px;
    }
    
    .modal {
        width: 95%;
        max-width: 500px;
        margin: 1rem auto;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.875rem;
        min-height: 44px; /* Accesibilidad touch */
    }
    
    .btn-lg {
        padding: 0.875rem 1.75rem;
        font-size: 1rem;
        min-height: 48px;
    }
    
    /* Mejorar formularios en tablet */
    .form-input,
    .form-select,
    .form-textarea {
        min-height: 44px;
        font-size: 16px; /* Evitar zoom en iOS */
    }
    
    /* Cards más compactas */
    .activity-item {
        padding: 0.75rem;
    }
    
    .activity-item .activity-time {
        font-size: 0.75rem;
    }
}

/* Mobile Landscape */
@media (max-width: 640px) {
    .top-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
        padding: 1rem;
        padding-left: 4rem;
    }
    
    .header-actions {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .card-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .card-header .btn {
        width: 100%;
        justify-content: center;
    }
    
    .card-footer {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .form-group {
        margin-bottom: 1rem;
    }
    
    .btn {
        justify-content: center;
        width: 100%;
        min-height: 48px;
    }
    
    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.875rem;
    }
    
    /* Ocultar algunas columnas en mobile */
    .table th:nth-child(n+4),
    .table td:nth-child(n+4) {
        display: none;
    }
    
    .table th:nth-child(1),
    .table td:nth-child(1),
    .table th:nth-child(2),
    .table td:nth-child(2),
    .table th:last-child,
    .table td:last-child {
        display: table-cell;
    }
    
    /* Mejorar modales en landscape mobile */
    .modal {
        width: 100%;
        margin: 0.5rem;
        max-height: 95vh;
    }
    
    .modal .card-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    .modal .card-header .btn {
        width: auto;
        min-width: 44px;
    }
    
    /* Formulario en dos columnas cuando hay espacio */
    .form-row {
        display: flex;
        gap: 1rem;
        flex-wrap: wrap;
    }
    
    .form-row .form-group {
        flex: 1;
        min-width: 200px;
    }
}

/* Mobile Portrait */
@media (max-width: 480px) {
    .section {
        padding: 1rem;
    }
    
    .card {
        padding: 1rem;
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    .stat-label {
        font-size: 0.75rem;
    }
    
    #page-title {
        font-size: 1.25rem;
        text-align: center;
    }
    
    .top-header {
        padding: 0.75rem;
        padding-left: 4rem;
    }
    
    .sidebar-header {
        padding: 1.5rem 1rem;
    }
    
    .sidebar-header h2 {
        font-size: 1.25rem;
    }
    
    .menu-item {
        padding: 1rem;
        font-size: 0.875rem;
        min-height: 48px;
        display: flex;
        align-items: center;
    }
    
    .menu-item i {
        width: 20px;
        margin-right: 0.75rem;
    }
    
    .table {
        min-width: 300px;
    }
    
    .table th,
    .table td {
        padding: 0.5rem 0.25rem;
        font-size: 0.75rem;
    }
    
    /* Modal fullscreen en portrait mobile */
    .modal {
        width: 100%;
        height: 100%;
        margin: 0;
        border-radius: 0;
        max-height: 100vh;
        display: flex;
        flex-direction: column;
    }
    
    .modal .card {
        height: 100%;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }
    
    .modal .card-content {
        flex: 1;
        overflow-y: auto;
        padding: 1rem;
    }
    
    .modal .card-header {
        padding: 1rem;
        border-bottom: 1px solid var(--border-color);
        flex-shrink: 0;
    }
    
    .modal .card-footer {
        padding: 1rem;
        border-top: 1px solid var(--border-color);
        flex-shrink: 0;
        background: var(--background-color);
    }
    
    /* Optimizar formularios para mobile portrait */
    .form-input,
    .form-select,
    .form-textarea {
        font-size: 16px; /* Evitar zoom en iOS */
        padding: 0.75rem;
        min-height: 48px;
    }
    
    .form-label {
        font-size: 0.875rem;
        font-weight: 600;
    }
    
    /* Botones más grandes para touch */
    .btn {
        min-height: 48px;
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
        border-radius: 8px;
    }
    
    .btn-sm {
        min-height: 40px;
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
    
    /* Stats grid en mobile portrait */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .stat-card {
        text-align: center;
    }
    
    /* Actividades más compactas */
    .activity-list {
        max-height: 200px;
    }
    
    .activity-item {
        padding: 0.5rem;
        font-size: 0.875rem;
    }
    
    .activity-item .activity-time {
        font-size: 0.75rem;
    }
    
    /* Ocultar elementos no esenciales */
    .table th:nth-child(n+3),
    .table td:nth-child(n+3) {
        display: none;
    }
    
    .table th:last-child,
    .table td:last-child {
        display: table-cell;
    }
    
    /* Header más compacto */
    .header-actions {
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    
    .header-actions .btn {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
        min-width: auto;
        white-space: nowrap;
    }
    
    .header-actions .btn i {
        margin-right: 0.5rem;
    }
    
    .header-actions .form-select {
        min-width: 150px;
        font-size: 0.875rem;
    }
}

/* Menu Toggle Button for Mobile */
@media (max-width: 768px) {
    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 1rem;
        left: 1rem;
        z-index: 1002;
        background: var(--primary-color);
        color: white;
        border: none;
        border-radius: 8px;
        width: 48px;
        height: 48px;
        font-size: 1.25rem;
        box-shadow: var(--box-shadow);
        cursor: pointer;
        transition: var(--transition);
    }
    
    .menu-toggle:hover {
        background: var(--primary-hover);
        transform: scale(1.05);
        box-shadow: var(--box-shadow-lg);
    }
    
    .menu-toggle:active {
        transform: scale(0.95);
    }
    
    .menu-toggle.open {
        background: var(--danger-color);
    }
    
    .menu-toggle.open:hover {
        background: var(--danger-hover);
    }
    
    /* Sidebar overlay para cerrar al tocar fuera */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    .sidebar.open + .sidebar-overlay {
        display: block;
        opacity: 1;
    }
}

/* Hide menu toggle on desktop */
@media (min-width: 769px) {
    .menu-toggle {
        display: none !important;
    }
    
    .sidebar-overlay {
        display: none !important;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .menu-toggle,
    .btn,
    .modal-overlay {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .section {
        padding: 1rem 0;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000;
        --text-secondary: #000;
        --background-color: #fff;
        --card-background: #fff;
    }
    
    .card {
        border: 2px solid #000;
    }
    
    .btn {
        border: 2px solid;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .sidebar,
    .modal-overlay,
    .btn:hover,
    .card:hover {
        transition: none;
        transform: none;
    }
}

/* Touch improvements for all devices */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        padding: 0.75rem 1rem;
    }
    
    .menu-item {
        min-height: 48px;
        padding: 0.875rem 1rem;
    }
    
    .form-input,
    .form-select,
    .form-textarea {
        min-height: 44px;
        padding: 0.75rem;
    }
    
    /* Remove hover effects on touch devices */
    .btn:hover,
    .card:hover,
    .menu-item:hover {
        transform: none;
        box-shadow: inherit;
    }
    
    /* Add better focus indicators */
    .btn:focus,
    .form-input:focus,
    .form-select:focus,
    .menu-item:focus {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }
}