/**
 * Harfield Quick Entry Styles
 */

/* Wrapper */
.harfield-quick-entry-wrapper {
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 14px; /* Base font size for the entire form */
}

/* Table Styles */
.harfield-quick-entry-table {
    width: 100%;
    background: white;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.harfield-quick-entry-table thead {
    background: #343a40;
    color: white;
}

.harfield-quick-entry-table th {
    padding: 12px 15px;
    font-weight: 600;
    text-align: left;
    border: none;
}

.harfield-quick-entry-table th.quantity-column {
    text-align: center !important;
}

.harfield-quick-entry-table td {
    padding: 10px 15px;
    vertical-align: middle !important;
    border-top: 1px solid #dee2e6;
}

.harfield-quick-entry-table tbody tr:hover {
    background-color: #f8f9fa;
}

/* Column widths */
.product-code-column {
    width: 30%;
    min-width: 200px;
}

.quantity-column {
    width: 10%;
    min-width: 60px;
}

.product-name-column {
    width: 50%;
}

.actions-column {
    width: 10%;
    min-width: 60px;
    text-align: center;
}

/* Form Controls */
.harfield-quick-entry-table .form-control {
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 13px;
}

.quantity-input {
    text-align: center;
    max-width: 60px;
    margin: 0 auto;
}

/* Select2 Overrides */
.harfield-quick-entry-table .select2-container {
    width: 100% !important;
}

.harfield-quick-entry-table .select2-container--default .select2-selection--single {
    height: 36px;
    line-height: 36px;
    border: 1px solid #ced4da;
    border-radius: 4px;
}

.harfield-quick-entry-table .select2-container--default .select2-selection--single .select2-selection__rendered {
    padding-left: 12px;
    padding-right: 20px;
    font-size: 13px;
}

.harfield-quick-entry-table .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 34px;
    right: 10px;
}

/* Hide dropdown arrow when clear button is present */
.harfield-quick-entry-table .select2-container--default.select2-container--focus .select2-selection--single .select2-selection__arrow,
.harfield-quick-entry-table .select2-container--default .select2-selection--single:has(.select2-selection__clear) .select2-selection__arrow,
.harfield-quick-entry-table .select2-container.has-selection .select2-selection__arrow {
    display: none;
}

/* Adjust clear button position and style */
.harfield-quick-entry-table .select2-container--default .select2-selection--single .select2-selection__clear {
    margin-right: 0;
    right: -5px;
    top: 2px;
    font-size: 18px;
    line-height: 1;
}

/* Select2 dropdown options */
.select2-results__option {
    font-size: 13px;
}

/* Select2 search input */
.select2-search--dropdown .select2-search__field {
    font-size: 13px;
}

/* Remove the minimum input message */
.select2-results__message {
    display: none;
}

/* Force dropdown positioning */
.harfield-quick-entry-table .select2-dropdown {
    z-index: 9999 !important;
}

/* Ensure dropdown opens below the input */
.harfield-quick-entry-table .select2-container--open .select2-dropdown--below {
    border-top: 1px solid #ced4da;
}

.harfield-quick-entry-table .select2-container--open .select2-dropdown--above {
    border-bottom: 1px solid #ced4da;
}

/* Product info displays */
.product-name {
    display: inline-block;
    font-size: 13px;
    vertical-align: middle;
}

/* Out of stock styling */
.quick-entry-row.out-of-stock {
    opacity: 0.6;
}

.quick-entry-row.out-of-stock .product-name {
    text-decoration: line-through;
}

/* Buttons */
.btn {
    display: inline-block;
    font-weight: 400;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    user-select: none;
    border: 1px solid transparent;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    border-radius: 0.25rem;
    transition: all 0.15s ease-in-out;
    cursor: pointer;
}

.btn-primary {
    color: #fff;
    background-color: #007bff;
    border-color: #007bff;
}

.btn-primary:hover {
    background-color: #0056b3;
    border-color: #004085;
}

.btn-primary:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.btn-secondary {
    color: #fff;
    background-color: #6c757d;
    border-color: #6c757d;
}

.btn-secondary:hover {
    background-color: #545b62;
    border-color: #3d4349;
}

.btn-danger {
    color: #fff;
    background-color: #dc3545;
    border-color: #dc3545;
}

.btn-danger:hover {
    background-color: #c82333;
    border-color: #bd2130;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    line-height: 1.5;
    border-radius: 0.2rem;
}

.btn-lg {
    padding: 0.5rem 1rem;
    font-size: 1.25rem;
    line-height: 1.5;
    border-radius: 0.3rem;
}

.remove-row {
    width: 24px;
    height: 24px;
    padding: 0;
    border-radius: 50%;
    background-color: #fff;
    border: 1px solid #000;
    color: #000;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
    font-weight: normal;
}

.remove-row:hover {
    background-color: #f8f9fa;
    border-color: #000;
}

/* Actions section */
.harfield-quick-entry-actions {
    margin-top: 20px;
    text-align: center;
    padding: 20px 0;
    border-top: 2px solid #dee2e6;
}

#go-to-basket {
    min-width: 200px;
}

/* Messages */
.harfield-quick-entry-messages {
    margin-top: 20px;
}

.alert {
    padding: 12px 20px;
    margin-bottom: 10px;
    border: 1px solid transparent;
    border-radius: 4px;
}

.alert-success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}

.alert-warning {
    color: #856404;
    background-color: #fff3cd;
    border-color: #ffeeba;
}

.alert-danger {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}

.alert-info {
    color: #0c5460;
    background-color: #d1ecf1;
    border-color: #bee5eb;
}

/* Hide product name on smaller screens */
@media (max-width: 1000px) {
    .product-name-column {
        display: none;
    }
    
    /* Adjust remaining column widths when name is hidden */
    .product-code-column {
        width: 70%;
    }
    
    .quantity-column {
        width: 15%;
    }
    
    .actions-column {
        width: 15%;
    }
}

/* Responsive adjustments for mobile */
@media (max-width: 768px) {
    .harfield-quick-entry-wrapper {
        padding: 10px;
        margin: 10px -10px;
    }
    
    .harfield-quick-entry-table {
        font-size: 14px;
    }
    
    .harfield-quick-entry-table th,
    .harfield-quick-entry-table td {
        padding: 8px 10px;
    }
    
    .product-code-column,
    .quantity-column {
        min-width: auto;
    }
    
    .harfield-quick-entry-actions {
        padding: 15px 0;
    }
    
    #go-to-basket {
        width: 100%;
    }
}

/* Loading state */
.select2-container--default.select2-container--disabled .select2-selection--single {
    background-color: #e9ecef;
    cursor: not-allowed;
}

/* Print styles */
@media print {
    .harfield-quick-entry-wrapper {
        background: none;
        padding: 0;
    }
    
    .btn,
    .actions-column,
    .harfield-quick-entry-messages {
        display: none !important;
    }
    
    .harfield-quick-entry-table {
        box-shadow: none;
        border: 1px solid #000;
    }
}

/* 
 * CSS Targeting Guide
 * ===================
 * 
 * Main wrapper: .harfield-quick-entry-wrapper
 * Form: #harfield-quick-entry-form
 * Table: .harfield-quick-entry-table
 * Table rows: .quick-entry-row
 * 
 * Product code dropdown: .product-code-select
 * Quantity input: .quantity-input
 * Product name display: .product-name
 * Product price display: .product-price
 * Remove button: .remove-row
 * 
 * Add row button: #add-row
 * Submit button: #go-to-basket
 * Messages container: #harfield-quick-entry-messages
 * 
 * Column classes:
 * - .product-code-column
 * - .quantity-column
 * - .product-name-column
 * - .actions-column
 * 
 * State classes:
 * - .out-of-stock (applied to row when product is out of stock)
 * 
 * Select2 specific:
 * - .select2-container (within .harfield-quick-entry-table for scoping)
 * - .select2-results__option (dropdown options)
 * - .select2-search__field (search input)
 */
