/**
 * Estilos Responsive para Módulo de Inventario
 * Sistema ERP - Optimizado para móviles, tablets y escritorio
 */

/* ===== VARIABLES RESPONSIVE ===== */
:root {
    --mobile-padding: 0.75rem;
    --tablet-padding: 1.25rem;
    --desktop-padding: 2rem;
}

/* ===== CONTENEDORES RESPONSIVE ===== */
.page-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--mobile-padding);
}

/* ===== TABLAS RESPONSIVE ===== */
.table-responsive-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive-wrapper::-webkit-scrollbar {
    height: 6px;
}

.table-responsive-wrapper::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

/* ===== GRIDS RESPONSIVE ===== */
.stats-grid,
.kpi-grid {
    display: grid;
    gap: 1rem;
}

.warehouse-grid {
    display: grid;
    gap: 1.5rem;
}

/* ===== MODALES RESPONSIVE ===== */
.modal-content,
.modal {
    width: 95%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-body {
    max-height: calc(90vh - 150px);
    overflow-y: auto;
}

/* ===== FORMULARIOS RESPONSIVE ===== */
.form-row {
    display: grid;
    gap: 1rem;
}

/* ===== FILTROS RESPONSIVE ===== */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

/* ===== NAVEGACIÓN RESPONSIVE ===== */
.module-nav,
.nav-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* ===== HEADER RESPONSIVE ===== */
.page-header,
.header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

/* ===== QUICK ACTIONS RESPONSIVE ===== */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

/* ===== MEDIA QUERIES - MOBILE-FIRST ===== */

/* Base móvil (todos los estilos de max-width: 575px movidos aquí) */
body {
    font-size: 14px;
}

/* Stats grid 1 columna base */
.stats-grid,
.kpi-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

.warehouse-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
}

.form-row {
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

/* Header ultra compacto base */
.page-header {
    flex-direction: column;
    padding: 0.5rem;
    gap: 0.5rem;
}

.header-left {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.page-title {
    font-size: 1rem;
    text-align: center;
}

.back-btn {
    padding: 0.4rem 0.6rem;
    font-size: 0.9rem;
}

.header-actions {
    width: 100%;
    flex-direction: column;
    gap: 0.5rem;
}

/* Botones full width base */
.btn,
.nav-btn,
.btn-action {
    width: 100%;
    justify-content: center;
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
}

/* Navegación stack vertical base */
.module-nav,
.nav-tabs {
    flex-direction: column;
    width: 100%;
    gap: 0.4rem;
}

.nav-tab,
.module-nav a,
.tab {
    width: 100%;
    text-align: center;
    padding: 0.6rem;
    font-size: 0.85rem;
}

/* Quick actions full width base */
.quick-actions {
    flex-direction: column;
    gap: 0.5rem;
}

.quick-action-btn {
    width: 100%;
    padding: 0.75rem 1rem;
}

.quick-action-icon {
    font-size: 1.25rem;
}

.quick-action-label {
    font-size: 0.85rem;
}

.quick-action-desc {
    font-size: 0.7rem;
}

/* Warehouse selector base */
.warehouse-selector {
    width: 100%;
}

.warehouse-selector select {
    width: 100%;
    min-width: auto;
}

/* Filtros compactos base */
.filters-bar {
    flex-direction: column;
    padding: 0.5rem;
    gap: 0.5rem;
}

.filter-group {
    width: 100%;
}

.filter-group label {
    font-size: 0.7rem;
}

.filter-group input,
.filter-group select {
    width: 100%;
    padding: 0.5rem;
    font-size: 0.85rem;
}

/* Modales full screen base */
.modal-content,
.modal {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
    padding: 0.75rem;
}

.modal-header {
    padding: 0.75rem;
}

.modal-header h2,
.modal-title {
    font-size: 1rem;
}

.modal-body {
    padding: 0.75rem;
    max-height: calc(100vh - 130px);
}

.modal-footer {
    padding: 0.75rem;
    flex-direction: column;
    gap: 0.5rem;
}

.modal-footer .btn {
    width: 100%;
}

/* Ocultar columnas base */
.hide-xs,
.hide-mobile {
    display: none !important;
}

/* Tablas super compactas base */
table {
    font-size: 0.8rem;
}

table th,
table td {
    padding: 0.5rem 0.3rem;
}

/* Badge más pequeño base */
.badge,
.movement-type-badge,
.movement-status {
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
}

/* Stats cards compactos base */
.stat-card {
    padding: 0.75rem;
}

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

.stat-card h3 {
    font-size: 0.7rem;
    margin-bottom: 0.5rem;
}

.stat-card .label {
    font-size: 0.75rem;
}

/* KPI cards compactos base */
.kpi-card {
    padding: 0.75rem;
    gap: 0.75rem;
}

.kpi-value {
    font-size: 1.15rem;
}

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

.kpi-subtext {
    font-size: 0.65rem;
}

.kpi-icon {
    width: 36px;
    height: 36px;
    font-size: 0.9rem;
}

/* Warehouse cards base */
.warehouse-card {
    padding: 1rem;
}

.warehouse-card h3 {
    font-size: 1.1rem;
}

.warehouse-card .code {
    font-size: 0.95rem;
}

.warehouse-card .info {
    font-size: 0.85rem;
}

.warehouse-card .actions {
    flex-direction: column;
    gap: 0.4rem;
}

.warehouse-card .actions .btn {
    width: 100%;
}

/* Detail grid base */
.detail-grid {
    grid-template-columns: 1fr;
}

/* Tabs compactos base */
.tabs {
    flex-direction: column;
    gap: 0.4rem;
}

.tab {
    width: 100%;
    text-align: center;
}

/* Empty state base */
.empty-state {
    padding: 2rem 1rem;
}

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

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

/* Pagination compacta base */
.pagination {
    flex-wrap: wrap;
    gap: 0.3rem;
}

.pagination button {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
}

/* Product cell en tabla base */
.product-cell {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
}

.product-icon {
    display: none;
}

.product-name {
    font-size: 0.85rem;
}

.product-sku {
    font-size: 0.7rem;
}

/* Search bar base */
.search-bar input {
    font-size: 0.9rem;
    padding: 0.6rem 0.75rem;
}

/* Charts base */
.chart-body {
    height: 250px;
}

.chart-header h3 {
    font-size: 0.9rem;
}

/* Date filter base */
.date-filter {
    flex-direction: column;
    width: 100%;
}

.date-filter input {
    width: 100%;
}

/* ===== MÓVIL GRANDE (640px+) ===== */
@media (min-width: 640px) {
    body {
        font-size: 15px;
    }

    .page-container {
        padding: var(--mobile-padding);
    }

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

    /* Header compacto */
    .page-header {
        padding: 0.75rem;
    }

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

    .header-actions {
        justify-content: center;
    }

    /* Botones */
    .btn,
    .nav-btn {
        width: auto;
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    /* Navegación horizontal scroll */
    .module-nav,
    .nav-tabs {
        flex-direction: row;
        overflow-x: auto;
        flex-wrap: nowrap;
        gap: 0.4rem;
        padding: 0.5rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .module-nav::-webkit-scrollbar,
    .nav-tabs::-webkit-scrollbar {
        display: none;
    }

    .nav-tab,
    .module-nav a {
        width: auto;
        flex-shrink: 0;
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        white-space: nowrap;
    }

    /* Warehouse selector */
    .warehouse-selector {
        width: auto;
        justify-content: center;
    }

    .warehouse-selector select {
        width: auto;
        min-width: 120px;
        font-size: 0.8rem;
    }

    /* Filtros */
    .filters-bar {
        padding: 0.75rem;
    }

    /* Modales */
    .modal-content,
    .modal {
        width: 98%;
        height: auto;
        max-height: 90vh;
        margin: 0.5rem;
        border-radius: 8px;
        padding: 1rem;
    }

    .modal-header h2,
    .modal-title {
        font-size: 1.1rem;
    }

    /* Mostrar columnas SM */
    .hide-sm {
        display: revert !important;
    }

    /* Tablas compactas */
    table {
        font-size: 0.85rem;
    }

    table th,
    table td {
        padding: 0.6rem 0.4rem;
    }

    /* Stats cards */
    .stat-card {
        padding: 1rem;
    }

    .stat-card .value {
        font-size: 1.75rem;
    }

    .stat-card h3 {
        font-size: 0.75rem;
    }

    /* KPI cards */
    .kpi-card {
        padding: 1rem;
    }

    .kpi-value {
        font-size: 1.25rem;
    }

    .kpi-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    /* Product cell */
    .product-icon {
        display: block;
    }
}

/* ===== TABLET (768px+) ===== */
@media (min-width: 768px) {
    body {
        font-size: 16px;
    }

    .page-container {
        padding: var(--tablet-padding);
    }

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

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

    /* Header */
    .page-header {
        flex-direction: row;
        align-items: center;
        gap: 0.75rem;
    }

    .header-left {
        flex-direction: row;
    }

    .page-title {
        text-align: left;
    }

    .header-actions {
        width: auto;
        flex-direction: row;
        justify-content: flex-end;
    }

    /* Navegación scrollable */
    .module-nav,
    .nav-tabs {
        padding-bottom: 0.5rem;
    }

    .module-nav::-webkit-scrollbar,
    .nav-tabs::-webkit-scrollbar {
        display: block;
        height: 4px;
    }

    .nav-tab,
    .module-nav a {
        font-size: 0.85rem;
        padding: 0.6rem 1rem;
    }

    /* Modales */
    .modal-content,
    .modal {
        width: 95%;
        padding: 1.25rem;
    }

    /* Quick actions en fila */
    .quick-actions {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .quick-action-btn {
        width: auto;
        flex: 1 1 calc(50% - 0.5rem);
        min-width: 180px;
    }

    /* Filtros en fila */
    .filters-bar {
        flex-direction: row;
    }

    .filter-group {
        width: auto;
    }

    /* Mostrar columnas MD */
    .hide-md,
    .hide-tablet {
        display: revert !important;
    }

    /* Tablas */
    table {
        font-size: 0.9rem;
    }

    table th,
    table td {
        padding: 0.75rem 0.5rem;
    }

    /* Modal footer */
    .modal-footer {
        flex-direction: row;
    }

    .modal-footer .btn {
        width: auto;
    }

    /* Warehouse card actions */
    .warehouse-card .actions {
        flex-direction: row;
    }

    .warehouse-card .actions .btn {
        width: auto;
    }

    /* Tabs en fila */
    .tabs {
        flex-direction: row;
    }

    .tab {
        width: auto;
    }
}

/* ===== TABLET GRANDE (1024px+) ===== */
@media (min-width: 1024px) {
    .page-container {
        padding: var(--tablet-padding);
    }

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

    .form-row {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Mostrar columnas LG */
    .hide-lg {
        display: revert !important;
    }
}

/* ===== DESKTOP (1280px+) ===== */
@media (min-width: 1280px) {
    .page-container {
        padding: var(--desktop-padding);
    }

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

    .warehouse-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .form-row {
        grid-template-columns: repeat(2, 1fr);
    }

    table {
        font-size: 1rem;
    }

    table th,
    table td {
        padding: 1rem 0.75rem;
    }
}

/* ===== DESKTOP GRANDE (1400px+) ===== */
@media (min-width: 1400px) {
    .stats-grid,
    .kpi-grid {
        grid-template-columns: repeat(5, 1fr);
    }

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

    .form-row {
        grid-template-columns: repeat(3, 1fr);
    }
}

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

/* Texto responsive */
.text-responsive {
    font-size: clamp(0.875rem, 2vw, 1rem);
}

.heading-responsive {
    font-size: clamp(1.25rem, 4vw, 2rem);
}

/* Espaciado responsive */
.p-responsive {
    padding: clamp(0.5rem, 2vw, 2rem);
}

.m-responsive {
    margin: clamp(0.5rem, 2vw, 2rem);
}

/* Ocultar/mostrar por breakpoint - Mobile-First */
.desktop-only {
    display: none !important;
}

.mobile-only {
    display: block !important;
}

@media (min-width: 1024px) {
    .desktop-only {
        display: block !important;
    }

    .mobile-only {
        display: none !important;
    }
}

/* Scroll horizontal para tablas */
.table-scroll {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Fix para inputs en iOS */
@supports (-webkit-touch-callout: none) {
    input,
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* Accesibilidad táctil */
@media (pointer: coarse) {
    .btn,
    .nav-tab,
    .tab,
    button {
        min-height: 44px;
        min-width: 44px;
    }

    input,
    select {
        min-height: 44px;
    }
}

/* Print styles */
@media print {
    .page-header,
    .module-nav,
    .nav-tabs,
    .header-actions,
    .quick-actions,
    .filters-bar,
    .btn,
    .modal {
        display: none !important;
    }

    .page-container {
        padding: 0;
        max-width: 100%;
    }

    .hide-print {
        display: none !important;
    }
}
