/* =============================================
   PROASSETS - Template Responsive CSS
   VERSIÓN: 2.0.0 COMPLETAMENTE NUEVO
   Media queries optimizadas y sin conflictos
   ============================================= */

/* =============================================
   1. DISPOSITIVOS MUY GRANDES (≥1400px)
   ============================================= */
@media (min-width: 1400px) {
    .app-content {
        padding: 2rem;
        max-width: 1400px;
        margin: 0 auto;
    }
    
    .navbar-left,
    .navbar-right {
        gap: 1.5rem;
    }
}

/* =============================================
   2. DISPOSITIVOS GRANDES (1200px - 1399px)
   ============================================= */
@media (min-width: 1200px) and (max-width: 1399.98px) {
    .app-content {
        padding: 1.75rem;
    }
    
    .card {
        margin-bottom: 1.75rem;
    }
}

/* =============================================
   3. TABLETS HORIZONTALES (992px - 1199px)
   ============================================= */
@media (min-width: 992px) and (max-width: 1199.98px) {
    :root {
        --sidebar-width: 220px;
        --sidebar-collapsed: 65px;
    }
    
    .app-navbar {
        padding: 0 1.25rem;
    }
    
    .app-content {
        padding: 1.5rem;
        font-size: 0.9875rem; /* Ligeramente reducido pero legible */
    }
    
    /* Sidebar ajustado */
    .sidebar-brand {
        padding: 0.875rem 1rem;
    }
    
    .sidebar-brand-img {
        height: 36px;
    }
    
    .user-panel {
        padding: 1rem 0.75rem;
    }
    
    .user-image {
        width: 44px;
        height: 44px;
    }
    
    .user-name {
        font-size: 0.95rem;
    }
    
    .user-role {
        font-size: 0.85rem;
    }
    
    .nav-item > .nav-link {
        padding: 0.75rem 0.875rem;
        font-size: 0.95rem;
    }
    
    .nav-treeview .nav-link {
        padding: 0.625rem 0.875rem 0.625rem 2.5rem;
        font-size: 0.9rem;
    }
    
    /* Componentes ajustados */
    .card-header,
    .card-body {
        padding: 1rem;
    }
    
    .table th,
    .table td {
        padding: 0.75rem;
    }
}

/* =============================================
   4. TABLETS VERTICALES (768px - 991px)
   ============================================= */
@media (min-width: 768px) and (max-width: 991.98px) {
    :root {
        --sidebar-width: 200px;
        --sidebar-collapsed: 60px;
    }
    
    .app-navbar {
        padding: 0 1rem;
        height: 58px;
    }
    
    .navbar-left,
    .navbar-right {
        gap: 0.75rem;
    }
    
    .sidebar-toggle {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }
    
    .brand-image {
        height: 32px;
    }
    
    .app-content {
        padding: 1.25rem;
        font-size: 0.975rem;
        min-height: calc(100vh - 58px - var(--footer-height));
    }
    
    /* Sidebar más compacto */
    .sidebar-brand {
        padding: 0.75rem 0.875rem;
        min-height: 58px;
    }
    
    .sidebar-brand-img {
        height: 34px;
    }
    
    .user-panel {
        padding: 0.875rem 0.625rem;
        margin-bottom: 1rem;
    }
    
    .user-image {
        width: 40px;
        height: 40px;
    }
    
    .user-name {
        font-size: 0.93rem;
    }
    
    .user-role {
        font-size: 0.82rem;
        padding: 0.3rem 0.6rem;
    }
    
    .nav-item > .nav-link {
        padding: 0.625rem 0.75rem;
        font-size: 0.93rem;
    }
    
    .nav-item > .nav-link i:first-child {
        margin-right: 0.75rem;
        font-size: 1.05rem;
    }
    
    .nav-treeview .nav-link {
        padding: 0.5rem 0.75rem 0.5rem 2.25rem;
        font-size: 0.88rem;
    }
    
    /* Footer ajustado */
    .app-footer {
        padding: 0.875rem 1.25rem;
        font-size: 0.95rem;
    }
}

/* =============================================
   5. MÓVILES GRANDES (576px - 767px)
   ============================================= */
@media (min-width: 576px) and (max-width: 767.98px) {
    body {
        font-size: 0.95rem;
    }
    
    .app-container {
        flex-direction: column;
    }
    
    /* Sidebar móvil */
    .app-sidebar {
        transform: translateX(-100%);
        width: 280px;
        z-index: 1040;
        box-shadow: var(--shadow-lg);
    }
    
    .app-sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .app-sidebar.collapsed {
        width: 280px; /* No colapsa en móvil */
    }
    
    /* Contenido principal */
    .app-main-wrapper {
        margin-left: 0 !important;
        width: 100%;
    }
    
    /* Navbar móvil */
    .app-navbar {
        padding: 0 0.875rem;
        height: 56px;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1035;
    }
    
    .navbar-content {
        padding: 0 0.375rem;
    }
    
    .sidebar-toggle {
        width: 34px;
        height: 34px;
    }
    
    .brand-image {
        height: 30px;
    }
    
    /* Ocultar logo del cliente en móvil */
    .navbar-right .brand-image:last-child {
        display: none;
    }
    
    /* Ajustar contenido para navbar fijo */
    .app-content {
        padding: 1rem;
        margin-top: 56px;
        min-height: calc(100vh - 116px); /* 56px navbar + 60px footer */
        font-size: 0.95rem;
    }
    
    /* Footer móvil */
    .app-footer {
        margin-left: 0 !important;
        padding: 1rem;
        text-align: center;
        height: auto;
        min-height: 60px;
        font-size: 0.95rem;
    }
    
    /* Sidebar en móvil */
    .sidebar-brand {
        padding: 0.875rem;
        min-height: 56px;
    }
    
    .sidebar-brand-img {
        height: 32px;
    }
    
    .user-panel {
        margin: 0.875rem;
        padding: 0.875rem;
        border-radius: var(--border-radius);
        background-color: var(--color-white);
        box-shadow: var(--shadow-sm);
    }
    
    .user-name {
        font-size: 0.95rem;
    }
    
    .user-role {
        font-size: 0.85rem;
    }
    
    .nav-item > .nav-link {
        padding: 0.75rem;
        font-size: 0.95rem;
    }
    
    .nav-treeview .nav-link {
        padding: 0.625rem 0.75rem 0.625rem 2.5rem;
        font-size: 0.9rem;
    }
    
    /* Mostrar overlay móvil */
    .mobile-overlay.show {
        display: block;
    }
    
    /* Cards móviles */
    .card {
        margin-bottom: 1rem;
    }
    
    .card-header {
        padding: 0.875rem;
        font-size: 1.05rem;
    }
    
    .card-body {
        padding: 0.875rem;
        font-size: 0.95rem;
    }
    
    /* Botones full width */
    .btn {
        width: 100%;
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
}

/* =============================================
   6. MÓVILES PEQUEÑOS (375px - 575px)
   ============================================= */
@media (min-width: 375px) and (max-width: 575.98px) {
    body {
        font-size: 0.9375rem;
    }
    
    .app-navbar {
        padding: 0 0.75rem;
        height: 54px;
    }
    
    .sidebar-toggle {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
    
    .brand-image {
        height: 28px;
    }
    
    .app-content {
        padding: 0.875rem;
        margin-top: 54px;
        min-height: calc(100vh - 114px); /* 54px navbar + 60px footer */
        font-size: 0.9375rem;
    }
    
    .app-footer {
        padding: 0.875rem;
        font-size: 0.9375rem;
    }
    
    /* Sidebar más estrecho */
    .app-sidebar {
        width: 260px;
    }
    
    .sidebar-brand {
        padding: 0.75rem;
    }
    
    .sidebar-brand-img {
        height: 30px;
    }
    
    /* User panel más compacto */
    .user-panel {
        padding: 0.75rem;
        margin: 0.75rem;
    }
    
    .user-panel-content {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }
    
    .user-image {
        width: 48px;
        height: 48px;
    }
    
    .user-name {
        font-size: 0.95rem;
    }
    
    .user-role {
        font-size: 0.85rem;
    }
    
    /* Menú más compacto */
    .nav-item > .nav-link {
        padding: 0.625rem 0.75rem;
        font-size: 0.93rem;
    }
    
    .nav-treeview .nav-link {
        padding: 0.5rem 0.625rem 0.5rem 2.25rem;
        font-size: 0.88rem;
    }
    
    /* Tablas responsivas */
    .table-responsive {
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius);
        overflow: hidden;
    }
    
    .table {
        font-size: 0.9rem;
        min-width: 600px;
    }
}

/* =============================================
   7. MÓVILES MUY PEQUEÑOS (≤374px)
   ============================================= */
@media (max-width: 374.98px) {
    body {
        font-size: 0.925rem;
    }
    
    .app-navbar {
        padding: 0 0.5rem;
        height: 52px;
    }
    
    .sidebar-toggle {
        width: 30px;
        height: 30px;
        font-size: 0.9375rem;
    }
    
    .brand-image {
        height: 26px;
    }
    
    .app-content {
        padding: 0.75rem;
        margin-top: 52px;
        min-height: calc(100vh - 112px); /* 52px navbar + 60px footer */
        font-size: 0.925rem;
    }
    
    .app-footer {
        padding: 0.75rem;
        font-size: 0.925rem;
    }
    
    .app-sidebar {
        width: 240px;
    }
    
    .sidebar-brand {
        padding: 0.625rem;
    }
    
    .sidebar-brand-img {
        height: 28px;
    }
    
    .user-name {
        font-size: 0.93rem;
    }
    
    .user-role {
        font-size: 0.83rem;
    }
    
    .nav-item > .nav-link {
        font-size: 0.92rem;
        padding: 0.5rem 0.625rem;
    }
    
    .nav-treeview .nav-link {
        font-size: 0.87rem;
        padding: 0.375rem 0.5rem 0.375rem 2rem;
    }
}

/* =============================================
   8. MODO LANDSCAPE EN MÓVILES
   ============================================= */
@media (max-width: 991.98px) and (orientation: landscape) {
    .app-sidebar {
        width: 240px;
    }
    
    .sidebar-content {
        padding: 0.5rem;
    }
    
    .user-panel {
        padding: 0.75rem;
        margin: 0.75rem 0.5rem;
    }
    
    .user-image {
        width: 36px;
        height: 36px;
    }
    
    .user-name {
        font-size: 0.9rem;
    }
    
    .user-role {
        font-size: 0.8rem;
        padding: 0.2rem 0.4rem;
    }
    
    .nav-item > .nav-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
    
    .nav-treeview .nav-link {
        padding: 0.375rem 0.5rem 0.375rem 2rem;
        font-size: 0.85rem;
    }
    
    .app-content {
        padding: 0.875rem;
        font-size: 0.9375rem;
    }
}

/* =============================================
   9. IMPRESIÓN
   ============================================= */
@media print {
    .app-sidebar,
    .app-navbar,
    .app-footer,
    .sidebar-toggle,
    .btn,
    .no-print {
        display: none !important;
    }
    
    .app-main-wrapper {
        margin-left: 0 !important;
    }
    
    body {
        background: white !important;
        color: black !important;
        font-size: 12pt !important;
        line-height: 1.5 !important;
    }
    
    .app-content {
        padding: 0 !important;
        margin-top: 0 !important;
        min-height: auto !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        break-inside: avoid;
        margin-bottom: 1cm !important;
    }
    
    .table {
        border: 1px solid #ddd !important;
        font-size: 10pt !important;
    }
    
    a {
        color: black !important;
        text-decoration: none !important;
    }
    
    /* Evitar cortes de página en elementos importantes */
    h1, h2, h3 {
        page-break-after: avoid;
    }
    
    table {
        page-break-inside: avoid;
    }
}

/* =============================================
   10. MODO ALTO CONTRASTE
   ============================================= */
@media (prefers-contrast: high) {
    :root {
        --color-primary: #006400;
        --color-text-dark: #000000;
        --border-color: #000000;
        --color-gray-100: #ffffff;
    }
    
    .app-sidebar {
        border: 2px solid #000;
    }
    
    .nav-item > .nav-link.active {
        border: 2px solid #000;
        background-color: #f0f0f0;
    }
    
    .btn-primary {
        border: 2px solid #000;
    }
    
    body {
        font-weight: 500;
    }
}

/* =============================================
   11. REDUCED MOTION
   ============================================= */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .fade-in {
        animation: none !important;
    }
    
    .nav-treeview {
        transition: none !important;
    }
    
    .app-sidebar {
        transition: none !important;
    }
    
    .app-main-wrapper,
    .app-footer {
        transition: none !important;
    }
}