﻿/* Sales Popup CSS - Updated */

/* Modal z-index fix */
.sales-modal {
    z-index: 9999 !important;
}

.modal-backdrop.show {
    z-index: 998 !important;
}

/* Fix pointer events for modal content */
.sales-modal .modal-content {
    pointer-events: auto !important;
    position: relative !important;
    z-index: 1 !important;
}

.sales-modal .modal-dialog {
    pointer-events: auto !important;
}

/* Ensure all form elements are interactive */
.sales-modal input,
.sales-modal button,
.sales-modal select,
.sales-modal textarea {
    pointer-events: auto !important;
    opacity: 1 !important;
    cursor: pointer !important;
}

.sales-modal .form-control {
    cursor: text !important;
}

/* Fix any disabled appearance */
.sales-modal .btn:not(:disabled) {
    opacity: 1 !important;
    cursor: pointer !important;
}

.sales-modal .modal-content * {
    pointer-events: auto !important;
}

.sales-product-card {
    transition: transform 0.2s;
    cursor: pointer;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

    .sales-product-card:hover {
        transform: translateY(-3px);
        box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    }

/* Modal Styling */
.sales-modal .modal-header {
    background: linear-gradient(135deg, #4b6cb7 0%, #182848 100%);
    color: white;
    border-bottom: none;
}

.sales-modal .modal-title {
    font-weight: 600;
}

/* Modal backdrop static - only close with X button */
.sales-modal[data-bs-backdrop="static"] {
    pointer-events: auto;
}

/* Sales Buttons */
#salesModal .btn-sell,
.sales-popup-btn,
.btn.sales-popup-btn {
    background: linear-gradient(135deg, #4b6cb7 0%, #182848 100%) !important;
    border: none !important;
    color: white !important;
    transition: all 0.3s !important;
    padding: 10px 20px !important;
    border-radius: 6px !important;
    font-weight: 500 !important;
}

    #salesModal .btn-sell:hover,
    .sales-popup-btn:hover,
    .btn.sales-popup-btn:hover {
        transform: translateY(-2px) !important;
        box-shadow: 0 5px 15px rgba(75, 108, 183, 0.4) !important;
        color: white !important;
        background: linear-gradient(135deg, #4b6cb7 0%, #182848 100%) !important;
    }

    #salesModal .btn-sell:disabled,
    .sales-popup-btn:disabled,
    .btn.sales-popup-btn:disabled {
        opacity: 0.6 !important;
        transform: none !important;
        box-shadow: none !important;
    }

/* Product Info Section */
.sales-product-info {
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 20px;
}

.sales-product-name {
    font-size: 1.2em;
    font-weight: 600;
    color: #495057;
    margin-bottom: 5px;
}

.sales-product-code {
    color: #6c757d;
    font-size: 0.9em;
    margin-bottom: 10px;
}

.sales-stock-info {
    background: #e8f4f8;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.9em;
    color: #495057;
}

.sales-price-tag {
    background: linear-gradient(135deg, #4b6cb7 0%, #182848 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 15px;
    font-weight: bold;
    font-size: 0.9em;
    display: inline-block;
}

/* Form Controls */
.sales-form-group {
    margin-bottom: 15px;
}

.sales-form-label {
    font-weight: 500;
    margin-bottom: 5px;
    color: #495057;
}

.sales-modal .form-control:focus {
    border-color: #4b6cb7;
    box-shadow: 0 0 0 0.2rem rgba(75, 108, 183, 0.25);
}

/* Quantity Controls */
.sales-quantity-controls {
    display: flex;
    align-items: center;
    gap: 5px;
}

.sales-quantity-input {
    max-width: 120px;
    text-align: center;
}

.sales-btn-quantity {
    width: 35px;
    height: 35px;
    border: 1px solid #dee2e6;
    background: #f8f9fa;
    color: #495057;
    border-radius: 4px;
    transition: all 0.2s;
}

    .sales-btn-quantity:hover {
        background: #e9ecef;
        border-color: #adb5bd;
    }

/* Price Update Controls */
.price-update-info {
    display: block;
    margin-top: 2px;
}

.price-info {
    font-size: 0.85em;
}

#priceChangeInfo {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

#updatePriceBtn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

#restorePriceBtn {
    border-radius: 0;
    border-left: none;
}

.input-group .btn {
    z-index: 3;
}

/* Customer Search */
.customer-search-container {
    position: relative;
}

.customer-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 250px;
    overflow-y: auto;
    z-index: 1050;
    display: none;
    margin-top: 2px;
}

.suggestion-item {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.2s;
}

    .suggestion-item:hover,
    .suggestion-item.active {
        background-color: #f8f9ff;
        border-left: 3px solid #4b6cb7;
    }

    .suggestion-item:last-child {
        border-bottom: none;
    }

    .suggestion-item.no-results {
        color: #6c757d;
        cursor: default;
        text-align: center;
        font-style: italic;
    }

        .suggestion-item.no-results:hover {
            background-color: transparent;
            border-left: none;
        }

.customer-name {
    font-size: 0.95em;
    margin-bottom: 3px;
}

.customer-info {
    font-size: 0.8em;
    color: #6c757d;
}

/* Selected customer effect */
.selected-customer {
    border-color: #28a745 !important;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25) !important;
}

/* Customer search icon centering */
#customerSearchIcon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.input-group-text {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* New Customer Form */
#newCustomerSection .card {
    border: 2px solid #4b6cb7;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#newCustomerSection .card-header {
    background: linear-gradient(135deg, #4b6cb7 0%, #182848 100%);
    color: white;
    position: relative;
}

#newCustomerSection .btn-close {
    filter: invert(1);
    opacity: 0.8;
}

#newCustomerSection .form-label {
    font-weight: 500;
    color: #495057;
    margin-bottom: 5px;
}

    #newCustomerSection .form-label i {
        color: #4b6cb7;
        width: 16px;
    }

#newCustomerSection .form-control:focus {
    border-color: #4b6cb7;
    box-shadow: 0 0 0 0.2rem rgba(75, 108, 183, 0.25);
}

#newCustomerSection .required::after {
    content: " *";
    color: #dc3545;
}

/* Total Section */
.sales-total-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
    border: 1px solid #e9ecef;
}

.sales-total-amount {
    font-size: 1.5em;
    font-weight: bold;
    color: #495057;
}

.sales-vat-info {
    font-size: 0.9em;
    color: #6c757d;
    margin-top: 5px;
}

/* Loading and Messages */
.sales-loading-spinner {
    display: none;
    text-align: center;
    padding: 20px;
}

.sales-success-message {
    display: none;
    background: #d4edda;
    color: #155724;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    border: 1px solid #c3e6cb;
}

.sales-error-message {
    display: none;
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    border: 1px solid #f5c6cb;
}

/* Payment Method Groups */
.sales-payment-method-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.sales-payment-method-btn {
    flex: 1;
    min-width: 120px;
    padding: 10px 15px;
    border: 2px solid #e9ecef;
    background: #fff;
    color: #495057;
    border-radius: 6px;
    transition: all 0.2s;
    cursor: pointer;
}

    .sales-payment-method-btn:hover {
        border-color: #4b6cb7;
        background: #f8f9ff;
    }

    .sales-payment-method-btn.active {
        border-color: #4b6cb7;
        background: linear-gradient(135deg, #4b6cb7 0%, #182848 100%);
        color: white;
    }

/* Discount Section */
.sales-discount-section {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    padding: 15px;
    margin: 15px 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .sales-modal .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }

    .sales-payment-method-btn {
        min-width: 100px;
        font-size: 0.9em;
    }

    .sales-quantity-controls {
        justify-content: center;
    }

    .sales-total-amount {
        font-size: 1.2em;
    }

    .sales-form-label {
        font-size: 0.9em;
    }
}

/* Preserve other page btn-sell styles */
.btn-sell:not(.sales-popup-btn):not(#salesModal .btn-sell) {
    /* No styles here - preserves existing styles */
}
