/**
 * Estilos responsivos - Adaptaciones para diferentes tamaños de pantalla
 * Mobile first approach
 *
 * Autor: Sistema Finanzas
 * Fecha: 2025-10-26
 */

/* ========== BREAKPOINTS ========== */
/*
 * xs: < 576px   (móviles en vertical)
 * sm: ≥ 576px   (móviles en horizontal)
 * md: ≥ 768px   (tablets)
 * lg: ≥ 992px   (laptops)
 * xl: ≥ 1200px  (desktops)
 * xxl: ≥ 1400px (pantallas grandes)
 */

/* ========== MÓVILES (< 768px) ========== */
@media (max-width: 767.98px) {

    /* Sidebar móvil */
    .sidebar {
        width: var(--sidebar-width);
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
    }

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

    /* Main content sin margen en móvil */
    .main-content {
        margin-left: 0;
    }

    /* Overlay oscuro cuando el sidebar está abierto */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
    }

    .sidebar-overlay.show {
        display: block;
    }

    /* Header móvil */
    .top-header {
        padding: 0 var(--spacing-md);
    }

    .page-title {
        font-size: 1.2rem;
    }

    /* Botón hamburguesa en móvil */
    .mobile-menu-toggle {
        display: block;
        background: transparent;
        border: none;
        font-size: 1.5rem;
        color: var(--color-dark);
        cursor: pointer;
        padding: var(--spacing-sm);
        margin-right: var(--spacing-sm);
    }

    /* User menu más compacto */
    .user-menu {
        gap: var(--spacing-xs);
    }

    .user-name {
        display: none;
    }

    /* Content area con menos padding */
    .content-area {
        padding: var(--spacing-md);
    }

    /* Cards más compactas */
    .card-body {
        padding: var(--spacing-md);
    }

    /* Tablas responsivas */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table {
        font-size: 0.85rem;
    }

    .table thead th,
    .table tbody td {
        padding: var(--spacing-sm);
    }

    /* Métricas apiladas */
    .metric-card {
        margin-bottom: var(--spacing-md);
    }

    .metric-value {
        font-size: 1.5rem;
    }

    /* Botones de acción más grandes para tocar */
    .btn {
        padding: 0.6rem 1.2rem;
        font-size: 0.95rem;
    }

    /* Formularios */
    .form-control,
    .form-select {
        font-size: 16px; /* Evita zoom en iOS */
    }
}

/* ========== TABLETS (768px - 991px) ========== */
@media (min-width: 768px) and (max-width: 991.98px) {

    /* Sidebar más estrecho en tablets */
    .sidebar {
        width: 200px;
    }

    .main-content {
        margin-left: 200px;
    }

    .sidebar-header {
        padding: var(--spacing-md);
    }

    .logo-text {
        font-size: 1.2rem;
    }

    .nav-link {
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: 0.9rem;
    }

    /* Content con padding medio */
    .content-area {
        padding: var(--spacing-md) var(--spacing-lg);
    }
}

/* ========== DESKTOPS GRANDES (≥ 1400px) ========== */
@media (min-width: 1400px) {

    /* Contenido con ancho máximo para pantallas muy grandes */
    .content-area .container-fluid {
        max-width: 1600px;
        margin: 0 auto;
    }

    /* Fuentes ligeramente más grandes */
    :root {
        --font-size-base: 15px;
    }

    /* Sidebar más ancho */
    .sidebar {
        width: 280px;
    }

    .main-content {
        margin-left: 280px;
    }
}

/* ========== LANDSCAPE EN MÓVILES ========== */
@media (max-width: 767.98px) and (orientation: landscape) {

    /* Sidebar más estrecho en landscape */
    .sidebar {
        width: 220px;
    }

    /* Header más compacto */
    .top-header {
        height: 60px;
    }
}

/* ========== IMPRESIÓN ========== */
@media print {

    /* Ocultar sidebar y header en impresión */
    .sidebar,
    .top-header,
    .main-footer,
    .btn,
    .user-menu {
        display: none !important;
    }

    /* Main content ocupa todo el ancho */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }

    /* Eliminar sombras y fondos */
    .card,
    .metric-card {
        box-shadow: none !important;
        border: 1px solid #ddd;
    }

    /* Forzar colores de texto oscuros */
    body,
    .card,
    .table {
        color: #000 !important;
        background: white !important;
    }

    /* Evitar saltos de página dentro de elementos */
    .card,
    .metric-card,
    .table tbody tr {
        page-break-inside: avoid;
    }
}

/* ========== PREFERENCIAS DE ACCESIBILIDAD ========== */

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

/* Alto contraste */
@media (prefers-contrast: high) {
    .nav-link {
        border: 1px solid rgba(255, 255, 255, 0.3);
    }

    .nav-link.active {
        border: 2px solid #3BAFDA;
    }

    .card {
        border: 1px solid #ddd;
    }
}

/* Modo oscuro (opcional - para implementación futura) */
@media (prefers-color-scheme: dark) {
    /* Aquí se pueden agregar estilos para dark mode si se desea */
    /* Por ahora, el sistema fuerza light mode */
}

/* ========== UTILIDADES RESPONSIVAS ========== */

/* Ocultar elementos según breakpoint */
@media (max-width: 767.98px) {
    .hide-mobile { display: none !important; }
}

@media (min-width: 768px) {
    .hide-tablet { display: none !important; }
    .mobile-menu-toggle { display: none; }
}

@media (min-width: 992px) {
    .hide-desktop { display: none !important; }
}

/* Mostrar elementos según breakpoint */
.show-mobile { display: none !important; }
@media (max-width: 767.98px) {
    .show-mobile { display: block !important; }
}

/* Grid responsivo personalizado */
@media (max-width: 767.98px) {
    .row-mobile-stack > [class*="col-"] {
        width: 100%;
        margin-bottom: var(--spacing-md);
    }
}
