/* Inventario MP - Module Styles (normalizado a tokens --pv-*) */

/* Escala exacta de la tabla de Historico OC (.ho-table-container table / .ho-th / .ho-td) */
#inventario-mp-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 0.73rem;
    margin-top: 0;
}

#inventario-mp-table th,
#inventario-mp-table td {
    padding: 5px 8px;
    font-size: 0.73rem;
    line-height: 1.22;
    vertical-align: middle;
    border-bottom: 1px solid rgba(51, 65, 85, 0.15);
}

#inventario-mp-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #1e293b;
    color: #94a3b8;
    text-transform: uppercase;
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    padding: 7px 8px;
    border-bottom: 2px solid rgba(51, 65, 85, 0.4);
}

#inventario-mp-table .ho-th {
    padding: 7px 8px;
    font-size: 0.62rem;
    font-weight: 600;
    line-height: 1.15;
}

#inventario-mp-table .ho-td {
    padding: 5px 8px;
    font-size: 0.73rem;
    line-height: 1.22;
    color: #cbd5e1;
}

#inventario-mp-table .mp-col-codigo { width: 5%; }
#inventario-mp-table .mp-col-lote { width: 5%; text-align: center; }
#inventario-mp-table .mp-col-material { width: 26%; }
#inventario-mp-table .mp-col-inv { width: 7%; }
#inventario-mp-table .mp-col-unidad { width: 4%; }
#inventario-mp-table .mp-col-cad { width: 6.5%; }
#inventario-mp-table .mp-col-maquila { width: 7%; }
#inventario-mp-table .mp-col-transito { width: 7%; }
#inventario-mp-table .mp-col-reservado { width: 6.5%; }
#inventario-mp-table .mp-col-valor { width: 8%; }
#inventario-mp-table .mp-col-disp { width: 7%; }
#inventario-mp-table .mp-col-action { width: 4%; text-align: center; }

#inventario-mp-table .mp-col-material,
#inventario-mp-table .mp-col-codigo,
#inventario-mp-table .mp-col-unidad {
    min-width: 0;
}

#inventario-mp-table .mp-col-material {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#inventario-mp-table .ho-td.text-success {
    color: var(--pv-green-text) !important;
}

#inventario-mp-table .ho-td.text-danger {
    color: #ef4444 !important;
}

#inventario-mp-table .ho-td.text-muted {
    color: #64748b !important;
}

#inventario-mp-table .ho-td.text-info {
    color: #60a5fa !important;
}

#inventario-mp-table .text-xs {
    font-size: 0.68rem !important;
    line-height: 1.2;
}

#inventario-mp-table tr:hover {
    background: rgba(59, 130, 246, 0.06);
}

#inventario-mp-table .inv-mp-empty-cell {
    padding: 28px 12px;
    text-align: center;
    color: #94a3b8;
}

#inv-mp-tabs {
    display: none !important;
}

/* La toolbar de Inventario MP usa el patron .ho-toolbar de Historico OC (ver HTML). */

.inv-mp-view-btn {
    min-height: 30px;
    padding: 0 12px;
    border: 1px solid var(--pv-card-border);
    border-radius: 0.45rem;
    background: var(--pv-card-surface-solid);
    color: var(--pv-text-secondary);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.78rem;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.inv-mp-view-btn.active {
    border-color: var(--pv-accent);
    background: rgba(59, 130, 246, 0.16);
    color: #93c5fd;
}

.inv-mp-view-count {
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.18);
    color: #cbd5e1;
    font-size: 0.68rem;
}

.inv-mp-filter {
    position: relative;
}

.inv-mp-filter-btn {
    min-height: 30px;
    padding: 0 12px;
    border: 1px solid var(--pv-card-border);
    border-radius: 0.45rem;
    background: var(--pv-card-surface-solid);
    color: var(--pv-text-primary);
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
}

.inv-mp-filter-btn:hover {
    border-color: rgba(96, 165, 250, 0.42);
    background: rgba(59, 130, 246, 0.12);
}

.inv-mp-filter-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.inv-mp-filter-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 12;
    min-width: 190px;
    padding: 8px;
    border: 1px solid rgba(51, 65, 85, 0.8);
    border-radius: 8px;
    background: #0f172a;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.36);
}

.inv-mp-filter-menu.open {
    display: grid;
    gap: 4px;
}

.inv-mp-filter-option {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 28px;
    padding: 4px 6px;
    border-radius: 6px;
    color: var(--pv-text-secondary);
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.inv-mp-filter-option:hover {
    background: rgba(148, 163, 184, 0.08);
    color: var(--pv-text-primary);
}

.inv-mp-filter-option input {
    width: 14px;
    height: 14px;
    accent-color: var(--pv-accent);
}

/* La toolbar (patron ho-*) envuelve cuando el espacio es estrecho, en vez de desbordar */
#inv-mp-ho-toolbar {
    flex-wrap: wrap;
    row-gap: 8px;
}

#sub-inventarios-mp .ho-table-container {
    overflow-x: hidden;
    max-height: calc(100vh - 142px);
    margin-bottom: 0;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.inv-mp-parent-row {
    background: rgba(18, 24, 40, 0.55);
    cursor: pointer;
}

.inv-mp-parent-row .ho-td {
    padding-top: 7px;
    padding-bottom: 7px;
    background: rgba(18, 24, 40, 0.55);
}

.inv-mp-parent-row:hover {
    background: rgba(59, 130, 246, 0.07) !important;
}

.inv-mp-parent-row:hover .ho-td {
    background: rgba(59, 130, 246, 0.07);
}

.inv-mp-child-row {
    background: rgba(10, 14, 26, 0.5);
    cursor: pointer;
}

.inv-mp-child-row .ho-td {
    padding-top: 5px;
    padding-bottom: 5px;
    background: rgba(10, 14, 26, 0.5);
}

.inv-mp-child-row:hover {
    background: rgba(59, 130, 246, 0.06) !important;
}

.inv-mp-child-row:hover .ho-td {
    background: rgba(59, 130, 246, 0.06);
}

.inv-mp-child-row .ho-td:first-child {
    border-left: 3px solid rgba(59, 130, 246, 0.45);
}

.inv-mp-group-arrow {
    display: inline-flex;
    width: 14px;
    color: var(--pv-accent);
    font-weight: 800;
    font-size: 0.68rem;
    line-height: 1;
}

.inv-mp-material-main {
    color: var(--pv-text-primary);
    font-weight: 600;
    font-size: 0.78rem;
    line-height: 1.18;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.inv-mp-material-meta {
    min-height: 0;
    margin-top: 2px;
    line-height: 1.1;
}

.inv-mp-provider {
    margin-top: 2px;
    color: #94a3b8;
    font-size: 0.64rem;
    font-weight: 500;
    line-height: 1.15;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.inv-mp-negative-pill {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    border-radius: 999px;
    border: 1px solid rgba(239, 68, 68, 0.38);
    background: rgba(239, 68, 68, 0.14);
    color: #fca5a5;
    font-size: 0.62rem;
    font-weight: 700;
}

.inv-mp-lot-warning {
    margin-top: 2px;
    color: #f87171;
    font-size: 0.62rem;
    font-weight: 700;
}

.inv-mp-adjust-btn {
    width: 26px;
    height: 24px;
    min-height: 24px;
    padding: 0;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid var(--pv-accent);
    border-radius: 6px;
    color: #93c5fd;
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.inv-mp-adjust-btn .material-symbols-outlined {
    font-size: 15px;
    line-height: 1;
}

.inv-mp-adjust-btn:hover {
    background: rgba(59, 130, 246, 0.28);
}

.inv-mp-adjust-btn.danger {
    background: rgba(239, 68, 68, 0.16);
    border-color: #ef4444;
    color: #fca5a5;
}

.inv-mp-adjust-btn.danger:hover {
    background: rgba(239, 68, 68, 0.28);
}

.inv-mp-tag {
    display: inline-flex;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: var(--pv-text-xs);
}

/* Tag de acento (antes morado, ahora azul del sistema) */
.inv-mp-tag-purple {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
}

.inv-mp-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    font-size: var(--pv-text-sm);
    font-weight: 700;
}

.inv-mp-icon-blue {
    color: #60a5fa;
}

.inv-mp-icon-red {
    color: #f87171;
}

/* Inventory Status Colors */
.inv-positive {
    color: var(--pv-green);
    font-weight: 600;
}

.inv-negative {
    color: #ef4444;
    font-weight: 700;
}

.inv-zero {
    color: var(--pv-text-secondary);
}

/* Detail Drawer - right-anchored slide-in */
#inv-mp-detail-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: min(1100px, calc(100vw - 220px));
    height: 100vh;
    background: var(--pv-card-surface-solid);
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.6);
    z-index: 3000;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#inv-mp-detail-drawer.active {
    transform: translateX(0);
}

#inv-mp-detail-drawer .drawer-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#inv-mp-entradas-table th,
#inv-mp-entradas-table td,
#inv-mp-salidas-table th,
#inv-mp-salidas-table td,
#inv-mp-ajustes-table th,
#inv-mp-ajustes-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--pv-card-border);
}

#inv-mp-entradas-table tr:hover,
#inv-mp-salidas-table tr:hover,
#inv-mp-ajustes-table tr:hover {
    background: rgba(59, 130, 246, 0.06);
}

/* Drawer table header cells */
.drawer-th {
    padding: 8px 12px;
    text-align: left;
    color: var(--pv-text-secondary);
    font-weight: 500;
    font-size: var(--pv-text-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.drawer-th-right {
    padding: 8px 12px;
    text-align: right;
    color: var(--pv-text-secondary);
    font-weight: 500;
    font-size: var(--pv-text-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Drawer section container */
.drawer-section {
    background: var(--pv-card-surface-solid);
    border-radius: 12px;
    overflow: hidden;
}

.drawer-section-header {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.drawer-section-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.drawer-section-title {
    margin: 0;
    font-size: var(--pv-text-base);
    font-weight: 600;
}

.inv-mp-reg-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(2, 6, 23, 0.74);
}

.inv-mp-reg-dialog {
    width: min(1080px, 96vw);
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--pv-card-surface-solid);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 10px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
}

.inv-mp-reg-header,
.inv-mp-reg-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--pv-card-border);
}

.inv-mp-reg-footer {
    justify-content: flex-end;
    border-top: 1px solid var(--pv-card-border);
    border-bottom: 0;
}

.inv-mp-reg-eyebrow {
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.inv-mp-reg-header h3 {
    margin: 4px 0 0;
    color: var(--pv-text-primary);
    font-size: var(--pv-text-lg);
}

.inv-mp-reg-subtitle {
    margin-top: 4px;
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-sm);
}

.inv-mp-reg-close {
    width: 34px;
    height: 34px;
    border: 1px solid var(--pv-card-border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--pv-text-secondary);
    cursor: pointer;
}

.inv-mp-reg-body {
    padding: 16px 18px;
    overflow: auto;
}

.inv-mp-reg-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.inv-mp-reg-summary>div {
    padding: 11px 12px;
    background: rgba(15, 23, 42, 0.66);
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 8px;
}

.inv-mp-reg-summary span {
    display: block;
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs);
    font-weight: 800;
    text-transform: uppercase;
}

.inv-mp-reg-summary strong {
    display: block;
    margin-top: 4px;
    color: var(--pv-text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: var(--pv-text-base);
}

.inv-mp-reg-warnings {
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid rgba(251, 191, 36, 0.28);
    border-radius: 8px;
    background: rgba(113, 63, 18, 0.14);
    color: #fde68a;
    font-size: var(--pv-text-sm);
}

.inv-mp-reg-warnings div+div {
    margin-top: 5px;
}

.inv-mp-reg-add-row,
.inv-mp-reg-form-row {
    display: grid;
    grid-template-columns: 0.85fr auto 1.1fr 0.75fr auto;
    gap: 10px;
    margin-bottom: 12px;
}

.inv-mp-reg-form-row {
    grid-template-columns: 1fr 1fr;
    margin-top: 12px;
    margin-bottom: 0;
}

.inv-mp-reg-form-row label {
    display: grid;
    gap: 5px;
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-sm);
    font-weight: 700;
}

.inv-mp-reg-input {
    min-height: 34px;
    width: 100%;
    padding: 0 10px;
    border: 1px solid var(--pv-card-border);
    border-radius: 8px;
    background: #0f172a;
    color: var(--pv-text-primary);
    outline: none;
}

.inv-mp-reg-input:focus {
    border-color: var(--pv-accent);
}

.inv-mp-reg-table-wrap {
    max-height: 360px;
    overflow: auto;
    border: 1px solid var(--pv-card-border);
    border-radius: 8px;
}

.inv-mp-reg-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--pv-text-sm);
}

.inv-mp-reg-table th,
.inv-mp-reg-table td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--pv-card-border);
}

.inv-mp-reg-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #111827;
    color: var(--pv-text-secondary);
    text-align: left;
    text-transform: uppercase;
    font-size: var(--pv-text-xs);
    font-weight: 800;
}

.inv-mp-reg-status {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 0 8px;
    border-radius: 4px;
    background: rgba(148, 163, 184, 0.12);
    color: #cbd5e1;
    font-size: var(--pv-text-xs);
    font-weight: 700;
}

.inv-mp-reg-status.warn {
    background: rgba(251, 191, 36, 0.14);
    color: #fde68a;
}

.inv-mp-reg-status.danger {
    background: rgba(239, 68, 68, 0.14);
    color: #fca5a5;
}

.inv-mp-reg-primary-btn,
.inv-mp-reg-secondary-btn,
.inv-mp-reg-auto-btn,
.inv-mp-reg-danger-btn {
    min-height: 34px;
    padding: 0 14px;
    border-radius: 8px;
    font-weight: 800;
    cursor: pointer;
}

.inv-mp-reg-primary-btn {
    border: 1px solid rgba(59, 130, 246, 0.5);
    background: rgba(59, 130, 246, 0.18);
    color: #bfdbfe;
}

.inv-mp-reg-secondary-btn {
    border: 1px solid var(--pv-card-border);
    background: rgba(148, 163, 184, 0.08);
    color: var(--pv-text-secondary);
}

.inv-mp-reg-auto-btn {
    border: 1px solid rgba(59, 130, 246, 0.45);
    background: rgba(59, 130, 246, 0.14);
    color: #bfdbfe;
    white-space: nowrap;
}

.inv-mp-reg-danger-btn {
    border: 1px solid rgba(34, 197, 94, 0.46);
    background: rgba(34, 197, 94, 0.16);
    color: #bbf7d0;
}

.inv-mp-reg-danger-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

@media (max-width: 900px) {
    .inv-mp-reg-summary,
    .inv-mp-reg-add-row,
    .inv-mp-reg-form-row {
        grid-template-columns: 1fr;
    }
}

/* ════════════════════════════════════════════════════════════════
   Mejoras UX/responsivas: colapso de agotados, paleta calmada por
   columna y comportamiento responsivo de la tabla. (solo presentacion)
   ════════════════════════════════════════════════════════════════ */

/* Encabezados: tinte sutil que comunica la categoria sin saturar el cuerpo */
#inventario-mp-table th.mp-col-maquila { color: #5fb89a; }
#inventario-mp-table th.mp-col-transito { color: #d3a05f; }
#inventario-mp-table th.mp-col-reservado { color: #8aa6d8; }
#inventario-mp-table th.mp-col-valor { color: #cdb06a; }
#inventario-mp-table th.mp-col-disp { color: var(--pv-accent); }

/* Datos de columnas secundarias en tono neutro: la tabla se lee tranquila.
   Inventario y Disp. Programar conservan su color semantico (no se tocan). */
#inventario-mp-table td.mp-col-maquila,
#inventario-mp-table td.mp-col-transito,
#inventario-mp-table td.mp-col-reservado { color: var(--pv-text-secondary); }
#inventario-mp-table td.mp-col-valor { color: var(--pv-text-primary); font-weight: 500; }

.mp-na { color: var(--pv-text-secondary); opacity: 0.4; }

/* Resumen de lotes en la fila padre: verde = positivos, rojo = negativos */
.inv-mp-lote-summary { white-space: nowrap; }

.inv-mp-lot-count {
    color: var(--pv-text-primary);
    font-weight: 700;
    font-size: 0.68rem;
    line-height: 1.15;
}

.inv-mp-lot-breakdown {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    margin-top: 0;
}

.inv-mp-lot-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 17px;
    padding: 0 5px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 0.64rem;
    font-weight: 600;
    line-height: 1;
}

.inv-mp-lot-chip.pos { background: rgba(34, 197, 94, 0.12); color: #86efac; border-color: rgba(34, 197, 94, 0.28); }
.inv-mp-lot-chip.neg { background: rgba(239, 68, 68, 0.12); color: #fca5a5; border-color: rgba(239, 68, 68, 0.30); }
.inv-mp-lot-chip.zero { background: rgba(148, 163, 184, 0.11); color: #cbd5e1; border-color: rgba(148, 163, 184, 0.24); }

/* ── Responsivo ── */
@media (max-width: 1100px) {
    /* En pantallas medianas ocultamos columnas secundarias; el detalle por lote
       sigue disponible al abrir el drawer. Quedan las columnas clave. */
    #inventario-mp-table .mp-col-secondary { display: none; }
}

@media (max-width: 720px) {
    #inv-mp-ho-toolbar .ho-toolbar-left,
    #inv-mp-ho-toolbar .ho-toolbar-right { flex-wrap: wrap; }
    #inv-mp-ho-toolbar .ho-search-input { min-width: 0; }
}

/* ════════════════════════════════════════════════════════════════
   Congruencia estructural con Historico OC: seccion plana (sin la
   tarjeta envolvente) y banner de formula discreto.
   ════════════════════════════════════════════════════════════════ */

/* La seccion MP va plana, igual que Historico OC e Inventario PT */
#sub-inventarios-mp > .card {
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 0;
}

/* Banner de formula -> linea discreta (Historico OC no usa banners llamativos) */
.inv-mp-formula-hint {
    margin-bottom: 10px;
    padding: 6px 12px;
    border-left: 2px solid var(--pv-accent);
    border-radius: 4px;
    background: rgba(59, 130, 246, 0.06);
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs);
}

.inv-mp-formula-hint strong {
    color: var(--pv-text-primary);
    font-weight: 600;
}
