/**
 * BLGROUP - Interfaz de Fabricación
 * Diseño Minimalista - Blanco, Gris, Naranja (#FA7921)
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #FA7921;
    --primary-light: #FFE8D6;
    --primary-dark: #E06A1B;
    --white: #FFFFFF;
    --gray-50: #FAFAFA;
    --gray-100: #F5F5F5;
    --gray-200: #EEEEEE;
    --gray-300: #E0E0E0;
    --gray-400: #BDBDBD;
    --gray-500: #9E9E9E;
    --gray-600: #757575;
    --gray-700: #616161;
    --gray-800: #424242;
    --gray-900: #212121;
    --success: #4CAF50;
    --error: #E53935;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    overflow: hidden;
    font-size: 16px;
}

.container {
    display: flex;
    height: 100vh;
}

/* ==== PANEL IZQUIERDO - PRODUCTOS ==== */
.products-panel {
    width: 58%;
    background: var(--white);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--gray-200);
}

.panel-header {
    background: var(--white);
    padding: 24px 32px;
    border-bottom: 3px solid var(--primary);
}

.panel-header h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.panel-header .subtitle {
    font-size: 18px;
    color: var(--primary);
    font-weight: 500;
}

/* ==== BARRA DE BÚSQUEDA ==== */
.search-container {
    margin-top: 16px;
}

.search-input {
    width: 100%;
    padding: 14px 20px;
    font-size: 18px;
    border: 2px solid var(--gray-300);
    border-radius: 10px;
    background: var(--white);
    color: var(--gray-800);
    transition: all 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(250, 121, 33, 0.1);
}

.search-input::placeholder {
    color: var(--gray-400);
}

.product-card.hidden {
    display: none;
}

.products-grid {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    align-content: start;
    background: var(--gray-50);
}

.product-card {
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    padding: 24px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.product-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 20px rgba(250, 121, 33, 0.15);
}

.product-card.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

.product-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-800);
    line-height: 1.4;
}

.product-code {
    font-size: 14px;
    color: var(--gray-500);
    margin-top: 8px;
    font-family: 'SF Mono', Monaco, monospace;
}

/* ==== PANEL DERECHO - DETALLES ==== */
.details-panel {
    width: 42%;
    background: var(--gray-50);
    display: flex;
    flex-direction: column;
}

.details-header {
    background: var(--white);
    padding: 24px 28px;
    border-bottom: 1px solid var(--gray-200);
}

.details-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.datetime {
    font-size: 16px;
    color: var(--gray-500);
}

.details-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.empty-state {
    text-align: center;
    padding: 80px 24px;
    color: var(--gray-400);
}

.empty-state-icon {
    font-size: 72px;
    margin-bottom: 24px;
    opacity: 0.4;
}

.empty-state-text {
    font-size: 20px;
    color: var(--gray-500);
}

/* ==== PRODUCTO SELECCIONADO ==== */
.selected-product {
    background: var(--white);
    border-radius: 16px;
    padding: 28px;
    margin-bottom: 20px;
    border: 1px solid var(--gray-200);
}

.selected-product h3 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--gray-200);
}

.quantity-input-group {
    margin-top: 20px;
}

.quantity-input-group label {
    display: block;
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 12px;
}

.quantity-input-group input {
    width: 100%;
    padding: 20px;
    font-size: 36px;
    font-weight: 700;
    border: 2px solid var(--gray-300);
    border-radius: 12px;
    text-align: center;
    color: var(--gray-900);
    background: var(--white);
    transition: all 0.2s ease;
}

.quantity-input-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(250, 121, 33, 0.1);
}

/* ==== COMPONENTES ==== */
.components-section {
    background: var(--white);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid var(--gray-200);
}

.components-section h4 {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-700);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.component-item {
    padding: 16px 20px;
    margin-bottom: 10px;
    background: var(--gray-50);
    border-radius: 10px;
    border-left: 4px solid var(--gray-300);
    transition: all 0.2s ease;
}

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

.component-item.insufficient {
    background: #FFF8F8;
    border-left-color: var(--error);
}

.component-item.sufficient {
    background: #F8FFF8;
    border-left-color: var(--success);
}

.component-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.component-name {
    font-size: 17px;
    font-weight: 600;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.component-qty-per-unit {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
}

/* ==== ICONO DE CANDADO MINIMALISTA ==== */
.lock-btn {
    width: 28px;
    height: 28px;
    border: 2px solid var(--gray-300);
    border-radius: 6px;
    background: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.lock-btn:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.lock-btn.locked {
    border-color: var(--primary);
    background: var(--primary);
}

.lock-btn .lock-icon {
    width: 14px;
    height: 14px;
    stroke: var(--gray-500);
    stroke-width: 2;
    fill: none;
}

.lock-btn.locked .lock-icon {
    stroke: var(--white);
}

/* Botón de edición de cantidad */
.edit-btn {
    width: 28px;
    height: 28px;
    border: 2px solid var(--gray-300);
    border-radius: 6px;
    background: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-left: 4px;
}

.edit-btn:hover {
    border-color: #2196F3;
    background: #E3F2FD;
}

.edit-btn.editing {
    border-color: #2196F3;
    background: #2196F3;
}

.edit-btn .edit-icon {
    width: 14px;
    height: 14px;
    stroke: var(--gray-500);
    stroke-width: 2;
    fill: none;
}

.edit-btn.editing .edit-icon {
    stroke: var(--white);
}

/* Input de cantidad editable */
.editable-qty-input {
    width: 120px;
    padding: 10px 14px;
    font-size: 20px;
    font-weight: 700;
    border: 2px solid #2196F3;
    border-radius: 8px;
    background: #E3F2FD;
    color: var(--gray-800);
    text-align: center;
    -moz-appearance: textfield;
}

/* Ocultar flechas del input number */
.editable-qty-input::-webkit-outer-spin-button,
.editable-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.editable-qty-input:focus {
    outline: none;
    border-color: #1976D2;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.2);
}

.component-stock {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-200);
}

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

.stock-label {
    font-size: 13px;
    color: var(--gray-500);
    font-weight: 500;
}

.stock-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-800);
}

.stock-needed {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.needed-label {
    font-size: 13px;
    color: var(--gray-500);
    font-weight: 500;
}

.needed-value {
    font-size: 20px;
    font-weight: 700;
}

.needed-value.sufficient {
    color: var(--success);
}

.needed-value.insufficient {
    color: var(--error);
}

.stock-status {
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
}

.stock-status.sufficient {
    background: #E8F5E9;
    color: #2E7D32;
}

.stock-status.insufficient {
    background: #FFEBEE;
    color: #C62828;
}

/* ==== BOTÓN FABRICAR ==== */
.action-section {
    padding: 24px;
    background: var(--white);
    border-top: 1px solid var(--gray-200);
}

.btn-fabricar {
    width: 100%;
    padding: 24px;
    font-size: 22px;
    font-weight: 700;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-fabricar.enabled {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 4px 16px rgba(250, 121, 33, 0.4);
}

.btn-fabricar.enabled:hover {
    background: var(--primary-dark);
    box-shadow: 0 6px 20px rgba(250, 121, 33, 0.5);
}

.btn-fabricar.enabled:active {
    transform: scale(0.98);
}

.btn-fabricar.disabled {
    background: var(--gray-300);
    color: var(--gray-500);
    cursor: not-allowed;
}

/* ==== ALERTAS ==== */
.alert {
    padding: 20px 24px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background: #E8F5E9;
    border: 2px solid #A5D6A7;
    color: #2E7D32;
}

.alert-error {
    background: #FFEBEE;
    border: 2px solid #EF9A9A;
    color: #C62828;
}

.alert-warning {
    background: #FFF8E1;
    border: 2px solid #FFE082;
    color: #F57F17;
}

/* ==== SCROLLBAR ==== */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* ==== LOADING ==== */
.loading {
    text-align: center;
    padding: 60px;
    color: var(--gray-500);
}

.spinner {
    border: 4px solid var(--gray-200);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 24px;
}

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

/* ==== LOCK ICON ==== */
.lock-icon {
    cursor: pointer;
    font-size: 20px;
    margin-left: 8px;
    transition: transform 0.2s ease;
}

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

/* ==== MODAL DE CONFIRMACIÓN ==== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--white);
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    background: var(--primary);
    color: var(--white);
    padding: 24px 28px;
    text-align: center;
}

.modal-header h3 {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
}

.modal-body {
    padding: 28px;
    max-height: 50vh;
    overflow-y: auto;
}

.modal-product {
    text-align: center;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: 20px;
}

.modal-product-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 8px;
}

.modal-product-qty {
    font-size: 36px;
    font-weight: 700;
    color: var(--primary);
}

.modal-product-qty span {
    font-size: 18px;
    color: var(--gray-600);
    font-weight: 500;
}

.modal-components {
    margin-top: 16px;
}

.modal-components-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.modal-component {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-100);
}

.modal-component:last-child {
    border-bottom: none;
}

.modal-component-name {
    font-size: 15px;
    color: var(--gray-700);
    flex: 1;
}

.modal-component-name.locked::after {
    content: " (fijo)";
    color: var(--primary);
    font-weight: 600;
}

.modal-component-qty {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-800);
}

.modal-footer {
    padding: 20px 28px;
    background: var(--gray-50);
    display: flex;
    gap: 12px;
}

.modal-btn {
    flex: 1;
    padding: 16px 24px;
    font-size: 18px;
    font-weight: 700;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-btn-cancel {
    background: var(--white);
    color: var(--gray-700);
    border: 2px solid var(--gray-300);
}

.modal-btn-cancel:hover {
    background: var(--gray-100);
    border-color: var(--gray-400);
}

.modal-btn-confirm {
    background: var(--primary);
    color: var(--white);
}

.modal-btn-confirm:hover {
    background: var(--primary-dark);
}

.modal-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.modal-loading {
    text-align: center;
    padding: 40px;
}

.modal-loading .spinner {
    margin-bottom: 16px;
}

/* ==== MODAL ÉXITO ==== */
.modal-success {
    text-align: center;
    padding: 40px 20px;
}

.modal-success-icon {
    width: 80px;
    height: 80px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
}

.modal-success-icon svg {
    width: 40px;
    height: 40px;
    stroke: var(--white);
    stroke-width: 3;
    fill: none;
}

.modal-success-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 8px;
}

.modal-success-subtitle {
    font-size: 16px;
    color: var(--gray-600);
    margin-bottom: 8px;
}

.modal-success-mo {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

.modal-header.success {
    background: var(--success);
}

.modal-footer-single {
    padding: 20px 28px;
    background: var(--gray-50);
}

.modal-btn-close {
    width: 100%;
    padding: 16px 24px;
    font-size: 18px;
    font-weight: 700;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    background: var(--primary);
    color: var(--white);
    transition: all 0.2s ease;
}

.modal-btn-close:hover {
    background: var(--primary-dark);
}

/* ==== RESPONSIVE ==== */
@media (max-width: 1200px) {
    .products-panel {
        width: 50%;
    }
    .details-panel {
        width: 50%;
    }
}

@media (max-width: 900px) {
    .container {
        flex-direction: column;
    }
    .products-panel,
    .details-panel {
        width: 100%;
        height: 50vh;
    }
}
