/* ============================================
   responsive.css — Media queries globales
   Se carga al final para pisar reglas anteriores
   ============================================ */

@media (max-width: 768px) {

    /* ── Header ── */
    .prov-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    /* ── Toolbar ── */
    .prov-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .prov-toolbar-left {
        flex-direction: column;
    }
    .prov-toolbar-right {
        justify-content: space-between;
    }
    .prov-buscador,
    .prov-search-wrap {
        max-width: 100% !important;
    }
    .prov-search-wrap input {
        width: 100% !important;
    }
    .prov-toolbar .btn-prov {
        width: 100%;
        justify-content: center;
    }
    .prov-toolbar .prov-export-group {
        width: 100%;
    }
    .prov-toolbar .prov-export-group .btn-prov {
        flex: 1;
    }

    /* ── Tabla ── */
    .prov-tabla-wrap {
        overflow-x: auto;
    }
    .prov-tabla {
        min-width: 600px;
    }
    .prov-tabla th, .prov-tabla td {
        white-space: nowrap;
    }
    .prov-tabla .acciones-cell .btn-accion {
        padding: 4px 6px;
        font-size: 0.65rem;
    }

    /* ── Paginación ── */
    .prov-paginacion {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }
    .prov-paginacion-info {
        text-align: center;
    }

    /* ── Formularios ── */
    .prov-form {
        grid-template-columns: 1fr !important;
    }
    .prov-form .prov-field-dos,
    .prov-form .prov-field-full {
        grid-column: 1 !important;
    }
    .prov-ubigeo-row {
        grid-template-columns: 1fr !important;
    }
    .prov-detalle-grid {
        grid-template-columns: 1fr !important;
    }
    .prov-toggle-row {
        grid-template-columns: 1fr !important;
    }
    .prov-field label {
        font-size: 0.7rem;
    }
    .prov-field input,
    .prov-field select,
    .prov-field textarea {
        font-size: 0.75rem;
    }

    /* ── Detalle ── */
    .prov-detalle-grid {
        grid-template-columns: 1fr;
    }
    .prov-detalle-label {
        min-width: auto !important;
    }

    /* ── Botones dentro de formularios ── */
    .btn-prov {
        width: 100%;
        justify-content: center;
    }
    .prov-form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    /* ── Modal ── */
    .modal-body {
        padding: 16px;
    }
    .modal-header {
        padding: 14px 16px;
    }
    .modal-footer {
        padding: 12px 16px;
        flex-direction: column;
    }
    .modal-footer .btn-prov {
        width: 100%;
    }
    .prov-modal-form [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    /* ── Tablas con table-layout: fixed ── */
    .prov-tabla[style*="table-layout: fixed"],
    .prov-tabla[style*="table-layout:fixed"] {
        table-layout: auto !important;
    }

    /* ── Módulos específicos ── */
    /* Pedidos / OC / Guias detail tables */
    .ped-detalle-table,
    .oc-detalle-table,
    .gc-detalle-table {
        min-width: 500px;
    }

    /* TipoCambio grid */
    .tc-grid-main {
        grid-template-columns: 1fr !important;
    }
    .tc-form-row {
        grid-template-columns: 1fr !important;
    }
    .tc-tabla-wrap {
        overflow-x: auto;
    }

    /* Saldos Iniciales */
    .sdi-form-row {
        grid-template-columns: 1fr !important;
    }

    /* Costos Iniciales */
    .ci-form-row {
        grid-template-columns: 1fr !important;
    }

    /* OC / Guías grids */
    .oc-grid-3,
    .oc-grid-4,
    .ped-grid,
    .gc-grid {
        grid-template-columns: 1fr !important;
    }

    /* Artículos grids */
    .art-grid,
    .art-grid-3 {
        grid-template-columns: 1fr !important;
    }

    /* Filter dropdown */
    .prov-filter-dd {
        min-width: auto !important;
        width: 90vw;
        left: 0 !important;
        right: 0 !important;
    }

    /* Detail view */
    .prov-detalle-grid {
        grid-template-columns: 1fr !important;
    }
    .prov-detalle-grid .prov-detalle-row {
        flex-direction: column;
        gap: 2px;
    }

    /* Override inline widths from column resize */
    th[style*="width"] {
        width: auto !important;
        min-width: auto !important;
        max-width: none !important;
    }



    /* ── Consulta Pedidos: barra de fechas ── */
    /* Grid: 2 filas x 3 columnas para inputs tipo date (intrínsecamente anchos) */
    #consPedFechaBar {
        display: grid !important;
        grid-template-columns: auto auto minmax(0, 1fr) !important;
        gap: 4px 6px !important;
        padding: 6px 8px !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        font-size: 0.78rem !important;
    }
    #consPedFechaBar > i,
    #consPedFechaBar > span {
        align-self: center !important;
    }
    /* Fila 1: icono, "Desde:", input fecha desde */
    #consPedFechaBar > i { grid-row: 1; grid-column: 1; }
    #consPedFechaBar > :nth-child(2) { grid-row: 1; grid-column: 2; }
    #consPedFechaDesde { grid-row: 1; grid-column: 3; }
    /* Fila 2: "Hasta:", input fecha hasta, Limpiar */
    #consPedFechaBar > :nth-child(4) { grid-row: 2; grid-column: 1; }
    #consPedFechaHasta { grid-row: 2; grid-column: 2 / span 2; width: 100% !important; }
    #consPedBtnLimpiarFecha { grid-row: 3; grid-column: 1 / -1; justify-self: end; }
    #consPedFechaBar input[type="date"] {
        font-size: 0.78rem !important;
        padding: 2px 4px !important;
        min-width: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    #consPedFechaBar button {
        font-size: 0.7rem !important;
        padding: 4px 10px !important;
    }

    /* ── Tablas con table-layout: fixed (por clase, no inline) ── */
    #pageConsPedidosTablaWrap .prov-tabla,
    #pageConsOC .prov-tabla[style*="table-layout"],
    #pagePedidosTablaWrap .prov-tabla {
        table-layout: auto !important;
    }

    /* ── Pedidos / OC / Guías: detalle visible en móvil ── */
    #pagePedidosForm {
        height: auto !important;
        overflow: visible !important;
    }
    .ped-section-detalle {
        flex: none !important;
        overflow: hidden !important;
    }
    .ped-detalle-wrap {
        flex: none !important;
        max-height: 250px;
        overflow: auto !important;
    }
    .ped-detalle-table th,
    .ped-detalle-table td {
        white-space: nowrap !important;
    }
    .ped-detalle-table th:nth-child(2),
    .ped-detalle-table td:nth-child(2) {
        min-width: 120px;
    }

    .oc-section-detalle {
        flex: none !important;
        overflow: hidden !important;
    }
    .oc-detalle-wrap {
        flex: none !important;
        max-height: 250px;
        overflow: auto !important;
    }

    .gc-section-detalle {
        flex: none !important;
        overflow: hidden !important;
    }
    .gc-detalle-wrap {
        flex: none !important;
        max-height: 250px;
        overflow: auto !important;
    }
}

/* ── Breakpoint para tablets pequeñas ── */
@media (max-width: 1024px) {
    .prov-tabla .col-contacto,
    .prov-tabla .col-extra {
        display: none;
    }

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

/* ── Teléfonos pequeños ── */
@media (max-width: 480px) {
    .content-area {
        padding: 8px !important;
    }
    .prov-tabla-wrap {
        border-radius: 6px;
    }
    .modal-container {
        margin: 8px;
    }
    .modal-body {
        padding: 12px;
    }
    .prov-header {
        padding: 12px 16px;
    }
    .prov-header-titulo {
        font-size: 1rem;
    }
    .sidebar-empresa {
        font-size: 0.6rem;
    }
}
