@import url('tablet_inventory.css');

.tools-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 25px 40px;
    margin-bottom: 25px;
    flex-shrink: 0;
    gap: 20px;
    flex-wrap: wrap;
    z-index: 20;
    position: relative;
    /* Asegurar stacking context */
    border-bottom: 1px solid #eee;
}

.tools-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
    min-width: 300px;
}

.tools-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.search-box {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.search-box i {
    position: absolute;
    left: 15px;
    top: 15px;
    color: #999;
    font-size: 18px;
}

.search-box input {
    padding-left: 45px !important;
    font-size: 16px !important;
    height: 50px;
    border-radius: 12px;
    border: 1px solid #ddd;
    width: 100%;
    box-sizing: border-box;
}

.filter-select {
    padding: 0 15px;
    border: 1px solid #ddd;
    border-radius: 12px;
    font-family: inherit;
    font-size: 15px;
    color: #555;
    cursor: pointer;
    height: 50px;
    background: white;
}

.btn-secondary {
    background: white;
    border: 1px solid #ddd;
    color: #555;
    padding: 12px 20px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    height: 50px;
}

.btn-primary {
    background: var(--vino);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    height: 50px;
    transition: 0.2s;
}

.btn-primary:hover {
    filter: brightness(1.1);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* Dropdown CSV */
.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 120%;
    background: white;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    width: 240px;
    z-index: 100;
    border: 1px solid #eee;
}

.dropdown-content a {
    display: block;
    padding: 16px;
    text-decoration: none;
    color: #333;
    font-size: 15px;
}

/* --- NAV SWITCH BUTTONS (View Editor) --- */
.nav-switch-container {
    display: flex;
    background: #f0f2f5;
    padding: 4px;
    border-radius: 12px;
    border: 1px solid #e1e4e8;
    gap: 4px;
}

.nav-switch-btn {
    padding: 10px 20px;
    /* Increased space */
    border: none;
    background: transparent;
    border-radius: 8px;
    color: #666;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    /* Increased gap */
    position: relative;
    /* Prevent width jump on bold */
    min-width: 100px;
    justify-content: center;
}

.nav-switch-btn.active {
    background: white;
    color: var(--vino);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    /* Use text-shadow instead of font-weight to prevent layout jumping */
    text-shadow: 0.5px 0 0 currentColor;
}

.nav-switch-btn:hover:not(.active) {
    background: #e9ecef;
}

/* --- ESTILOS MODAL EDITOR V2 (Flex Layout Structure) --- */
.prod-ed-content {
    display: flex !important;
    flex-direction: column !important;
    max-height: 85vh !important;
    /* Altura fija del modal */
    height: 85vh;
    padding: 0 !important;
    /* Reset padding to handle full width headers/footers */
    overflow: hidden !important;
    /* Evitar scroll global del modal */
}

.prod-ed-header {
    padding: 20px 30px;
    flex-shrink: 0;
    /* No encoger header */
}

.prod-ed-tabs-wrapper {
    flex-shrink: 0;
    padding-bottom: 10px;
}

.prod-ed-body {
    flex: 1;
    overflow: hidden;
    /* El scroll lo manejan los tabs */
    display: flex;
    flex-direction: column;
    padding: 0 30px;
}

#formProductEditor {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Default Tab Content (Scrollable like Basic Info) */
.prod-ed-tab-content {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
    /* Custom Scrollbar */
    padding-right: 5px;
}

.prod-ed-tab-content::-webkit-scrollbar {
    width: 6px;
}

.prod-ed-tab-content::-webkit-scrollbar-thumb {
    background: #e0e0e0;
    border-radius: 4px;
}

/* Specific Layout for Costos Tab (Fixed Internal Layout) - ONLY WHEN ACTIVE */
#tab-costos.active {
    overflow-y: hidden;
    /* Evitar scroll del tab, usar interno */
    display: flex;
    flex-direction: column;
}

.prod-ed-cost-grid {
    display: grid;
    grid-template-columns: 1fr 280px;
    /* Columna Izq Flexible - Col Der Fija */
    gap: 20px;
    height: 100%;
    /* Forzar altura completa */
    padding-bottom: 10px;
    box-sizing: border-box;
}

.prod-ed-footer {
    padding: 20px 30px;
    background: white;
    border-top: 1px solid #eee;
    flex-shrink: 0;
    z-index: 20;
}

.tab-btn {
    padding: 15px 5px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: #999;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: 0.2s;
}

.tab-btn.active {
    color: var(--vino);
    border-bottom-color: var(--vino);
}

.tab-btn:hover {
    color: #555;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

@media (max-width: 600px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: span 1 !important;
    }
}

.span-2 {
    grid-column: span 2;
}

.input-prefix {
    position: relative;
}

.input-prefix span {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-weight: bold;
}

.input-prefix input {
    padding-left: 25px !important;
}

.switch-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.switch-wrapper input {
    display: none;
}

.switch-wrapper .slider {
    width: 40px;
    height: 22px;
    background: #ccc;
    border-radius: 20px;
    position: relative;
    transition: 0.3s;
}

.switch-wrapper .slider:before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: 0.3s;
}

.switch-wrapper input:checked+.slider {
    background: var(--vino);
}

.switch-wrapper input:checked+.slider:before {
    transform: translateX(18px);
}

.switch-wrapper .label-text {
    font-size: 14px;
    font-weight: 500;
    color: #555;
}

/* Homogenized Trash Button Styles */
.btn-delete-ghost,
.btn-danger-ghost {
    background: #ffffff;
    color: #c0392b;
    border: 1px solid #f0f0f0;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    /* Reset padding for icon center */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.btn-delete-ghost:hover,
.btn-danger-ghost:hover {
    background: #f4f4f4;
    color: #c0392b;
    border-color: #e0e0e0;
    transform: scale(1.05);
}

.btn-delete-multi {
    background: #ffebee;
    color: #c0392b;
    border: 1px solid #c0392b;
    padding: 0 16px;
    height: 50px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    display: none;
    /* Controlled by JS */
    align-items: center;
    gap: 8px;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-delete-multi:hover {
    background: #c0392b;
    color: white;
    box-shadow: 0 4px 10px rgba(192, 57, 43, 0.3);
}

.empty-state-small {
    text-align: center;
    padding: 40px;
    color: #aaa;
    border: 2px dashed #eee;
    border-radius: 12px;
}

.empty-state-small i {
    font-size: 30px;
    margin-bottom: 10px;
    display: block;
}

/* --- ESTILOS MODAL EDITOR PRO --- */
.editor-tabs-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-btn {
    padding: 15px 5px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: #999;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: 0.2s;
    font-size: 14px;
}

.tab-btn.active {
    color: var(--vino);
    border-bottom-color: var(--vino);
}

.tab-btn:hover {
    color: #555;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

/* Tarjetas y Forms */
.form-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #eee;
    margin-bottom: 15px;
}

.card-title {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 15px;
}

/* Inputs de Imágenes */
.img-upload-group {
    display: flex;
    gap: 5px;
    align-items: center;
}

.btn-icon-upload {
    width: 45px;
    height: 45px;
    border-radius: 10px;
    border: 1px solid #ddd;
    background: #f9f9f9;
    color: #555;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon-upload:hover {
    background: #e8f5e9;
    color: #27ae60;
    border-color: #27ae60;
}

/* KPIs Financieros */
.kpi-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.kpi-card {
    background: white;
    padding: 15px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid #eee;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.kpi-label {
    font-size: 10px;
    font-weight: 800;
    color: #aaa;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.kpi-value {
    font-size: 20px;
    font-weight: 800;
    color: #333;
}

.kpi-value.text-gray {
    color: #7f8c8d;
}

.kpi-value.text-green {
    color: #27ae60;
}

.kpi-value.text-red {
    color: #c0392b;
}

/* Personalización (Estilo Tabla Limpia) */
.cms-group {
    border: 1px solid #eee;
    border-radius: 12px;
    margin-bottom: 15px;
    overflow: hidden;
    background: white;
}

.cms-header {
    background: #f8f9fa;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
}

.inp-clean {
    border: none;
    background: transparent;
    font-weight: 700;
    color: #333;
    font-size: 14px;
    width: 100%;
    outline: none;
}

.cms-table-header {
    display: flex;
    padding: 8px 15px;
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
    font-size: 10px;
    font-weight: 800;
    color: #aaa;
    gap: 10px;
}

.cms-body {
    padding: 10px 15px;
}

.cms-row {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
    align-items: center;
}

.form-control-sm {
    height: 36px;
    padding: 0 10px;
    font-size: 13px;
    border-radius: 8px;
    border: 1px solid #ddd;
    width: 100%;
    box-sizing: border-box;
}

.bg-gray {
    background: #f9f9f9;
    color: #777;
}

.btn-icon-sq {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid #eee;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
}

.btn-icon-sq:hover {
    background: #f0f0f0;
}

.text-danger {
    color: #c0392b;
}

.btn-add-option {
    width: 100%;
    padding: 8px;
    border: 2px dashed #eee;
    background: #fafafa;
    border-radius: 8px;
    color: #999;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    margin-top: 5px;
}

.btn-add-option:hover {
    border-color: #ccc;
    color: #555;
}

/* SAT Link */
.sat-link {
    font-size: 10px;
    color: #2980b9;
    text-decoration: none;
    margin-top: 2px;
    display: block;
}

@media (max-width: 600px) {

    .form-grid-2,
    .form-grid-3,
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .span-2-mobile {
        grid-column: span 1;
    }
}

.tab-io-btn {
    padding: 10px 15px;
    border: none;
    background: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-weight: 600;
    color: #999;
}

.tab-io-btn.active {
    color: var(--vino);
    border-bottom-color: var(--vino);
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-bottom: 1px solid #f9f9f9;
}

.check-row:last-child {
    border: none;
}

/* Lista de Plantillas */
.template-row:hover {
    background-color: #f9f9f9;
}

.template-row:last-child {
    border-bottom: none !important;
}

.editor-header-controls {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 25px;
    background: white;
    padding: 18px 25px;
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
}

/* --- SWITCH DE MODO (PESTAÑAS) --- */
.price-mode-switch {
    display: flex;
    background: #f0f2f5;
    padding: 4px;
    border-radius: 12px;
    border: 1px solid #e1e4e8;
}

.mode-btn {
    padding: 0 16px;
    height: 42px;
    border: none;
    background: transparent;
    border-radius: 8px;
    color: #666;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mode-btn.active {
    background: white;
    color: #5e1c26;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    font-weight: 800;
}

.mode-btn:hover:not(.active) {
    background: #e9ecef;
}

/* --- BOTÓN NUEVO (ESTILO VINO + REDONDEADO) --- */
/* --- BOTÓN NUEVO (REMOVED - Use .btn-primary) --- */
/* #btnNewProduct style removed to use standard .btn-primary */

/* --- TABLA (+10% TAMAÑO) --- */
.editor-table-container {
    background: white;
    border-radius: 16px;
    overflow-x: auto;
    /* Permitir scroll horizontal si es necesario */
    overflow-y: visible;
    /* No cortar verticalmente */
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.04);
    border: 1px solid #eee;
    margin-bottom: 50px;
    position: relative;
    z-index: 1;
}

.editor-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
    table-layout: fixed;
}

.editor-table th {
    background: #f8f9fa;
    color: #666;
    font-weight: 800;
    text-transform: uppercase;
    font-size: 11px;
    padding: 15px 12px;
    border-bottom: 2px solid #eee;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
    /* Alineación por defecto */
}

/* --- TABLET RESPONSIVENESS (1200px) --- */
@media (max-width: 1200px) {
    .tools-bar {
        flex-wrap: wrap;
        padding: 15px 20px;
        gap: 15px;
    }

    .tools-left,
    .tools-right {
        flex: 1 1 auto;
        min-width: 0;
        /* Allow shrinking */
    }

    .tools-left {
        width: 100%;
        /* Force full width on smaller tablets if needed, or let it wrap */
        order: 1;
    }

    .tools-right {
        width: 100%;
        justify-content: flex-end;
        order: 2;
    }

    /* Adjust Modal Grids */
    .form-grid-3 {
        grid-template-columns: 1fr 1fr;
        /* Reduce to 2 columns */
    }

    .img-upload-group {
        flex-wrap: wrap;
    }
}

@media (max-width: 768px) {
    .form-grid-3 {
        grid-template-columns: 1fr;
        /* Reduce to 1 column on mobile */
    }
}

/* Celdas */
.editor-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
    height: 60px;
}

.editor-table tr:hover {
    background: #fafafa;
}

.editor-table tr.row-selected {
    background: #fff5f7;
}

.editor-table tr.delivery-active td {
    background: #fffcf5;
    border-bottom-color: #fae5d3;
}

/* Alineación */
.th-center,
.td-center {
    text-align: center !important;
}

.th-right,
.td-right {
    text-align: right !important;
}

/* --- IMÁGENES BLINDADAS (SOLUCIÓN AL TAMAÑO) --- */
.img-wrapper {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    overflow: hidden;
    background: #eee;
    flex-shrink: 0;
}

.cell-img {
    width: 50px !important;
    height: 50px !important;
    max-width: 50px !important;
    max-height: 50px !important;
    object-fit: cover;
    display: block;
}

/* Inputs de Tabla */
.inp-table {
    width: 90px;
    height: 40px;
    padding: 0 10px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    text-align: right;
    font-weight: 600;
    color: #333;
    transition: border-color 0.2s;
}

.inp-table:focus {
    border-color: #5e1c26;
    outline: none;
    box-shadow: 0 0 0 3px rgba(94, 28, 38, 0.05);
}

.inp-cost {
    background: #fcfcfc;
    color: #666;
    font-weight: 500;
}

/* Select Categoría */
.sel-table {
    width: 100%;
    max-width: 160px;
    height: 40px;
    padding: 0 10px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    cursor: pointer;
}

/* Badges de Margen */
.margin-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 800;
    min-width: 50px;
}

.margin-high {
    background: #e8f5e9;
    color: #2e7d32;
}

.margin-mid {
    background: #fff8e1;
    color: #f57f17;
}

.margin-low {
    background: #ffebee;
    color: #c62828;
}

/* Botones Acción */
.btn-smart {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    color: #999;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-smart:hover {
    background: #f0f0f0;
    color: #333;
}

.btn-del-row:hover {
    background: #fee2e2;
    color: #c62828;
}

/* Drag & Drop */
.drag-handle {
    cursor: grab;
    color: #ccc;
    padding: 8px;
    font-size: 16px;
}

.drag-handle:active {
    cursor: grabbing;
    color: #5e1c26;
}

tr.dragging {
    opacity: 0.5;
    background: #eee;
}

tr.drop-target-top td {
    border-top: 2px solid #5e1c26 !important;
}

tr.drop-target-bottom td {
    border-bottom: 2px solid #5e1c26 !important;
}

/* --- 6. FOOTER DEL MODAL (ESTILOS NUEVOS Y ALINEACIÓN) --- */
.modal-actions-footer {
    display: flex;
    justify-content: space-between;
    /* Separa los extremos */
    align-items: center;
    gap: 15px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    width: 100%;
}

/* Botón Guardar (Vino, Grande, Redondo) */
#btnSaveProduct,
#modalProductEditor .btn-primary {
    background: #5e1c26 !important;
    color: white;
    flex: 1;
    /* Ocupa todo el espacio derecho */
    height: 50px;
    font-size: 15px;
    font-weight: 600;
    padding: 0 24px;
    border-radius: 12px;
    /* Redondo */
    border: none;
    box-shadow: 0 5px 15px rgba(94, 28, 38, 0.25);
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 0;
}

#btnSaveProduct:hover {
    background: #4a151e !important;
    transform: translateY(-2px);
}

/* Botón Eliminar (Cuadrado, Icono visible, Nombre oculto) */
#btnDeleteProduct {
    background: #fee2e2;
    color: #c0392b;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 12px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
    /* Oculta el texto "Eliminar" */
    cursor: pointer;
    transition: 0.2s;
    margin: 0;
}

#btnDeleteProduct i,
#btnDeleteProduct svg {
    font-size: 22px;
    /* Muestra el icono grande */
    pointer-events: none;
}

#btnDeleteProduct:hover {
    background: #c0392b;
    color: white;
}

/* Badges */
.margin-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 800;
    min-width: 45px;
}

.margin-high {
    background: #e8f5e9;
    color: #2e7d32;
}

.margin-mid {
    background: #fff8e1;
    color: #f57f17;
}

.margin-low {
    background: #ffebee;
    color: #c62828;
}

/* Responsive */
@media (max-width: 900px) {
    .inventory-dashboard {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .tools-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .inventory-dashboard {
        grid-template-columns: 1fr;
    }

    .form-grid-2,
    .form-grid-3,
    .option-row {
        grid-template-columns: 1fr;
    }
}

/* --- VARIABLES Y UTILIDADES --- */
:root {
    --vino: #5e1c26;
    --verde: #27ae60;
    --rojo: #c0392b;
    --azul: #2980b9;
    --gris-fondo: #f4f6f8;
    --borde: #e0e0e0;
}

/* --- CONTENEDOR PRINCIPAL --- */
.inventory-wrapper {
    display: grid;
    gap: 15px;
    padding-bottom: 20px;
}

/* --- TARJETA DE INSUMO (TABLA ESTILIZADA) --- */
.inv-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
    /* Espacio entre filas */
}

.inv-row {
    background: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
    transition:
        transform 0.2s,
        box-shadow 0.2s;
}

.inv-row:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    z-index: 10;
    position: relative;
}

.inv-row td {
    padding: 12px 15px;
    border-top: 1px solid var(--borde);
    border-bottom: 1px solid var(--borde);
    vertical-align: middle;
}

.inv-row td:first-child {
    border-left: 1px solid var(--borde);
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
}

.inv-row td:last-child {
    border-right: 1px solid var(--borde);
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
}

/* Estados de Alerta (Borde Izquierdo) */
.inv-row.stock-low td:first-child {
    border-left: 4px solid var(--naranja);
}

.inv-row.stock-crit td:first-child {
    border-left: 4px solid var(--rojo);
}

.inv-row.stock-ok td:first-child {
    border-left: 4px solid var(--verde);
}

/* --- INPUTS DENTRO DE TABLA --- */
.inv-inp {
    border: 1px solid transparent;
    background: transparent;
    font-size: 14px;
    padding: 5px;
    border-radius: 6px;
    width: 100%;
    transition: 0.2s;
}

.inv-inp:hover,
.inv-inp:focus {
    background: #f9f9f9;
    border-color: #ddd;
    outline: none;
}

.inv-inp.number {
    text-align: right;
    font-weight: 600;
    color: #555;
}

.inv-inp.cost {
    color: var(--vino);
    font-weight: 700;
}

/* --- BOTONES DE ACCIÓN --- */
.btn-action-group {
    display: flex;
    gap: 5px;
    justify-content: center;
}

.btn-mini {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: #f0f2f5;
    color: #777;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.btn-mini:hover {
    background: #e2e6ea;
    color: #333;
}

.btn-mini.provider {
    color: var(--azul);
    background: #ebf5fb;
}

.btn-mini.history {
    color: var(--morado);
    background: #f4ecf7;
}

.btn-mini.delete:hover {
    background: #fadbd8;
    color: var(--rojo);
}

/* --- MODAL DE AUDITORÍA --- */
.ia-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.ia-table th {
    background: #f8f9fa;
    padding: 10px;
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    text-align: center;
}

.ia-row {
    border-bottom: 1px solid #eee;
}

.ia-row td {
    padding: 10px;
}

.ia-inp {
    width: 80px;
    text-align: center;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 5px;
    font-weight: bold;
    font-size: 15px;
}

.ia-inp:focus {
    border-color: var(--azul);
    outline: none;
}

.diff-tag {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 800;
}

.diff-pos {
    background: #d4efdf;
    color: var(--verde);
}

/* Sobra */
.diff-neg {
    background: #fadbd8;
    color: var(--rojo);
}

/* Falta */
.diff-zero {
    background: #f0f0f0;
    color: #aaa;
}

/* --- MODAL DE LOTES (PEPS) --- */
.batch-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f0;
    position: relative;
    overflow: hidden;
}

.batch-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
}

.batch-fresh::before {
    background: var(--verde);
}

.batch-warning::before {
    background: var(--naranja);
}

.batch-expired::before {
    background: var(--rojo);
}

.batch-info h4 {
    margin: 0;
    font-size: 14px;
    color: #333;
}

.batch-info span {
    font-size: 11px;
    font-weight: 600;
    display: block;
    margin-top: 3px;
}

.batch-qty {
    text-align: right;
}

.batch-qty .num {
    font-size: 18px;
    font-weight: 800;
    color: var(--vino);
}

.batch-qty .lbl {
    font-size: 10px;
    color: #999;
}

/* --- ANIMACIONES REALTIME --- */

/* Flash al actualizar */
@keyframes highlight-update {
    0% {
        background-color: #fff9c4;
    }

    /* Amarillo suave */
    100% {
        background-color: white;
    }
}

.row-updated {
    animation: highlight-update 1.5s ease-out;
}

/* Entrada suave (Insert) */
@keyframes slide-in-row {
    from {
        opacity: 0;
        transform: translateY(-10px);
        background-color: #dcedc8;
        /* Verde muy suave */
    }

    to {
        opacity: 1;
        transform: translateY(0);
        background-color: white;
    }
}

.row-enter {
    animation: slide-in-row 0.6s ease-out forwards;
}

/* Salida suave (Delete) */
.row-exit {
    transition: all 0.5s ease;
    opacity: 0;
    transform: translateX(20px);
    background-color: #ffcdd2;
    /* Rojo suave */
    height: 0 !important;
    padding: 0 !important;
    border: none !important;
}

/* --- EDITOR GRID (REEMPLAZO DE ESTILOS INLINE) --- */
.editor-scroll-container {
    flex: 1;
    overflow-y: auto;
    padding: 0 5px;
}

.editor-grid-wrapper {
    display: grid;
    gap: 10px;
    padding-bottom: 20px;
    /* Reducido para evitar espacio gris excesivo */
}

/* --- ESTILOS MIGRADOS DE JS (EDITOR & INVENTARIO) --- */

/* Editor: Estados Vacíos */
.empty-state-editor {
    text-align: center;
    padding: 50px;
    color: #999;
}

/* Editor: Columnas Fijas */
.col-w-40 {
    width: 40px;
}

.col-w-60 {
    width: 60px;
}

.col-w-80 {
    width: 80px;
}

.col-w-100 {
    width: 100px;
}

.col-w-110 {
    width: 110px;
}

.col-w-120 {
    width: 120px;
}

.col-w-150 {
    width: 150px;
}

/* Editor: Bloques de Información */
.cost-block {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.cost-label {
    font-size: 9px;
    font-weight: 800;
    color: #aaa;
}

.cost-value {
    font-size: 16px;
    font-weight: 800;
    color: #5e1c26;
}

.cost-sub {
    font-size: 9px;
    color: #999;
}

.stock-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stock-val {
    font-size: 18px;
    font-weight: 800;
    color: #333;
    line-height: 1;
}

.stock-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 3px;
    white-space: nowrap;
}

.stock-badge-ok {
    color: #27ae60;
    background: #e8f5e9;
}

.stock-badge-low {
    color: #e67e22;
    background: #fff8e1;
}

.stock-badge-out {
    color: #c0392b;
    background: #ffebee;
}

.badge-margin {
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 11px;
    color: white;
}

.badge-green {
    background-color: #27ae60;
}

.badge-orange {
    background-color: #e67e22;
}

.badge-red {
    background-color: #c0392b;
}

/* Editor: Inputs y Celdas */
.inp-delivery {
    border-color: #e67e22;
    color: #d35400;
    font-weight: 700;
}

.inp-price-main {
    border-color: #27ae60;
    color: #27ae60;
    font-weight: 700;
}

.inp-price-old {
    color: #999;
}

.price-display {
    color: #999;
    font-size: 13px;
}

.cell-drag {
    color: #ddd;
    cursor: move;
}

.cell-img-thumb {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
}

.cell-prod-name {
    font-weight: bold;
    color: #333;
}

/* --- ACTIONS GROUP (Shared) --- */
.btn-action-group,
.cell-actions {
    display: flex;
    justify-content: center;
    gap: 5px;
}

.btn-production {
    background: #27ae60;
    color: white;
}

.btn-mini {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid #ddd;
    background: white;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
    font-size: 13px;
}

.btn-mini:hover {
    background: #f0f0f0;
    color: #333;
    border-color: #ccc;
}

.btn-mini.delete:hover {
    background: #ffebee;
    color: #c0392b;
    border-color: #c0392b;
}

/* Inventario: Tablas y Listas */
.inv-header-row {
    color: #999;
    font-size: 11px;
    text-transform: uppercase;
}

.inv-th-left {
    text-align: left;
    padding-left: 5px;
}

.inv-col-30 {
    width: 30px;
}

.inv-col-100 {
    width: 100px;
}

.inv-col-120 {
    width: 120px;
}

.inv-cell-drag {
    text-align: center;
    cursor: move;
    color: #ccc;
}

.inv-cell-check {
    text-align: center;
}

.inv-name-wrapper {
    font-weight: bold;
}

.inv-alert-low {
    font-size: 10px;
    color: var(--rojo);
    margin-top: 2px;
}

.inv-stock-group {
    display: flex;
    align-items: center;
    gap: 5px;
    justify-content: flex-end;
}

/* Inventario: Lotes (Batch) */
.batch-loading {
    padding: 20px;
    text-align: center;
    color: #ccc;
}

.batch-empty {
    padding: 30px;
    text-align: center;
    color: #999;
    font-size: 13px;
}

.batch-item {
    padding: 12px 20px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.batch-code {
    font-weight: bold;
    color: #333;
    font-size: 13px;
}

.batch-meta {
    font-size: 11px;
}

.batch-val {
    font-size: 16px;
    font-weight: 700;
    color: #5e1c26;
}

.text-green {
    color: #27ae60;
}

.text-orange {
    color: #e67e22;
}

.text-red {
    color: #c0392b;
}

/* --- ESTILOS MIGRADOS DE JS (PRODUCT FORM) --- */

/* CMS Customizations */
.cms-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.cms-icon-layer {
    color: #ccc;
}

.cms-header-actions {
    display: flex;
    gap: 5px;
}

.btn-cloud-save {
    color: #2980b9;
    background: #ebf5fb;
}

.col-opt-name {
    flex: 2;
}

.col-opt-price {
    width: 70px;
    text-align: center;
}

.col-opt-action {
    width: 40px;
    text-align: center;
}

/* Cloud Templates Modal */
.template-list-loading {
    text-align: center;
    padding: 20px;
}

.template-list-empty {
    text-align: center;
    padding: 20px;
    color: #999;
}

.template-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.template-meta {
    font-size: 11px;
    color: #888;
}

.template-actions {
    display: flex;
    gap: 5px;
}

.btn-use-template {
    color: #27ae60;
}

.template-error {
    color: red;
}

/* Forced Modal Overlay (Fix Visual) */
.modal-overlay-forced {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 20000;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
}

/* Recipe Table */
.recipe-empty-msg {
    font-size: 11px;
}

.recipe-row {
    border-bottom: 1px solid #f0f0f0;
}

.recipe-cell-name {
    padding: 8px 15px;
}

.recipe-text-name {
    font-weight: 600;
    color: #333;
}

.recipe-cell-qty {
    padding: 8px 10px;
    text-align: center;
}

.recipe-unit {
    color: #999;
}

.recipe-cell-cost {
    padding: 8px 15px;
    text-align: right;
    font-weight: 700;
    color: #5e1c26;
}

.recipe-cell-action {
    padding: 8px 5px;
    text-align: center;
}

/* Tax Info */
.tax-info-small {
    color: #666;
}

/* --- ESTILOS MIGRADOS DE JS (EDITOR & INVENTARIO) --- */

/* Editor: Estados Vacíos */
.empty-state-editor {
    text-align: center;
    padding: 50px;
    color: #999;
}

/* Editor: Columnas Fijas */
.col-w-40 {
    width: 40px;
}

.col-w-60 {
    width: 60px;
}

.col-w-80 {
    width: 80px;
}

.col-w-100 {
    width: 100px;
}

.col-w-110 {
    width: 110px;
}

.col-w-120 {
    width: 120px;
}

.col-w-150 {
    width: 150px;
}

/* Editor: Bloques de Información */
.cost-block {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.cost-label {
    font-size: 9px;
    font-weight: 800;
    color: #aaa;
}

.cost-value {
    font-size: 16px;
    font-weight: 800;
    color: #5e1c26;
}

.cost-sub {
    font-size: 9px;
    color: #999;
}

.stock-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stock-val {
    font-size: 18px;
    font-weight: 800;
    color: #333;
    line-height: 1;
}

.stock-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 3px;
    white-space: nowrap;
}

.stock-badge-ok {
    color: #27ae60;
    background: #e8f5e9;
}

.stock-badge-low {
    color: #e67e22;
    background: #fff8e1;
}

.stock-badge-out {
    color: #c0392b;
    background: #ffebee;
}

.badge-margin {
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 11px;
    color: white;
}

.badge-green {
    background-color: #27ae60;
}

.badge-orange {
    background-color: #e67e22;
}

.badge-red {
    background-color: #c0392b;
}

/* Editor: Inputs y Celdas */
.inp-delivery {
    border-color: #e67e22;
    color: #d35400;
    font-weight: 700;
}

.inp-price-main {
    border-color: #27ae60;
    color: #27ae60;
    font-weight: 700;
}

.inp-price-old {
    color: #999;
}

.price-display {
    color: #999;
    font-size: 13px;
}

.cell-drag {
    color: #ddd;
    cursor: move;
}

.cell-img-thumb {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
}

.cell-prod-name {
    font-weight: bold;
    color: #333;
}

.cell-actions {
    display: flex;
    justify-content: center;
    gap: 5px;
}

.btn-production {
    background: #27ae60;
    color: white;
}

/* Inventario: Tablas y Listas */
.inv-header-row {
    color: #999;
    font-size: 11px;
    text-transform: uppercase;
}

.inv-th-left {
    text-align: left;
    padding-left: 5px;
}

.inv-col-30 {
    width: 30px;
}

.inv-col-100 {
    width: 100px;
}

.inv-col-120 {
    width: 120px;
}

.inv-cell-drag {
    text-align: center;
    cursor: move;
    color: #ccc;
}

.inv-cell-check {
    text-align: center;
}

.inv-name-wrapper {
    font-weight: bold;
}

.inv-alert-low {
    font-size: 10px;
    color: var(--rojo);
    margin-top: 2px;
}

.inv-stock-group {
    display: flex;
    align-items: center;
    gap: 5px;
    justify-content: flex-end;
}

/* Inventario: Lotes (Batch) */
.batch-loading {
    padding: 20px;
    text-align: center;
    color: #ccc;
}

.batch-empty {
    padding: 30px;
    text-align: center;
    color: #999;
    font-size: 13px;
}

.batch-item {
    padding: 12px 20px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.batch-code {
    font-weight: bold;
    color: #333;
    font-size: 13px;
}

.batch-meta {
    font-size: 11px;
}

.batch-val {
    font-size: 16px;
    font-weight: 700;
    color: #5e1c26;
}

.text-green {
    color: #27ae60;
}

.text-orange {
    color: #e67e22;
}

.text-red {
    color: #c0392b;
}

/* CSV DROPDOWN */
.csv-dropdown-container {
    position: relative;
    display: inline-block;
}

.csv-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    min-width: 200px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    border-radius: 12px;
    overflow: hidden;
    padding: 8px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transform-origin: top right;
    animation: dropdownSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.csv-menu button {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 10px 15px;
    border: none;
    background: none;
    text-align: left;
    font-family: 'Montserrat', sans-serif;
    font-size: 13px;
    color: #444;
    cursor: pointer;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.2s;
}

.csv-menu button:hover {
    background: #f8f9fa;
    color: var(--vino);
    padding-left: 18px;
}

.csv-menu button i {
    width: 20px;
    margin-right: 12px;
    color: #888;
    font-size: 14px;
    transition: 0.2s;
}

.csv-menu button:hover i {
    color: var(--vino);
}

/* CUSTOM CATEGORY DROPDOWN */
.cat-dropdown {
    position: relative;
    min-width: 210px;
}

.cat-dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 18px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    color: #444;
    transition: all 0.2s;
}

.cat-dropdown-trigger:hover {
    border-color: var(--vino);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.cat-dropdown-trigger i.fa-chevron-down {
    font-size: 11px;
    color: #aaa;
    transition: 0.3s;
}

.cat-dropdown.active .cat-dropdown-trigger i.fa-chevron-down {
    transform: rotate(180deg);
}

.cat-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: white;
    min-width: 240px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    border-radius: 12px;
    padding: 8px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transform-origin: top left;
    animation: dropdownSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.cat-item {
    padding: 11px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s;
}

.cat-item:hover {
    background: #f8f9fa;
    color: var(--vino);
    padding-left: 18px;
}

.cat-item.active {
    background: #fdf2f4;
    color: var(--vino);
}

.cat-item i {
    font-size: 10px;
    opacity: 0;
    transition: 0.2s;
}

.cat-item.active i {
    opacity: 1;
}

/* TABLE PADDING & SPACING */
#view-editor,
#view-inventory {
    padding: 0 0 50px 0 !important;
    overflow-x: hidden;
    overflow-y: auto;
}

#view-editor .editor-grid-wrapper,
#view-inventory #suppliesGridContainer {
    max-width: 1650px;
    margin-left: auto;
    margin-right: auto;
    padding: 0 40px;
    width: 100%;
}

.editor-grid-wrapper {
    margin-top: 5px;
}

.editor-table-container {
    border: 1px solid #eee;
    border-radius: 16px;
    overflow-x: auto;
    overflow-y: hidden;
    background: white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
}

.editor-table-container::-webkit-scrollbar {
    height: 6px;
}

.editor-table-container::-webkit-scrollbar-thumb {
    background: #eee;
    border-radius: 10px;
}

.editor-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.editor-table th {
    background: #fdfdfd;
    padding: 15px 12px;
    text-align: left;
    font-weight: 700;
    color: #999;
    font-size: 11px;
    text-transform: uppercase;
    border-bottom: 1px solid #eee;
}

.editor-table td {
    padding: 12px;
    border-bottom: 1px solid #f9f9f9;
    vertical-align: middle;
}

.editor-table tr:last-child td {
    border-bottom: none;
}

.editor-table tr:hover {
    background: #fcfcfc;
}

.td-center {
    text-align: center;
}

.td-right {
    text-align: right;
}

.th-center {
    text-align: center;
}

.th-right {
    text-align: right;
}

.inp-table,
.sel-table {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #444;
    transition: 0.2s;
    background: #fff;
}

.inp-table:focus,
.sel-table:focus {
    border-color: var(--vino);
    outline: none;
}

/* Inline Editing Style */
.inp-inline {
    border: 1px solid transparent;
    background: transparent;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 700;
    color: #333;
    width: 100%;
    transition: 0.2s;
    font-family: inherit;
    font-size: 14px;
}

.inp-inline:hover {
    background: #f5f5f5;
    border-color: #eee;
}

.inp-inline:focus {
    background: white;
    border-color: var(--vino);
    outline: none;
    box-shadow: 0 0 0 3px rgba(94, 28, 38, 0.05);
}

.sel-table {
    cursor: pointer;
    padding-right: 25px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23999' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C2.185 5.355 2.403 5 2.8 5h9.4c.397 0 .615.355.348.658l-4.796 5.482a.5.5 0 0 1-.748 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

/* CSS for the new status column */
.col-w-30 {
    width: 30px;
}

.status-indicator {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: help;
}

.status-icon {
    font-size: 16px;
    font-weight: 900;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.status-indicator:hover .status-icon {
    transform: scale(1.2);
}

.status-icon.vino {
    color: #5e1c26;
}

.status-icon.red {
    color: #e74c3c;
}

.status-icon.orange {
    color: #e67e22;
}

.status-icon.green {
    color: #27ae60;
}

.status-indicator .tooltip {
    visibility: hidden;
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%) translateY(5px);
    background-color: #333;
    color: #fff;
    text-align: center;
    padding: 6px 12px;
    border-radius: 8px;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 600;
    z-index: 1001;
    opacity: 0;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

.status-indicator .tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

.status-indicator:hover .tooltip {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.btn-action-group {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.drag-handle {
    cursor: move;
    color: #ddd;
}

@keyframes dropdownSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* --- CUSTOM SEARCHABLE DROPDOWN (Recipe Selection) --- */
.custom-select-wrapper {
    position: relative;
    user-select: none;
    width: 100%;
}

.custom-select-trigger {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    font-size: 13px;
    height: 40px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s;
    color: #444;
}

.custom-select-trigger:hover {
    border-color: #aaa;
}

.custom-select-trigger span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.custom-dropdown-menu {
    position: absolute;
    bottom: calc(100% + 5px);
    /* Espacio fijo hacia ARRIBA */
    left: 0;
    width: 100%;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid #eee;
    z-index: 100;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: fadeIn 0.2s ease;
}

.custom-dropdown-menu.active {
    display: flex;
}

.dropdown-search-box {
    padding: 10px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    position: relative;
}

.dropdown-search-box input {
    width: 100%;
    padding: 8px 10px 8px 30px;
    border-radius: 6px;
    border: 1px solid #ddd;
    font-size: 12px;
    box-sizing: border-box;
}

.dropdown-search-box i {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 12px;
}

.dropdown-options-list {
    max-height: 200px;
    overflow-y: auto;
}

.dropdown-option {
    padding: 10px 15px;
    border-bottom: 1px solid #f9f9f9;
    cursor: pointer;
    font-size: 12px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.1s;
}

.dropdown-option:hover {
    background: #f0f7ff;
    color: #5e1c26;
}

.dropdown-option:last-child {
    border-bottom: none;
}

.dropdown-option.selected {
    background: #eef2f6;
    font-weight: 600;
}

/* Scrollbar for options */
.dropdown-options-list::-webkit-scrollbar {
    width: 6px;
}

.dropdown-options-list::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 4px;
}

/* FIX: Left Column Layout using Flex for Scroll + Fixed Bottom Bar */
/* FIX: Left Column Layout using Flex for Scroll + Fixed Bottom Bar */
.prod-ed-left-col {
    display: flex;
    flex-direction: column;
    height: 100%;
    /* Ocupar todo el alto disponible del grid */
    justify-content: space-between;
    position: relative;
    padding-bottom: 0px;
    overflow: hidden;
    /* Contener el scroll interno */
}

.prod-ed-scrollable-content {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 15px;
    padding-right: 5px;
}

/* Scrollbar for the content area */
.prod-ed-scrollable-content::-webkit-scrollbar {
    width: 6px;
}

.prod-ed-scrollable-content::-webkit-scrollbar-thumb {
    background: #e0e0e0;
    border-radius: 4px;
}

/* Add bar is simply at the bottom now */
.prod-ed-add-bar {
    background: white;
    box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.05);
    z-index: 10;
    border-radius: 12px;
    padding: 10px;
    border: 1px solid #eee;
    margin-top: 5px;
    margin-bottom: 20px;
    /* Lift it up specifically */
    flex-shrink: 0;
}

/* --- RIGHT COLUMN & COST ANALYSIS --- */
.prod-ed-right-col {
    background: #f8f9fa;
    /* Fondo gris muy suave */
    border: 1px solid #eee;
    border-radius: 20px;
    /* BORDES REDONDOS */
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: 100%;
    /* Llenar la altura */
    box-sizing: border-box;
    /* IMPORTANT: Evitar overflow por padding */
}

.prod-ed-analysis-title {
    margin: 0;
    font-size: 14px;
    font-weight: 800;
    color: #333;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.prod-ed-label {
    font-size: 11px;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    margin-bottom: 5px;
    display: block;
}

/* Portion Selector - Unified Group Look */
.prod-ed-slices {
    display: flex;
    align-items: center;
    background: white;
    border: 1px solid #ddd;
    border-radius: 20px;
    /* Pill shape */
    padding: 0;
    /* Remove padding to merge buttons */
    justify-content: space-between;
    margin-bottom: 5px;
    overflow: hidden;
    /* Contain children */
    width: 100%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.btn-qty-mini {
    width: 40px;
    height: 32px;
    border: none;
    background: transparent;
    color: #888;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    font-size: 16px;
}

.btn-qty-mini:hover {
    background: #f5f5f5;
    color: var(--vino);
}

.inp-qty-mini {
    border: none;
    text-align: center;
    font-weight: 800;
    color: #333;
    flex: 1;
    /* Take remaining space */
    font-size: 16px;
    background: transparent;
    height: 32px;
}

.inp-qty-mini:focus {
    outline: none;
}

.prod-ed-note {
    font-size: 10px;
    color: #999;
    padding-left: 5px;
}

/* New Button Style for Table Rows */
.btn-danger-ghost-sm {
    background: #ffffff;
    color: #c0392b;
    border: 1px solid #f0f0f0;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-danger-ghost-sm:hover {
    background: #f4f4f4;
    /* Homologated Gray Effect */
    color: #c0392b;
    border-color: #e0e0e0;
    transform: scale(1.05);
}

.prod-ed-cost-card {
    background: white;
    border-radius: 16px;
    /* Borde interno tambien redondo */
    padding: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    border: 1px solid #f0f0f0;
    margin-top: auto;
    /* Empujar al fondo */
}

.prod-ed-cost-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #666;
    margin-bottom: 6px;
}

.prod-ed-divider {
    height: 1px;
    background: #eee;
    margin: 10px 0;
    border-top: 1px dashed #ddd;
    /* Estilo ticket */
}

.prod-ed-total-cost {
    text-align: center;
}

.prod-ed-total-val {
    font-size: 24px;
    font-weight: 900;
    color: var(--vino);
    line-height: 1;
    margin-top: 5px;
    letter-spacing: -0.5px;
}

/* =========================================
   DEFINITIVE MOBILE OVERRIDES (FORCE PRIORITY)
   ========================================= */
@media (max-width: 768px) {
    body .tools-bar {
        display: block !important;
        padding: 12px 16px !important;
        /* Increased from 5px 12px */
        height: auto !important;
        width: 100% !important;
        box-sizing: border-box !important;
        background: #fff !important;
        margin: 0 !important;
    }

    body .tools-left {
        display: block !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* FILA 1: Switch (100% width) */
    body .nav-switch-container {
        width: 100% !important;
        display: flex !important;
        height: 38px !important;
        margin: 0 0 10px 0 !important;
        /* Increased from 6px */
        border-radius: 8px !important;
        padding: 2px !important;
        background: #f1f5f9 !important;
        box-sizing: border-box !important;
    }

    body .nav-switch-btn {
        flex: 1 !important;
        height: 34px !important;
        font-size: 13px !important;
        min-width: 0 !important;
        /* Reset desktop fix */
        padding: 0 5px !important;
    }

    /* FILA 2: BUSCADOR (32px height, 100% width) */
    body .search-box {
        width: 100% !important;
        max-width: 100% !important;
        height: 36px !important;
        /* Increased from 32px */
        margin: 0 0 10px 0 !important;
        /* Increased from 6px */
        display: block !important;
        position: relative !important;
    }

    body .search-box i {
        position: absolute !important;
        left: 10px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        z-index: 10 !important;
        font-size: 14px !important;
    }

    body .search-box input {
        width: 100% !important;
        height: 36px !important;
        /* Increased from 32px */
        padding: 0 10px 0 35px !important;
        border-radius: 6px !important;
        background: #f8fafc !important;
        border: 1px solid #e1e4e8 !important;
        font-size: 14px !important;
        box-sizing: border-box !important;
    }

    /* FILA 3: CATEGORY SELECTOR (32px height, 100% width) */
    body #catDropdown.cat-dropdown {
        width: 100% !important;
        max-width: 100% !important;
        height: 36px !important;
        /* Increased from 32px */
        display: block !important;
        margin: 0 0 12px 0 !important;
        /* Increased from 6px */
        padding: 0 !important;
    }

    body #catDropdown .cat-dropdown-trigger {
        width: 100% !important;
        height: 36px !important;
        /* Increased from 32px */
        padding: 0 12px !important;
        border-radius: 6px !important;
        border: 1px solid #e1e4e8 !important;
        background: #f8fafc !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        box-sizing: border-box !important;
    }

    body #activeCatLabel {
        font-size: 13px !important;
        color: #4a5568 !important;
    }

    /* FILA 4: ACTIONS (DISTRIBUTED LEFT/RIGHT) */
    body#view-editor .tools-right,
    body .tools-right {
        display: flex !important;
        flex-direction: row !important;
        width: 100% !important;
        border-top: 1px solid #f1f5f9 !important;
        padding-top: 8px !important;
        gap: 8px !important;
        justify-content: center !important;
        /* Base centering container */
    }

    body #editorToolbarProducts,
    body #editorToolbarSupplies {
        display: none;
        width: 100% !important;
        gap: 8px !important;
        align-items: center !important;
        justify-content: space-between !important;
    }

    /* TOGGLE VISIBILITY BASED ON APP STATE */
    body.mode-products #editorToolbarProducts {
        display: flex !important;
    }

    body.mode-supplies #editorToolbarSupplies {
        display: flex !important;
    }

    /* LEFT GROUP (DEFAULT FLOW) */
    body .price-mode-switch,
    body .btn-audit {
        margin-left: 0 !important;
    }

    /* RIGHT GROUP PUSHERS (First item of the right group) */
    body .csv-dropdown-container {
        margin-left: auto !important;
    }

    body .btn-delete-multi {
        display: none !important;
        /* HIDE TRASH ON MOBILE */
    }

    body .btn-secondary,
    body .btn-primary {
        height: 36px !important;
        width: 36px !important;
        font-size: 0 !important;
        border-radius: 8px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0 !important;
    }

    body .btn-secondary i,
    body .btn-primary i {
        margin: 0 !important;
        font-size: 16px !important;
    }

    /* 2. TABLE DIMENSIONS, BORDERS & SCROLL */
    body#view-editor,
    body .view-section {
        height: 100% !important;
        overflow: hidden !important;
    }

    body .editor-scroll-area,
    body .editor-grid-wrapper {
        flex: 1 !important;
        overflow-y: auto !important;
        padding: 0 !important;
        -webkit-overflow-scrolling: touch;
    }

    body .editor-scroll-area {
        padding-bottom: 120px !important;
    }

    body .editor-table-container {
        width: calc(100% - 24px) !important;
        margin: 10px 12px !important;
        border-radius: 12px !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
        border: 1px solid #eee !important;
        overflow-x: auto !important;
        background: #fff !important;
    }

    /* 1. GLOBAL TABLE (PRODUCTS): AUTO LAYOUT */
    body .editor-table {
        width: 100% !important;
        min-width: auto !important;
        table-layout: auto !important;
        border-collapse: separate !important;
        border-spacing: 0 !important;
    }

    /* 2. TARGETED SUPPLIES FIX: FIXED LAYOUT WITH EXPLICIT COLUMN WIDTHS */
    #suppliesGridContainer .editor-table {
        min-width: 750px !important;
        table-layout: fixed !important;
    }

    /* Target every specific column class in Supplies to prevent squashing */
    #suppliesGridContainer .editor-table .col-w-40 {
        width: 35px !important;
    }

    #suppliesGridContainer .editor-table .td-center:has(.chk-select) {
        width: 35px !important;
    }

    #suppliesGridContainer .editor-table .col-w-60 {
        width: 55px !important;
    }

    #suppliesGridContainer .editor-table .col-prod-name {
        width: 250px !important;
    }

    #suppliesGridContainer .editor-table .col-w-150 {
        width: 100px !important;
    }

    #suppliesGridContainer .editor-table .col-w-100 {
        width: 80px !important;
    }

    #suppliesGridContainer .editor-table .col-status {
        width: 40px !important;
    }

    #suppliesGridContainer .editor-table .col-stock {
        width: 90px !important;
    }

    #suppliesGridContainer .editor-table .col-actions {
        width: 100px !important;
    }

    body .editor-table td {
        padding: 8px 6px !important;
        height: auto !important;
        white-space: nowrap !important;
    }

    body .editor-table th {
        padding: 12px 6px !important;
        font-size: 13px !important;
        /* VISIBLE HEADERS */
        font-weight: 800 !important;
        color: #1a202c !important;
        /* DARKER FOR MAXIMUM CONTRAST */
        white-space: nowrap !important;
        text-transform: uppercase !important;
        background: #fdfdfd !important;
    }

    /* LEGIBILITY: NAME COLUMN WRAPPING */
    body .cell-prod-name {
        font-size: 15px !important;
        font-weight: 600 !important;
        white-space: normal !important;
        padding-right: 15px !important;
    }

    body .cell-prod-name .inp-inline {
        font-size: 15px !important;
        font-weight: 700 !important;
        padding: 4px 0 !important;
        width: 100% !important;
    }

    /* THUMBNAILS */
    body .cell-img-thumb,
    body .cell-img {
        width: 42px !important;
        height: 42px !important;
        border-radius: 6px !important;
    }
}