/* =========================================
   1. CONTENEDOR Y ESTRUCTURA MAESTRA
   ========================================= */
.prod-main-container {
    padding: 15px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    max-width: 1200px;
    margin: 0 auto;
    padding-bottom: 90px; 
}

/* Resumen superior (Negro/Morado) */
.prod-summary-bar {
    background: #1a1a1a;
    color: white;
    padding: 12px 20px;
    border-radius: 10px;
    margin-bottom: 10px;
    display: flex;
    gap: 25px;
    font-size: 14px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    align-items: center;
}
.prod-summary-bar b { color: #bb86fc; }

/* =========================================
   2. BARRA DE HERRAMIENTAS Y BUSCADOR
   ========================================= */
.prod-controls-wrapper {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.prod-search-container { flex: 1; min-width: 250px; }

.prod-input-search {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border 0.3s;
}
.prod-input-search:focus { border-color: #71639e; }

.prod-btn-primary {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    background: #71639e;
    color: white;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}
.prod-btn-primary:hover { background: #5e5185; }

.prod-btn-sync {
    padding: 10px;
    border: none;
    border-radius: 8px;
    background: white;
    border: 1px solid #ddd;
    color: #71639e;
    cursor: pointer;
    transition: all 0.2s;
}

/* =========================================
   3. AGRUPADORES (ESTILO ODOO)
   ========================================= */
.prod-grouping-wrapper {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.prod-label-filter { font-size: 11px; font-weight: bold; color: #666; text-transform: uppercase; }

.prod-grouping-buttons {
    display: flex;
    gap: 5px;
    background: #eee;
    padding: 4px;
    border-radius: 10px;
}

.prod-btn-group {
    padding: 8px 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 7px;
    font-size: 11px;
    font-weight: bold;
    color: #666;
    transition: all 0.2s;
}

.prod-btn-group.active {
    background: white;
    color: #71639e;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Fila de Grupo (Toggle COM/DIR/Familia) */
.prod-group-row {
    background-color: #f1f0f7 !important;
    cursor: pointer;
}
.prod-group-row td {
    text-align: left !important;
    font-weight: bold;
    color: #71639e;
    padding: 12px 20px !important;
    font-size: 14px;
    border-bottom: 2px solid #71639e !important;
}

/* =========================================
   4. TABLA MAESTRA (DISEÑO LIMPIO)
   ========================================= */
.prod-table-responsive {
    width: 100%;
    overflow-x: auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.prod-table-master { width: 100%; border-collapse: collapse; min-width: 1000px; }

.prod-table-master th {
    background: #1a1a1a;
    color: white;
    padding: 14px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    text-align: center;
}

.prod-table-master td {
    padding: 12px;
    border-bottom: 1px solid #eee;
    font-size: 14px;
    vertical-align: middle;
    text-align: center;
}

.prod-table-master tr:hover:not(.prod-group-row) { background-color: #f0f0f5; transition: background 0.2s; }

/* Badges de Referencia y Stock */
.prod-ref-badge {
    background: #f0f0f5;
    color: #555;
    padding: 4px 8px;
    border-radius: 5px;
    font-family: monospace;
    font-size: 12px;
    border: 1px solid #e0e0e0;
}

.prod-stock-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 12px;
}
.prod-stock-positive { background: rgba(39, 174, 96, 0.1); color: #27ae60; }
.prod-stock-zero { background: rgba(192, 57, 43, 0.1); color: #c0392b; }

/* =========================================
   5. PAGINACIÓN AVANZADA (Estilo Etiquetas)
   ========================================= */
.prod-pagination-toolbar {
    margin-top: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    padding: 12px 20px;
    border-radius: 12px;
    border: 1px solid #eee;
    flex-wrap: wrap;
    gap: 15px;
}

.prod-pag-density, .prod-pag-jump {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #555;
}

.prod-select-pag {
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #ddd;
    background: white;
    font-weight: bold;
    color: #71639e;
    cursor: pointer;
    outline: none;
}

.prod-pag-nav {
    display: flex;
    align-items: center;
    gap: 5px;
}

.prod-btn-pag {
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
    border-radius: 8px;
    font-weight: bold;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.prod-btn-pag:hover:not(.active) { background: #f0f0f0; }

.prod-btn-pag.active {
    background: #71639e;
    color: white;
    border-color: #71639e;
}

/* =========================================
   6. MODALES (OVERLAY Y CONTENIDO)
   ========================================= */
.prod-modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.prod-modal-content {
    background: white;
    width: 90%;
    max-width: 500px; /* Se sobrescribe dinámicamente o con clases */
    padding: 35px;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.3);
    position: relative;
    animation: prodFadeIn 0.3s ease-out;
    transition: all 0.3s ease-in-out; /* Animación para el maximizado */
    max-height: 95vh;
    display: flex;
    flex-direction: column;
}

/* NUEVA CLASE: Modal Maximizado */
.prod-modal-maximized {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    padding: 40px !important;
}

.prod-modal-body {
    overflow-y: auto;
    flex-grow: 1;
    padding-right: 5px; /* Evitar que el scrollbar pegue en el contenido */
}

@keyframes prodFadeIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }

.prod-modal-header { text-align: center; margin-bottom: 20px; }
.prod-modal-header h3 { margin: 0; font-size: 20px; color: #333; text-transform: uppercase; }

/* NUEVA CLASE: Grid del Formulario */
.prod-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    text-align: left;
}

.prod-form-group { margin-bottom: 5px; }
.prod-form-group label {
    display: block;
    font-size: 12px;
    font-weight: bold;
    color: #666;
    margin-bottom: 5px;
    text-align: left;
}

.prod-form-control {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #ccc;
    font-size: 14px;
    outline: none;
    box-sizing: border-box; /* Previene desbordamiento en grid */
}
.prod-form-control:focus { border-color: #71639e; }

/* Ajuste específico para Datalists visualmente más limpios */
input[list]::-webkit-calendar-picker-indicator {
    color: #71639e;
    cursor: pointer;
    opacity: 0.6;
}
input[list]:hover::-webkit-calendar-picker-indicator { opacity: 1; }

.prod-modal-footer {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.prod-btn-cancel {
    flex: 1;
    padding: 14px;
    background: #e0e0e0;
    color: #444;
    border: none;
    border-radius: 10px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}
.prod-btn-cancel:hover { background: #d0d0d0; }

.prod-btn-confirm {
    flex: 1;
    padding: 14px;
    background: #71639e;
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    transition: background 0.2s;
}
.prod-btn-confirm:hover { background: #5e5185; }

/* Spinner */
.prod-loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #71639e;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: prodSpin 1s linear infinite;
    margin: 0 auto;
}

@keyframes prodSpin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Responsive */
@media (max-width: 768px) {
    .prod-form-row { flex-direction: column; }
    .prod-modal-content { padding: 20px; }
    .prod-pagination-toolbar { flex-direction: column; text-align: center; }
    
    /* Responsive Grid Form */
    .prod-form-grid { grid-template-columns: 1fr !important; }
    .prod-form-group[style*="grid-column: span 2"] { grid-column: span 1 !important; }
}