/* ============================================================================
 * RESPONSIVE GLOBAL - Sistema Responsivo Unificado
 * Archivo: static/css/responsive-global.css
 *
 * Breakpoints:
 * - xs: < 480px (móvil pequeño)
 * - sm: 480px - 640px (móvil)
 * - md: 640px - 768px (móvil grande / tablet pequeña)
 * - lg: 768px - 1024px (tablet)
 * - xl: 1024px - 1280px (desktop pequeño)
 * - 2xl: > 1280px (desktop)
 * ============================================================================ */

/* ==================== BASE RESPONSIVE ==================== */

/* Asegurar que todo respete el viewport */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    min-width: 320px;
    overflow-x: hidden;
}

/* Imágenes responsivas por defecto */
img,
video,
iframe {
    max-width: 100%;
    height: auto;
}

/* ==================== CONTENEDORES RESPONSIVOS ==================== */

.container,
.compact-container,
.content-container {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

@media (min-width: 640px) {
    .container,
    .compact-container,
    .content-container {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .container,
    .compact-container,
    .content-container {
        padding-left: 2rem;
        padding-right: 2rem;
        max-width: 1400px;
    }
}

/* ==================== NAVEGACIÓN MÓVIL ==================== */

/* Overlay para cuando el menú está abierto */
.mobile-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;
}

.mobile-overlay.active {
    display: block;
    opacity: 1;
}

/* Header del menú móvil */
.mobile-nav-header {
    display: none;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    margin: -4rem -1.5rem 1rem;
    background: linear-gradient(135deg, #0049ff 0%, #0066ff 100%);
}

.mobile-nav-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: white;
}

.mobile-nav-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    font-size: 1.25rem;
    transition: background 0.2s;
}

.mobile-nav-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Menú hamburguesa */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    z-index: 1001;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
}

.hamburger-line {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text-primary, #1a1a1a);
    margin: 4px 0;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.mobile-menu-toggle.active .hamburger-line:nth-child(2) {
    opacity: 0;
    transform: translateX(-10px);
}

.mobile-menu-toggle.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
    }

    /* Mostrar header del menú móvil */
    .mobile-nav-header {
        display: flex;
    }

    /* Header ajustes móvil */
    .header-2050,
    header[class*="header"] {
        padding: 0.5rem 1rem !important;
    }

    .header-2050 .header-content {
        gap: 0.75rem;
    }

    .header-2050 .header-logo img,
    header .logo img,
    .logo-image {
        max-height: 50px !important;
        height: 50px !important;
    }

    /* Ocultar texto del logo en móvil pequeño */
    .logo-text {
        display: none;
    }

    /* Navegación colapsable */
    .header-nav,
    .header-menu-section,
    .main-nav,
    nav.header-navigation {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        background: #ffffff;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
        padding: 4rem 1.5rem 2rem;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1000;
        overflow-y: auto;
        display: flex !important;
        flex-direction: column;
        gap: 0.25rem;
    }

    .header-nav.active,
    .header-menu-section.active,
    .main-nav.active,
    nav.header-navigation.active {
        left: 0;
    }

    /* Links del menú móvil */
    .header-nav a,
    .header-menu-section a,
    .main-nav a,
    nav.header-navigation a,
    .nav-2050 a {
        display: block !important;
        padding: 0.875rem 1rem;
        border-radius: 8px;
        font-size: 0.95rem;
        color: #1a1a1a;
        text-decoration: none;
        transition: all 0.2s;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    }

    .header-nav a:hover,
    .header-menu-section a:hover,
    .main-nav a:hover {
        background: rgba(0, 73, 255, 0.08);
        color: #0049ff;
        transform: translateX(4px);
    }

    /* Dropdowns en menú móvil */
    .nav-dropdown {
        display: block;
    }

    .nav-dropdown-content {
        position: static !important;
        transform: none !important;
        display: none;
        box-shadow: none;
        border: none;
        background: rgba(0, 0, 0, 0.02);
        border-radius: 8px;
        margin-top: 0.25rem;
        padding-left: 1rem;
    }

    .nav-dropdown.open .nav-dropdown-content {
        display: block;
    }

    .nav-dropdown-btn {
        display: flex;
        justify-content: space-between;
        width: 100%;
        padding: 0.875rem 1rem;
    }

    /* User menu en móvil */
    .header-user,
    .user-menu {
        position: relative;
    }

    .user-menu-btn {
        min-width: auto;
        padding: 0.4rem 0.6rem;
    }

    .user-name-display {
        display: none;
    }

    /* Dropdown del usuario en móvil */
    .user-menu-dropdown {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-height: 75vh;
        border-radius: 16px 16px 0 0 !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15) !important;
        overflow-y: auto;
    }
}

/* ==================== TABLAS RESPONSIVAS ==================== */

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Modo card para tablas en móvil */
@media (max-width: 768px) {
    .neu-table,
    .table-responsive table,
    table.responsive-table {
        border: 0;
    }

    .neu-table thead,
    .table-responsive thead,
    table.responsive-table thead {
        display: none;
    }

    .neu-table tbody tr,
    .table-responsive tbody tr,
    table.responsive-table tbody tr {
        display: block;
        margin-bottom: 0.75rem;
        background: #fff;
        border-radius: 8px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        padding: 0.75rem;
    }

    .neu-table tbody td,
    .table-responsive tbody td,
    table.responsive-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
        border: none;
        border-bottom: 1px solid #f0f0f0;
        font-size: 0.875rem;
    }

    .neu-table tbody td:last-child,
    .table-responsive tbody td:last-child,
    table.responsive-table tbody td:last-child {
        border-bottom: none;
    }

    .neu-table tbody td::before,
    .table-responsive tbody td::before,
    table.responsive-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #64748b;
        font-size: 0.75rem;
        text-transform: uppercase;
        flex-shrink: 0;
        margin-right: 1rem;
    }

    /* Acciones en tabla móvil */
    .neu-table .action-buttons,
    .table-actions {
        justify-content: flex-end;
        gap: 0.5rem;
    }
}

/* Scroll horizontal hint */
.table-responsive::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(to left, rgba(255,255,255,0.9), transparent);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.table-responsive.has-scroll::after {
    opacity: 1;
}

/* ==================== FORMULARIOS RESPONSIVOS ==================== */

@media (max-width: 640px) {
    /* Inputs full width */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    input[type="date"],
    input[type="datetime-local"],
    input[type="search"],
    select,
    textarea,
    .neu-input,
    .neu-select,
    .form-control {
        width: 100% !important;
        font-size: 16px !important; /* Evita zoom en iOS */
    }

    /* Form groups en columna */
    .form-row,
    .form-group-row,
    .filter-row,
    .input-group {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    .form-row > *,
    .form-group-row > *,
    .filter-row > * {
        width: 100% !important;
        flex: none !important;
    }

    /* Labels */
    label,
    .form-label {
        font-size: 0.875rem;
        margin-bottom: 0.25rem;
    }

    /* Botones de formulario */
    .form-actions,
    .button-group,
    .submit-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }

    .form-actions button,
    .form-actions .btn,
    .form-actions a,
    .button-group button,
    .submit-buttons button,
    .submit-buttons a {
        width: 100%;
        justify-content: center;
    }

    /* Filter forms */
    .filters-form .filter-group {
        width: 100%;
    }

    .filter-actions {
        flex-direction: column;
        width: 100%;
    }

    .filter-actions button,
    .filter-actions a {
        width: 100%;
    }
}

/* ==================== GRIDS Y CARDS RESPONSIVOS ==================== */

/* Grid auto-responsive */
.grid-auto,
.cursos-grid,
.cards-grid,
.kpi-grid {
    display: grid;
    gap: 1rem;
}

@media (max-width: 480px) {
    .grid-auto,
    .cursos-grid,
    .cards-grid {
        grid-template-columns: 1fr !important;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .grid-auto,
    .cursos-grid,
    .cards-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .grid-auto,
    .cursos-grid,
    .cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }

    .kpi-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Cards */
@media (max-width: 640px) {
    .neu-card,
    .card,
    .kpi-card {
        padding: 1rem;
        border-radius: 8px;
    }

    .neu-card-header,
    .card-header {
        padding: 0.75rem 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .neu-card-title,
    .card-title {
        font-size: 0.9rem;
    }

    .kpi-card .kpi-value {
        font-size: 1.5rem;
    }

    .kpi-card .kpi-label {
        font-size: 0.65rem;
    }
}

/* ==================== LAYOUT DOS COLUMNAS ==================== */

.two-column-layout,
.dashboard-grid,
.report-grid,
.selection-grid {
    display: grid;
    gap: 1rem;
}

@media (max-width: 1024px) {
    .two-column-layout,
    .dashboard-grid,
    .report-grid,
    .selection-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ==================== PAGE HEADER RESPONSIVO ==================== */

@media (max-width: 640px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .page-header-left {
        width: 100%;
    }

    .page-icon {
        width: 40px !important;
        height: 40px !important;
        font-size: 1.25rem !important;
    }

    .page-title {
        font-size: 1.125rem !important;
    }

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

    .page-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .page-actions .neu-btn,
    .page-actions .btn {
        flex: 1;
        min-width: calc(50% - 0.25rem);
        justify-content: center;
        font-size: 0.75rem;
        padding: 0.5rem 0.75rem;
    }
}

/* ==================== BREADCRUMBS RESPONSIVOS ==================== */

@media (max-width: 640px) {
    .breadcrumbs-compact,
    .breadcrumb,
    nav[aria-label="breadcrumb"],
    nav[aria-label="Navegación"] {
        font-size: 0.7rem;
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }

    .breadcrumbs-compact a,
    .breadcrumb a {
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        display: inline-block;
        vertical-align: middle;
    }
}

/* ==================== BOTONES RESPONSIVOS ==================== */

@media (max-width: 480px) {
    .neu-btn,
    .btn,
    button {
        padding: 0.625rem 1rem;
        font-size: 0.8rem;
    }

    .neu-btn-sm,
    .btn-sm {
        padding: 0.375rem 0.625rem;
        font-size: 0.7rem;
    }

    /* Touch targets mínimos */
    .neu-btn,
    .btn,
    button,
    a.btn,
    .action-btn {
        min-height: 44px;
        min-width: 44px;
    }
}

/* ==================== MODALES RESPONSIVOS ==================== */

@media (max-width: 640px) {
    .modal,
    .modal-content,
    [class*="modal"] {
        margin: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        max-height: 100vh;
        border-radius: 0 !important;
    }

    .modal-header,
    .modal-footer {
        padding: 1rem;
    }

    .modal-body {
        padding: 1rem;
        max-height: calc(100vh - 140px);
        overflow-y: auto;
    }
}

/* ==================== NOTIFICACIONES RESPONSIVAS ==================== */

@media (max-width: 480px) {
    .toast-container,
    .notification-toast {
        left: 0.5rem !important;
        right: 0.5rem !important;
        max-width: none !important;
    }

    .notification-bell-dropdown {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-height: 70vh;
        border-radius: 16px 16px 0 0 !important;
    }
}

/* ==================== SIDEBAR/PANEL LATERAL ==================== */

@media (max-width: 1024px) {
    .sidebar,
    .side-panel,
    aside {
        position: fixed;
        top: 0;
        left: -100%;
        width: 280px;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        background: #fff;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }

    .sidebar.active,
    .side-panel.active {
        left: 0;
    }

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

/* ==================== SELECTION CARDS (INSCRIBIR FUNCIONARIOS) ==================== */

@media (max-width: 768px) {
    .selection-card {
        margin-bottom: 1rem;
    }

    .selection-list {
        max-height: 300px;
    }

    .selection-item {
        padding: 0.75rem;
    }

    .selection-item-badge {
        display: none; /* Ocultar badges en móvil para ahorrar espacio */
    }

    .group-filters {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }

    .group-chip {
        flex-shrink: 0;
    }

    .submit-section {
        flex-direction: column;
        gap: 1rem;
    }

    .submit-stats {
        width: 100%;
        justify-content: space-around;
    }

    .submit-buttons {
        width: 100%;
        flex-direction: column;
    }

    .submit-buttons .neu-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ==================== EMPTY STATES ==================== */

@media (max-width: 480px) {
    .empty-state {
        padding: 2rem 1rem;
    }

    .empty-state .empty-icon {
        font-size: 2rem;
    }

    .empty-state h4 {
        font-size: 1rem;
    }

    .empty-state p {
        font-size: 0.8rem;
    }
}

/* ==================== UTILIDADES RESPONSIVE ==================== */

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

/* Ocultar en desktop */
@media (min-width: 641px) {
    .hide-desktop,
    .mobile-only {
        display: none !important;
    }
}

/* Ocultar en tablet */
@media (min-width: 641px) and (max-width: 1024px) {
    .hide-tablet {
        display: none !important;
    }
}

/* Mostrar solo en tablet */
@media (max-width: 640px), (min-width: 1025px) {
    .tablet-only {
        display: none !important;
    }
}

/* Text alignment responsive */
@media (max-width: 640px) {
    .text-center-mobile {
        text-align: center !important;
    }

    .text-left-mobile {
        text-align: left !important;
    }
}

/* Spacing responsive */
@media (max-width: 640px) {
    .p-mobile-sm {
        padding: 0.5rem !important;
    }

    .m-mobile-0 {
        margin: 0 !important;
    }

    .gap-mobile-sm {
        gap: 0.5rem !important;
    }
}

/* ==================== SAFE AREAS (iOS NOTCH) ==================== */

@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }

    .header-2050,
    header {
        padding-top: max(0.5rem, env(safe-area-inset-top));
    }

    .mobile-nav,
    .bottom-nav {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

/* ==================== PRINT STYLES ==================== */

@media print {
    .mobile-menu-toggle,
    .header-nav,
    .sidebar,
    .page-actions,
    .submit-section,
    .filter-row,
    .no-print {
        display: none !important;
    }

    body {
        font-size: 12pt;
    }

    .neu-card,
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ==================== ANIMACIONES REDUCIDAS ==================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
