/**
 * Estilos para el módulo de Stock
 */

.stock-wrapper {
    padding: 0 32px 32px 32px;
}

/* Tabs */
.tabs-container {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 0;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #6b7280;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: #111827;
    background: #f9fafb;
}

.tab-btn.active {
    color: #dd3434;
    border-bottom-color: #dd3434;
}

/* Iconos en botones */
.calendar-icon {
    margin-right: 6px;
}

.chevron-icon {
    margin-left: 4px;
}

/* Filtro de fechas */
.date-filter-wrapper {
    position: relative;
    display: inline-block;
}

.date-filter-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #374151;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.date-filter-btn:hover {
    border-color: #dd3434;
    color: #dd3434;
}

.date-filter-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    z-index: 10000;
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s;
}

.date-filter-dropdown.show,
.date-filter-dropdown.active {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
    display: block !important;
}

.date-filter-dropdown ul {
    list-style: none;
    margin: 0;
    padding: 8px 0;
}

.date-filter-dropdown li {
    margin: 0;
}

.date-filter-dropdown li.divider {
    height: 1px;
    background: #e5e7eb;
    margin: 8px 0;
}

.date-filter-dropdown a {
    display: block;
    padding: 8px 16px;
    color: #374151;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.2s;
}

.date-filter-dropdown a:hover {
    background: #f3f4f6;
    color: #dd3434;
}

.tab-content {
    padding-top: 6px;
}

/* Categorías - Stock Actual */
.categorias-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.categoria-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

.categoria-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #f9fafb;
    cursor: pointer;
    transition: background 0.2s;
}

.categoria-header:hover {
    background: #f3f4f6;
}

.categoria-header.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.categoria-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.categoria-color {
    width: 4px;
    height: 32px;
    border-radius: 2px;
}

.categoria-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #111827;
}

.categoria-stats {
    font-size: 14px;
    color: #6b7280;
}

.collapse-icon {
    transition: transform 0.2s;
    color: #6b7280;
}

.categoria-items {
    padding: 0;
}

/* Tabla de stock */
.stock-table {
    width: 100%;
    border-collapse: collapse;
}

.stock-table thead {
    background: #f9fafb;
}

.stock-table th {
    padding: 12px 20px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stock-table tbody tr {
    border-top: 1px solid #e5e7eb;
    transition: background 0.2s;
}

.stock-table tbody tr:hover {
    background: #f9fafb;
}

.stock-table td {
    padding: 16px 20px;
    font-size: 14px;
    color: #374151;
}

.item-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.item-imagen {
    width: 42px;
    height: 42px;
    border-radius: 6px;
    object-fit: cover;
    background: #f3f4f6;
}

.item-imagen-small {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    object-fit: cover;
    background: #f3f4f6;
}

.item-nombre {
    font-weight: 500;
    color: #111827;
}

.item-nombre-cocina {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
}

.stock-cantidad {
    display: inline-block;
    padding: 4px 12px;
    background: #dbeafe;
    color: #1e40af;
    border-radius: 4px;
    font-weight: 500;
}

/* Histórico: mismo patrón que clientes/proveedores para no solapar celdas */
.historico-table-wrapper {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    max-height: 70vh;
    overflow-y: auto;
}

/* Cuando lleva entity-table-wrapper: scroll horizontal + tabla con anchos fijos (como entity-management) */
.historico-table-wrapper.entity-table-wrapper {
    overflow: auto;
    max-height: calc(100vh - 220px);
    min-height: 200px;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.historico-table-wrapper.entity-table-wrapper .historico-table {
    width: 1350px;
    min-width: 1350px;
    border-collapse: collapse;
    font-size: 14px;
    table-layout: fixed;
}

.historico-table thead {
    background: #f9fafb;
    position: sticky;
    top: 0;
    z-index: 10;
}

.historico-table-wrapper.entity-table-wrapper .historico-table thead th {
    padding: 12px 14px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 2;
    box-shadow: 0 1px 0 0 #e5e7eb;
    white-space: nowrap;
}

/* Anchos fijos por columna (evitan solapamiento; mismo criterio que clientes/proveedores) */
.historico-table-wrapper.entity-table-wrapper .historico-table thead th:nth-child(1),
.historico-table-wrapper.entity-table-wrapper .entity-th-filters th:nth-child(1),
.historico-table-wrapper.entity-table-wrapper .historico-table tbody td:nth-child(1) { width: 148px; min-width: 148px; max-width: 148px; }
.historico-table-wrapper.entity-table-wrapper .historico-table thead th:nth-child(2),
.historico-table-wrapper.entity-table-wrapper .entity-th-filters th:nth-child(2),
.historico-table-wrapper.entity-table-wrapper .historico-table tbody td:nth-child(2) { width: 200px; min-width: 200px; max-width: 200px; }
.historico-table-wrapper.entity-table-wrapper .historico-table thead th:nth-child(3),
.historico-table-wrapper.entity-table-wrapper .entity-th-filters th:nth-child(3),
.historico-table-wrapper.entity-table-wrapper .historico-table tbody td:nth-child(3) { width: 120px; min-width: 120px; max-width: 120px; }
.historico-table-wrapper.entity-table-wrapper .historico-table thead th:nth-child(4),
.historico-table-wrapper.entity-table-wrapper .entity-th-filters th:nth-child(4),
.historico-table-wrapper.entity-table-wrapper .historico-table tbody td:nth-child(4) { width: 100px; min-width: 100px; max-width: 100px; text-align: right; }
.historico-table-wrapper.entity-table-wrapper .historico-table thead th:nth-child(5),
.historico-table-wrapper.entity-table-wrapper .entity-th-filters th:nth-child(5),
.historico-table-wrapper.entity-table-wrapper .historico-table tbody td:nth-child(5) { width: 100px; min-width: 100px; max-width: 100px; text-align: right; }
.historico-table-wrapper.entity-table-wrapper .historico-table thead th:nth-child(6),
.historico-table-wrapper.entity-table-wrapper .entity-th-filters th:nth-child(6),
.historico-table-wrapper.entity-table-wrapper .historico-table tbody td:nth-child(6) { width: 92px; min-width: 92px; max-width: 92px; text-align: right; }
.historico-table-wrapper.entity-table-wrapper .historico-table thead th:nth-child(7),
.historico-table-wrapper.entity-table-wrapper .entity-th-filters th:nth-child(7),
.historico-table-wrapper.entity-table-wrapper .historico-table tbody td:nth-child(7) { width: 110px; min-width: 110px; max-width: 110px; }
.historico-table-wrapper.entity-table-wrapper .historico-table thead th:nth-child(8),
.historico-table-wrapper.entity-table-wrapper .entity-th-filters th:nth-child(8),
.historico-table-wrapper.entity-table-wrapper .historico-table tbody td:nth-child(8) { width: 130px; min-width: 130px; max-width: 130px; }
.historico-table-wrapper.entity-table-wrapper .historico-table thead th:nth-child(9),
.historico-table-wrapper.entity-table-wrapper .entity-th-filters th:nth-child(9),
.historico-table-wrapper.entity-table-wrapper .historico-table tbody td:nth-child(9) { width: 108px; min-width: 108px; max-width: 108px; text-align: right; }
.historico-table-wrapper.entity-table-wrapper .historico-table thead th:nth-child(10),
.historico-table-wrapper.entity-table-wrapper .entity-th-filters th:nth-child(10),
.historico-table-wrapper.entity-table-wrapper .historico-table tbody td:nth-child(10) { width: 108px; min-width: 108px; max-width: 108px; text-align: right; }
.historico-table-wrapper.entity-table-wrapper .historico-table thead th:nth-child(11),
.historico-table-wrapper.entity-table-wrapper .entity-th-filters th:nth-child(11),
.historico-table-wrapper.entity-table-wrapper .historico-table tbody td:nth-child(11) { width: 134px; min-width: 134px; max-width: 134px; }

/* Celdas: overflow y ellipsis para no solapar columnas contiguas */
.historico-table-wrapper.entity-table-wrapper .historico-table tbody td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    padding: 12px 14px;
    font-size: 14px;
    color: #374151;
}
/* Diferencia: verde/rojo (misma especificidad que la regla anterior para que no quede en negro) */
.historico-table-wrapper.entity-table-wrapper .historico-table tbody td.diferencia.positivo {
    color: #059669;
}
.historico-table-wrapper.entity-table-wrapper .historico-table tbody td.diferencia.negativo {
    color: #dc2626;
}
.historico-table-wrapper.entity-table-wrapper .historico-table tbody td.table-empty-state {
    white-space: normal;
    text-overflow: clip;
    text-align: center;
}
/* Fecha: sin ellipsis para que se vea completa (dd/mm/yyyy, hh:mm) */
.historico-table-wrapper.entity-table-wrapper .historico-table tbody td:nth-child(1) {
    text-overflow: clip;
}

/* Celda Producto: item-info debe permitir que el nombre corte con ellipsis */
.historico-table-wrapper.entity-table-wrapper .historico-table tbody td:nth-child(2) .item-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
}
.historico-table-wrapper.entity-table-wrapper .historico-table tbody td:nth-child(2) .item-info span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* Fila de filtros por columna (consulta a BD), mismo estilo que clientes/proveedores */
.historico-table-wrapper.entity-table-wrapper .entity-th-filters th {
    padding: 8px;
    vertical-align: middle;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 49px;
    z-index: 2;
    box-shadow: 0 1px 0 0 #e2e8f0;
}
.historico-table-wrapper.entity-table-wrapper .entity-th-filters .entity-col-filter-input {
    width: calc(100% - 16px);
    min-width: 0;
    padding: 6px 8px;
    font-size: 12px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    box-sizing: border-box;
}
.historico-table-wrapper.entity-table-wrapper .entity-th-filters .entity-col-filter-input:focus {
    outline: none;
    border-color: #3b82f6;
}

.historico-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.historico-table tbody tr {
    border-top: 1px solid #e5e7eb;
    transition: background 0.2s;
}

.historico-table tbody tr:hover {
    background: #f9fafb;
}

/* td por defecto (cuando no es entity-table-wrapper, p.ej. carga inicial) */
.historico-table td {
    padding: 12px 16px;
    font-size: 14px;
    color: #374151;
}

.diferencia {
    font-weight: 600;
}

.diferencia.positivo {
    color: #059669;
}

.diferencia.negativo {
    color: #dc2626;
}

.motivo-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.motivo-ajuste_manual {
    background: #dbeafe;
    color: #1e40af;
}

.motivo-gasto {
    background: #fef3c7;
    color: #92400e;
}

.motivo-venta {
    background: #d1fae5;
    color: #065f46;
}

.motivo-actualizacion_manual {
    background: #e0e7ff;
    color: #3730a3;
}

.motivo-inventario {
    background: #f3e8ff;
    color: #6b21a8;
}

.motivo-devolucion {
    background: #fee2e2;
    color: #991b1b;
}

/* Modal de ajuste de stock */
.modal-large {
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
}

.busqueda-resultados {
    margin-bottom: 24px;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
}

.resultados-list {
    padding: 8px;
}

.resultado-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 6px;
    transition: background 0.2s;
}

.resultado-item:hover {
    background: #f9fafb;
}

.resultado-item.selected {
    background: #eff6ff;
    border: 1px solid #3b82f6;
}

.resultado-item .item-details {
    flex: 1;
}

.resultado-item .item-meta {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
}

.btn-select-item {
    white-space: nowrap;
}

#items-seleccionados-container {
    margin-top: 24px;
}

#items-seleccionados-container h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #111827;
}

.items-seleccionados-list {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 12px;
    background: #f9fafb;
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
}

.selected-item-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    margin-bottom: 8px;
}

.selected-item-card:last-child {
    margin-bottom: 0;
}

.selected-item-card .item-details {
    flex: 1;
}

.stock-input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stock-input-group label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
}

.input-small {
    width: 100px;
    padding: 6px 10px;
    font-size: 14px;
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
    white-space: nowrap;
}

.btn-remove-item {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.btn-remove-item:hover {
    background: #fecaca;
}

/* Estados vacíos */
.empty-state {
    padding: 48px 24px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}

.empty-state-small {
    padding: 24px;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
}



@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .stock-wrapper {
        padding: 0 16px 16px 16px;
    }
    
    .categoria-header {
        padding: 12px 16px;
    }
    
    .stock-table th,
    .stock-table td {
        padding: 12px;
        font-size: 13px;
    }
    
    .item-imagen {
        width: 40px;
        height: 40px;
    }
    
    .historico-table-wrapper.entity-table-wrapper {
        max-height: 60vh;
    }
    
    .historico-table-wrapper.entity-table-wrapper .historico-table {
        min-width: 1350px;
    }
    
    .historico-table th,
    .historico-table td {
        padding: 10px 8px;
        font-size: 12px;
    }
    
    .modal-large {
        max-width: 95%;
        margin: 20px auto;
    }
    
    .selected-item-card {
        flex-wrap: wrap;
    }
}

/* Estilos para badge de establecimiento */
.establecimiento-badge {
    display: inline-block;
    padding: 4px 8px;
    background: #f3f4f6;
    color: #374151;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid #d1d5db;
}

.stock-table th:last-child,
.stock-table td:last-child {
    text-align: center;
    min-width: 120px;
}

/* ---- Stock Actual: tabla plana (estilo proveedores) ---- */
.stock-actual-table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;

    flex-wrap: wrap;
}

.stock-actual-table-header .filters-bar {
    flex: 1;
    min-width: 200px;
}

.stock-actual-table-header .filters-bar-search {
    max-width: 320px;
}

/* Wrapper usa entity-table-wrapper; anchos de columna para tabla stock */
.stock-actual-table-wrapper.entity-table-wrapper {
    min-width: 0;
}

.stock-actual-table-wrapper table.stock-actual-table {
    min-width: 1250px;
}

.stock-actual-table-wrapper.stock-actual-table-wrapper thead th:first-child,
.stock-actual-table-wrapper .entity-th-filters th:first-child,
.stock-actual-table-wrapper.stock-actual-table-wrapper tbody td:first-child {
    width: 44px;
    min-width: 44px;
    max-width: 44px;
    text-align: center;
}

.stock-actual-table-wrapper thead th[data-sort="nombre"] { width: 220px; min-width: 220px; }
.stock-actual-table-wrapper thead th[data-sort="categoria_nombre"] { width: 140px; min-width: 140px; }
.stock-actual-table-wrapper thead th[data-sort="proveedor_nombre"] { width: 150px; min-width: 150px; }
.stock-actual-table-wrapper thead th[data-sort="precio"] { width: 90px; min-width: 90px; }
.stock-actual-table-wrapper thead th[data-sort="costo"] { width: 90px; min-width: 90px; }
.stock-actual-table-wrapper thead th[data-sort="stock"] { width: 90px; min-width: 90px; }
.stock-actual-table-wrapper thead th[data-sort="valor"] { width: 100px; min-width: 100px; }
.stock-actual-table-wrapper thead th[data-sort="establecimiento_nombre"] { width: 130px; min-width: 130px; }

/* Badge de categoría con color */
.stock-categoria-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    background: #f3f4f6;
    color: var(--categoria-color, #374151);
    border-left: 3px solid var(--categoria-color, #6b7280);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.stock-col-categoria {
    min-width: 120px;
}

/* Checkbox en tabla stock (mismo estilo que proveedores) */
#stock-actual-container .checkbox-select,
#stock-actual-container .checkbox-stock-item, .checkbox-producto-item {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

#stock-selection-bar .selection-bar-btn.btn-primary,
#productos-selection-bar .selection-bar-btn.btn-primary {
    background: rgba(221, 52, 52, 0.25);
    color: #fff;
}

#stock-selection-bar .selection-bar-btn.btn-primary:hover,
#productos-selection-bar .selection-bar-btn.btn-primary:hover {
    background: rgba(221, 52, 52, 0.4);
}

/* ---- Almacenes tab ---- */
.almacenes-list {
    min-height: 200px;
    margin-top: 10px;
}

.almacenes-empty {
    text-align: center;
    padding: 48px 24px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px dashed #d1d5db;
}

.almacenes-empty p {
    margin: 0 0 8px;
    color: #374151;
}

.almacenes-empty-hint {
    font-size: 14px;
    color: #6b7280 !important;
    margin-bottom: 20px !important;
}

.almacenes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.almacen-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.almacen-card:hover {
    border-color: #d1d5db;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}


.almacen-card-color {
    height: 6px;
    width: 100%;
}

.almacen-card-body {
    padding: 16px;
}

.almacen-card-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 8px;
}

.almacen-badge-defecto {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: #b45309;
    background: #fef3c7;
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: auto;
}

.almacen-emoji {
    font-size: 24px;
    line-height: 1;
}

.almacen-emoji-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.almacen-emoji-btn {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    line-height: 1;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.almacen-emoji-btn:hover {
    border-color: #9ca3af;
    background: #f9fafb;
}

.almacen-emoji-btn.selected {
    border-color: var(--almacen-color, #2563eb);
    background: color-mix(in srgb, var(--almacen-color, #2563eb) 12%, transparent);
}

.almacen-emoji-input {
    max-width: 120px;
}

.almacen-nombre {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #111827;
}

.almacen-descripcion {
    margin: 0 0 12px;
    font-size: 13px;
    color: #6b7280;
    line-height: 1.45;
}

.almacen-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #f3f4f6;
}

.btn-ghost {
    background: transparent;
    border: none;
    color: #6b7280;
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
}

.btn-ghost:hover {
    color: #dd3434;
    background: #fef2f2;
}

/* Modal almacén */
.modal-almacen .modal-content {
    min-width: 400px;
    max-width: 480px;
}

.form-row-almacen {
    display: flex;
    gap: 16px;
    align-items: flex-end;
}

.form-row-almacen .form-group {
    flex: 1;
}

.almacen-color-input {
    display: flex;
    gap: 10px;
    align-items: center;
}

.almacen-color-input input[type="color"] {
    width: 44px;
    height: 38px;
    padding: 2px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    cursor: pointer;
    background: #fff;
}

.almacen-color-input .input-field {
    flex: 1;
}

.almacen-color-input input[type="text"] {
    font-family: monospace;
}

.form-group-almacen-defecto .checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}
.form-group-almacen-defecto .checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
}
.form-group-almacen-defecto .form-hint {
    margin: 4px 0 0 26px;
    font-size: 12px;
    color: #6b7280;
    line-height: 1.35;
}

.form-group .required {
    color: #dc2626;
}

/* Celda de stock clickable (desplegable por almacén) */

.stock-cantidad-cell:hover {
    background: #f3f4f6;
}
.stock-cantidad-cell .stock-cantidad {
    flex: 1;
}
.stock-cantidad-cell .stock-cantidad-icon {
    flex-shrink: 0;
    color: #9ca3af;
}
.stock-cantidad-cell:hover .stock-cantidad-icon {
    color: #dd3434;
}

/* Desplegable stock por almacén */
.stock-almacenes-dropdown {
    position: fixed;
    z-index: 10050;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
    min-width: 280px;
    max-width: 360px;
}
.stock-almacenes-dropdown-inner {
    padding: 0;
}
.stock-almacenes-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 8px 8px 0 0;
}
.stock-almacenes-dropdown-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
}
.stock-almacenes-dropdown-close {
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    border-radius: 4px;
    flex-shrink: 0;
}
.stock-almacenes-dropdown-close:hover {
    background: #e5e7eb;
    color: #111827;
}
.stock-almacenes-dropdown-body {
    padding: 10px 14px;
    max-height: 280px;
    overflow-y: auto;
}
.stock-almacenes-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.stock-almacenes-row:last-child {
    margin-bottom: 0;
}
.stock-almacenes-row-label {
    flex: 1;
    font-size: 13px;
    color: #374151;
    min-width: 0;
    padding-left: 2px;
    border-left: 3px solid var(--almacen-color, #6b7280);
}
.stock-almacenes-row input.stock-almacen-cantidad {
    width: 80px;
    flex-shrink: 0;
    text-align: right;
}
.stock-almacenes-row-readonly .stock-almacenes-row-cantidad {
    font-weight: 600;
    color: #111827;
    min-width: 64px;
    text-align: right;
}
.stock-almacenes-dropdown-footer {
    padding: 10px 14px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 0 0 8px 8px;
    font-size: 14px;
    color: #374151;
}
.stock-almacenes-dropdown-footer strong {
    color: #111827;
}
.stock-almacenes-loading,
.stock-almacenes-error,
.stock-almacenes-empty {
    padding: 12px;
    font-size: 13px;
    color: #6b7280;
    text-align: center;
}
.stock-almacenes-error {
    color: #dc2626;
}
.stock-almacenes-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.stock-almacenes-loading .spinner {
    width: 18px;
    height: 18px;
    border-width: 2px;
}

/* Modal Ajustar stock por almacén */
.stock-ajustar-modal {
    position: fixed;
    inset: 0;
    z-index: 10060;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.stock-ajustar-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
}
.stock-ajustar-modal-box {
    position: relative;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);

    width: 95%;
    max-width: 1400px;
    max-height: 90vh;
    margin:0 auto;
    display: flex;
    flex-direction: column;
}
.stock-ajustar-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
}
.stock-ajustar-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 400px;
}
.stock-ajustar-modal-close {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    border-radius: 6px;
}
.stock-ajustar-modal-close:hover {
    background: #f3f4f6;
    color: #111827;
}
.stock-ajustar-modal-body {
    padding: 20px;
    overflow-y: auto;
}
.stock-ajustar-modal-hint {
    margin: 0 0 16px 0;
    font-size: 13px;
    color: #6b7280;
    line-height: 1.4;
}
.stock-ajustar-modal-notas {
    margin-top: 16px;
}
.stock-ajustar-modal-notas .pm-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
}
.stock-ajustar-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.stock-ajustar-table th,
.stock-ajustar-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}
.stock-ajustar-table th {
    font-weight: 600;
    color: #374151;
    background: #f9fafb;
}

#stock-historico-container{
    margin-top:5px;
}

.stock-ajustar-table td.stock-ajustar-actual,
.stock-ajustar-table td .stock-ajustar-nuevo-total {

    font-variant-numeric: tabular-nums;
}
.stock-ajustar-table input.ajuste-stock-almacen {
    width: 90px;
    text-align: right;
}
.stock-ajustar-almacen-label {
    padding-left: 6px;
    border-left: 3px solid var(--almacen-color, #6b7280);
}
.stock-ajustar-error,
.stock-ajustar-empty {
    color: #6b7280;
    text-align: center;
    padding: 16px !important;
}
.stock-ajustar-error {
    color: #dc2626;
}
.stock-ajustar-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 0 0 12px 12px;
}

/* Barra Histórico: filtro a la izquierda, Exportar Excel a la derecha */
.stock-historico-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.stock-historico-actions .date-filter-wrapper {
    margin: 0;
}
#stock-export-excel-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
#stock-export-excel-btn svg {
    flex-shrink: 0;
}

/* Modal Exportar Excel */
.stock-export-excel-modal {
    position: fixed;
    inset: 0;
    z-index: 10060;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.stock-export-excel-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
}
.stock-export-excel-modal-box {
    position: relative;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    max-width: 440px;
    width: 100%;
}
.stock-export-excel-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
}
.stock-export-excel-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}
.stock-export-excel-modal-close {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    border-radius: 6px;
}
.stock-export-excel-modal-close:hover {
    background: #f3f4f6;
    color: #111827;
}
.stock-export-excel-modal-body {
    padding: 20px;
}
.stock-export-excel-modal-hint {
    margin: 0 0 16px 0;
    font-size: 13px;
    color: #6b7280;
    line-height: 1.4;
}
.stock-export-excel-form-group {
    margin-bottom: 14px;
}
.stock-export-excel-form-group:last-of-type {
    margin-bottom: 0;
}
.stock-export-excel-form-group .pm-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
}
.stock-export-excel-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 0 0 12px 12px;
}

/* Modal Ajustar Stock Masivo (por almacén) - estilo stock-ajustar-modal-box */
.stock-ajustar-masivo-overlay {
    position: fixed;
    inset: 0;
    z-index: 10060;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.4);
}
.stock-ajustar-masivo-box {
    position: relative;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    max-width: 1460px;
    width: 100%;
    min-height: 85vh;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
}
.stock-ajustar-masivo-box .stock-ajustar-modal-header {
    border-radius: 12px 12px 0 0;
}
.stock-ajustar-masivo-box .stock-ajustar-modal-body {
    overflow-y: auto;
    flex: 1;
}
.stock-ajustar-masivo-search {
    margin-bottom: 14px;
}
.stock-ajustar-masivo-search .pm-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
}
.stock-ajustar-masivo-selected {
    margin-top: 16px;
    margin-bottom: 16px;
}
.stock-ajustar-masivo-selected-title {
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: 600;
    color: #111827;
}
.items-seleccionados-list-masivo {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.selected-item-card-masivo {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px 14px;
    background: #fafafa;
}
.selected-item-card-masivo-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.selected-item-card-masivo-header .item-imagen-small {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
}
.selected-item-card-masivo-header .item-details {
    flex: 1;
    min-width: 0;
}
.selected-item-card-masivo-header .item-nombre {
    font-weight: 600;
    color: #111827;
    font-size: 14px;
}
.selected-item-card-masivo-header .item-meta {
    font-size: 12px;
    color: #6b7280;
}
.selected-item-card-masivo-header .btn-remove-item-masivo {
    flex-shrink: 0;
}
.stock-ajustar-masivo-table {
    margin-top: 0;
    font-size: 13px;
}
.stock-ajustar-masivo-table th,
.stock-ajustar-masivo-table td {
    padding: 8px 10px;
}
.stock-ajustar-masivo-table input.ajuste-stock-almacen-masivo {
    width: 80px;
    text-align: right;
}
.stock-ajustar-masivo-table .stock-ajustar-nuevo-total-masivo {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
#modal-ajustar-stock .busqueda-resultados {
    margin-top: 10px;
    margin-bottom: 10px;
}
#modal-ajustar-stock .resultados-list {
    max-height: 200px;
    overflow-y: auto;
}
#modal-ajustar-stock .resultado-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    margin-bottom: 6px;
    background: #fff;
}
#modal-ajustar-stock .resultado-item.selected {
    border-color: #dd3434;
    background: #fef2f2;
}
#modal-ajustar-stock .resultado-item .item-imagen-small {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 4px;
}
#modal-ajustar-stock .resultado-item .item-details {
    flex: 1;
    min-width: 0;
}
#modal-ajustar-stock .btn-select-item {
    flex-shrink: 0;
}

