/* css/modal-styles.css - UPDATED - Black & White Modal Popup Styles */

/* ===== MODAL OVERLAY ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
    box-sizing: border-box;
}

/* ===== MODAL ANIMATIONS ===== */
@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes modalSlideOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
}

/* ===== BASE MODAL CONTENT ===== */
.modal-venta,
.modal-produccion,
.modal-gasto {
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    border: 3px solid var(--border);
    width: 100%;
    max-width: 1000px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s ease-out;
}

.modal-overlay.closing .modal-venta,
.modal-overlay.closing .modal-produccion,
.modal-overlay.closing .modal-gasto {
    animation: modalSlideOut 0.2s ease-in;
}

/* ===== MODAL HEADER ===== */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    background: var(--primary);
    color: white;
    border-radius: 12px 12px 0 0;
    border-bottom: 2px solid var(--border);
}

.modal-header h3 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 50%;
    transition: all 0.2s;
    line-height: 1;
    font-weight: bold;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* ===== MODAL BODY ===== */
.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 25px;
    max-height: calc(90vh - 140px);
    background: var(--bg);
}

.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ===== MODAL FOOTER ===== */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    padding: 20px 25px;
    background: var(--bg-secondary);
    border-radius: 0 0 12px 12px;
    border-top: 2px solid var(--border);
}

.modal-footer button {
    padding: 12px 24px;
    border: 2px solid;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 120px;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

.modal-footer .btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.modal-footer .btn-secondary {
    background: var(--bg);
    color: var(--text);
    border-color: var(--border);
}

.modal-footer .btn-secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

.modal-footer .btn-success {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.modal-footer .btn-success:hover {
    background: #218838;
    border-color: #218838;
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

/* ===== FORM SECTIONS WITHIN MODALS ===== */
.modal-body .seccion-produccion,
.modal-body .seccion-cliente,
.modal-body .seccion-entrega,
.modal-body .seccion-productos,
.modal-body .resumen-venta,
.modal-body .seccion-produccion-gasto,
.modal-body .seccion-datos-gasto {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    border: 2px solid var(--border-light);
    border-left: 4px solid var(--primary);
}

.modal-body .seccion-entrega {
    border-left-color: var(--text);
}

.modal-body .seccion-productos {
    border-left-color: var(--success);
}

.modal-body .resumen-venta {
    border-left-color: var(--warning);
}

.modal-body .seccion-produccion-gasto {
    border-left-color: var(--secondary);
}

.modal-body .seccion-datos-gasto {
    border-left-color: var(--danger);
}

/* ===== PRODUCTION MODAL SPECIFIC - ENHANCED LAYOUT ===== */
.productos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 20px;
    margin-top: 15px;
}

/* Enhanced product item styling */
.producto-item {
    background: white;
    padding: 20px;
    border-radius: 10px;
    border: 2px solid var(--border);
    transition: all 0.2s;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.producto-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.producto-item.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

.producto-item label {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    font-size: 16px;
    line-height: 1.4;
    transition: color 0.2s;
}

.producto-item.selected label {
    color: var(--primary);
}

.producto-item input[type="checkbox"] {
    width: auto;
    margin-right: 12px;
    transform: scale(1.3);
    cursor: pointer;
    accent-color: var(--primary);
}

.producto-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 12px;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    border: 1px solid var(--border-light);
}

.producto-info span {
    font-weight: 500;
}

/* ENHANCED: Much better input sizing and styling */
.producto-item input[type="number"] {
    width: 100%;
    padding: 15px 18px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.2s;
    background: white;
    min-height: 52px;
    box-sizing: border-box;
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    text-align: center;
    color: var(--text);
}

.producto-item input[type="number"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
    background: var(--bg-light);
}

.producto-item input[type="number"]:disabled {
    background: var(--bg-secondary);
    border-color: var(--border-light);
    color: var(--text-muted);
    cursor: not-allowed;
}

.producto-item input[type="number"]::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

/* ===== CALCULATION RESULTS ===== */
.resultados-calculo {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
    border: 2px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.resultados-calculo h4 {
    color: var(--text);
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.alerta-inventario {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 2px solid;
    font-weight: 500;
}

.alerta-inventario.success {
    background: var(--success-light);
    border-color: var(--success);
    color: var(--success);
}

.alerta-inventario.error {
    background: var(--danger-light);
    border-color: var(--danger);
    color: var(--danger);
}

.alerta-inventario h5 {
    margin-bottom: 10px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.alerta-inventario ul {
    margin: 0;
    padding-left: 20px;
}

.alerta-inventario li {
    margin-bottom: 5px;
}

.resumen-financiero {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.stat-card {
    background: var(--bg-secondary);
    padding: 18px;
    border-radius: 8px;
    text-align: center;
    border: 2px solid var(--border-light);
    transition: all 0.2s;
}

.stat-card:hover {
    border-color: var(--primary);
    background: white;
    transform: translateY(-1px);
}

.stat-card h5 {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.stat-card .amount {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text);
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    margin-bottom: var(--space-xs);
    line-height: 1;
    text-align: center;
    width: 100%;
    display: block;
    letter-spacing: -0.02em;
    word-break: break-word;
    hyphens: auto;
}

.stat-card .amount.positive {
    color: var(--success);
}

.stat-card .amount.negative {
    color: var(--danger);
}

/* ===== EXPENSE MODAL SPECIFIC ===== */
.modal-body .seccion-produccion-gasto select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    background: white;
    min-height: 48px;
    color: var(--text);
    font-family: inherit;
}

.modal-body .seccion-produccion-gasto option {
    padding: 8px;
    color: var(--text);
}

.modal-body .seccion-datos-gasto .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

/* ===== SALES MODAL SPECIFIC ===== */
.stock-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
    margin-top: 10px;
}

.stock-item-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border: 2px solid var(--border-light);
    border-left: 4px solid var(--success);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}

.stock-item-info:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}

.stock-item-info.sin-stock {
    border-left-color: var(--danger);
    background: var(--danger-light);
    opacity: 0.8;
}

.stock-item-info.stock-bajo {
    border-left-color: var(--warning);
    background: var(--warning-light);
}

.producto-nombre {
    font-weight: 600;
    color: var(--text);
}

.stock-cantidad {
    color: var(--text-light);
    font-size: 14px;
    margin: 2px 0;
}

.stock-precio {
    font-weight: 600;
    color: var(--success);
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

.productos-venta-grid {
    display: grid;
    gap: 15px;
}

.producto-venta-item {
    background: white;
    padding: 18px;
    border-radius: 10px;
    border: 2px solid var(--border);
    transition: all 0.2s;
}

.producto-venta-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.producto-venta-item.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

.producto-venta-item label {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
}

.producto-venta-item input[type="checkbox"] {
    width: auto;
    margin-right: 10px;
    transform: scale(1.2);
    accent-color: var(--primary);
}

/* Enhanced sales product inputs */
.producto-inputs {
    display: grid;
    grid-template-columns: 120px 1fr 120px;
    gap: 12px;
    align-items: center;
    margin-top: 12px;
}

.producto-inputs input[type="number"] {
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    text-align: center;
    min-height: 44px;
    font-weight: 500;
    color: var(--text);
    background: white;
}

.producto-inputs input[type="number"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

.precio-display {
    color: var(--text-light);
    font-size: 14px;
    text-align: center;
    font-weight: 500;
    padding: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
}

.subtotal {
    font-weight: 700;
    color: var(--success);
    font-size: 16px;
    text-align: center;
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    padding: 8px;
    background: var(--success-light);
    border-radius: 4px;
    border: 1px solid var(--success);
}

.no-stock {
    text-align: center;
    color: var(--danger);
    font-weight: 600;
    padding: 25px;
    background: var(--danger-light);
    border-radius: 8px;
    border: 2px dashed var(--danger);
    margin: 15px 0;
}

.total-general {
    background: white;
    padding: 25px;
    border-radius: 12px;
    text-align: center;
    border: 2px solid var(--warning);
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.total-general h4 {
    margin: 0 0 10px 0;
    color: var(--text);
    font-size: 18px;
}

.total-general #totalGeneral {
    color: var(--success);
    font-weight: 800;
    font-size: 28px;
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    display: block;
    margin: 10px 0;
}

.total-general p {
    margin: 8px 0 0 0;
    color: var(--text-light);
    font-weight: 500;
}

/* ===== FORM STYLING WITHIN MODALS ===== */
.modal-body h4 {
    color: var(--text);
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.modal-body .form-group {
    margin-bottom: 15px;
}

.modal-body .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.modal-body label {
    display: block;
    margin-bottom: 5px;
    color: var(--text);
    font-weight: 500;
}

.modal-body input,
.modal-body select,
.modal-body textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
    box-sizing: border-box;
    min-height: 48px;
    font-family: inherit;
    background: white;
    color: var(--text);
}

.modal-body input:focus,
.modal-body select:focus,
.modal-body textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

.modal-body input[type="radio"] {
    width: auto;
    margin-right: 8px;
    min-height: auto;
    accent-color: var(--primary);
}

.modal-body input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
    min-height: auto;
    accent-color: var(--primary);
}

.modal-body label input[type="radio"],
.modal-body label input[type="checkbox"] {
    margin-right: 8px;
}

.modal-body small {
    display: block;
    margin-top: 5px;
    color: var(--text-muted);
    font-size: 12px;
    font-style: italic;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .modal-overlay {
        padding: 10px;
    }
    
    .modal-venta,
    .modal-produccion,
    .modal-gasto {
        max-width: 100%;
        max-height: 95vh;
        border-radius: 10px;
    }
    
    .modal-header {
        padding: 15px 20px;
        border-radius: 8px 8px 0 0;
    }
    
    .modal-header h3 {
        font-size: 20px;
    }
    
    .modal-body {
        padding: 20px;
        max-height: calc(95vh - 130px);
    }
    
    .modal-footer {
        padding: 15px 20px;
        border-radius: 0 0 8px 8px;
    }
    
    .modal-body .form-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    /* Enhanced responsive product grid */
    .productos-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .producto-item {
        min-height: 120px;
        padding: 15px;
    }
    
    .producto-item input[type="number"] {
        font-size: 16px;
        padding: 12px;
        min-height: 48px;
    }
    
    .stock-info-grid {
        grid-template-columns: 1fr;
    }
    
    .producto-inputs {
        grid-template-columns: 100px 1fr;
        gap: 8px;
    }
    
    .subtotal {
        grid-column: 1 / -1;
        text-align: center;
        margin-top: 8px;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer button {
        width: 100%;
    }
    
    .resumen-financiero {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .modal-overlay {
        padding: 5px;
    }
    
    .modal-venta,
    .modal-produccion,
    .modal-gasto {
        max-height: 98vh;
        border-radius: 8px;
    }
    
    .modal-body {
        padding: 15px;
        max-height: calc(98vh - 120px);
    }
    
    .modal-body .seccion-produccion,
    .modal-body .seccion-cliente,
    .modal-body .seccion-entrega,
    .modal-body .seccion-productos,
    .modal-body .resumen-venta,
    .modal-body .seccion-produccion-gasto,
    .modal-body .seccion-datos-gasto {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .total-general #totalGeneral {
        font-size: 24px;
    }
    
    .producto-item {
        padding: 12px;
        min-height: 100px;
    }
    
    .producto-item input[type="number"] {
        padding: 10px;
        min-height: 44px;
        font-size: 14px;
    }
}

/* ===== LOADING STATES ===== */
.modal-venta.loading::before,
.modal-produccion.loading::before,
.modal-gasto.loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 10;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== ENHANCED VISUAL FEEDBACK ===== */
.producto-item.error {
    border-color: var(--danger);
    background: var(--danger-light);
}

.producto-item.warning {
    border-color: var(--warning);
    background: var(--warning-light);
}

.form-group.error input,
.form-group.error select,
.form-group.error textarea {
    border-color: var(--danger);
    background: var(--danger-light);
}

.form-group.error label {
    color: var(--danger);
}

.error-message {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: var(--space-xs);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.success-message {
    color: var(--success);
    font-size: 0.875rem;
    margin-top: var(--space-xs);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}