/**
 * WC Quick Order Styles
 * Designed to match Gospel Publishers theme (Virtue Premium)
 *
 * @package WC_Quick_Order
 */

/* ==========================================================================
   Variables and Base Styles
   ========================================================================== */

:root {
    --qo-primary: #7ba39f;
    --qo-black: #000000;
    --qo-white: #ffffff;
    --qo-gray: #444444;
    --qo-gray-light: #eeeeee;
    --qo-border: #000000;
    --qo-font-family: 'Lato', sans-serif;
    --qo-font-size: 14px;
    --qo-line-height: 20px;
}

/* ==========================================================================
   Main Wrapper
   ========================================================================== */

.wc-quick-order-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: var(--qo-font-family);
    font-size: var(--qo-font-size);
    line-height: var(--qo-line-height);
    color: var(--qo-black);
}

.wc-quick-order-header {
    margin-bottom: 30px;
    text-align: center;
}

.wc-quick-order-title {
    font-size: 34px;
    font-weight: 400;
    margin: 0 0 10px 0;
    color: var(--qo-black);
}

.wc-quick-order-description {
    font-size: 14px;
    color: var(--qo-gray);
    margin: 0;
}

/* ==========================================================================
   Search Section (Autocomplete Form)
   ========================================================================== */

.wc-quick-order-search-section {
    background: var(--qo-white);
    border: 1px solid var(--qo-border);
    padding: 20px;
    margin-bottom: 30px;
}

.wc-quick-order-search-controls {
    margin-bottom: 20px;
}

.search-toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 15px;
}

.search-toggle-label {
    font-weight: 700;
    font-size: 14px;
    margin: 0;
}

.search-toggle-buttons {
    display: flex;
    gap: 10px;
}

.search-toggle-btn {
    padding: 8px 16px;
    border: 1px solid var(--qo-border);
    background: var(--qo-white);
    color: var(--qo-black);
    font-family: var(--qo-font-family);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.search-toggle-btn:hover {
    background: var(--qo-gray-light);
}

.search-toggle-btn.active {
    background: var(--qo-primary);
    color: var(--qo-white);
    border-color: var(--qo-primary);
}

.wc-quick-order-search-box {
    position: relative;
    margin-bottom: 10px;
}

.wc-quick-order-search-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--qo-border);
    font-family: var(--qo-font-family);
    font-size: 14px;
    box-sizing: border-box;
}

.wc-quick-order-search-input:focus {
    outline: none;
    border-color: var(--qo-primary);
}

.wc-quick-order-search-spinner {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
}

/* Search Results Dropdown */
.wc-quick-order-search-results {
    position: relative;
    border: 1px solid var(--qo-border);
    background: var(--qo-white);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
}

.wc-quick-order-results-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.wc-quick-order-result-item {
    padding: 15px;
    border-bottom: 1px solid var(--qo-gray-light);
    cursor: pointer;
    display: flex;
    gap: 15px;
    align-items: center;
    transition: background 0.2s ease;
}

.wc-quick-order-result-item:hover {
    background: var(--qo-gray-light);
}

.wc-quick-order-result-item:last-child {
    border-bottom: none;
}

.result-item-image img {
    width: 60px;
    height: auto;
    border: 1px solid var(--qo-gray-light);
}

.result-item-details {
    flex: 1;
}

.result-item-name {
    font-weight: 700;
    margin: 0 0 5px 0;
    color: var(--qo-black);
}

.result-item-sku {
    font-size: 12px;
    color: var(--qo-gray);
    margin: 0 0 5px 0;
}

.result-item-description {
    font-size: 13px;
    color: var(--qo-gray);
    margin: 0 0 5px 0;
}

.result-item-price {
    font-weight: 700;
    color: var(--qo-black);
    margin: 0;
}

.result-item-out-of-stock {
    color: #cc0000;
    font-weight: 700;
}

/* Selected Product Display */
.wc-quick-order-selected-product {
    border: 1px solid var(--qo-primary);
    padding: 20px;
    background: #f9f9f9;
}

.selected-product-details {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.selected-product-image img {
    width: 100px;
    height: auto;
    border: 1px solid var(--qo-gray-light);
}

.selected-product-info {
    flex: 1;
}

.selected-product-name {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 10px 0;
}

.selected-product-sku,
.selected-product-description,
.selected-product-price {
    margin: 0 0 8px 0;
    font-size: 14px;
}

.selected-product-price {
    font-weight: 700;
    font-size: 16px;
}

.selected-product-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

.quantity-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
}

.quantity-wrapper label {
    font-weight: 700;
    margin: 0;
}

.selected-product-quantity {
    width: 80px;
    padding: 10px 12px;
    border: 1px solid var(--qo-border);
    font-family: var(--qo-font-family);
    font-size: 14px;
}

/* ==========================================================================
   Order List Section
   ========================================================================== */

.wc-quick-order-list-section {
    margin-bottom: 30px;
}

.wc-quick-order-list-title {
    font-size: 24px;
    font-weight: 400;
    margin: 0 0 20px 0;
    color: var(--qo-black);
}

.wc-quick-order-list-empty {
    padding: 40px;
    text-align: center;
    background: var(--qo-gray-light);
    border: 1px solid var(--qo-border);
}

.wc-quick-order-list-empty p {
    margin: 0;
    color: var(--qo-gray);
}

/* Order Table */
.wc-quick-order-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--qo-border);
    background: var(--qo-white);
}

.wc-quick-order-table thead th {
    background: var(--qo-black);
    color: var(--qo-white);
    padding: 12px;
    text-align: left;
    font-weight: 700;
    font-size: 14px;
}

.wc-quick-order-table tbody td {
    padding: 15px 12px;
    border-bottom: 1px solid var(--qo-gray-light);
    vertical-align: middle;
}

.wc-quick-order-table tbody tr:last-child td {
    border-bottom: 1px solid var(--qo-border);
}

.wc-quick-order-table tfoot td {
    padding: 15px 12px;
    font-weight: 700;
    background: var(--qo-gray-light);
}

.wc-quick-order-table .col-image {
    width: 80px;
}

.wc-quick-order-table .col-sku {
    width: 120px;
}

.wc-quick-order-table .col-price,
.wc-quick-order-table .col-quantity,
.wc-quick-order-table .col-subtotal {
    width: 100px;
}

.wc-quick-order-table .col-remove {
    width: 50px;
    text-align: center;
}

.wc-quick-order-table .text-right {
    text-align: right;
}

.order-item-image img {
    width: 60px;
    height: auto;
    border: 1px solid var(--qo-gray-light);
}

.order-item-name {
    font-weight: 700;
    margin: 0 0 5px 0;
}

.order-item-description {
    font-size: 13px;
    color: var(--qo-gray);
    margin: 0;
}

.order-item-out-of-stock {
    color: #cc0000;
    font-weight: 700;
}

.order-item-quantity {
    width: 60px;
    padding: 8px;
    border: 1px solid var(--qo-border);
    font-family: var(--qo-font-family);
    font-size: 14px;
    text-align: center;
}

.btn-remove-item {
    background: transparent;
    border: none;
    color: #cc0000;
    cursor: pointer;
    font-size: 20px;
    padding: 0;
    line-height: 1;
}

.btn-remove-item:hover {
    color: #990000;
}

/* ==========================================================================
   Bulk Form Specific Styles
   ========================================================================== */

.bulk-entry-table {
    margin-bottom: 20px;
}

.bulk-entry-table .col-line {
    width: 40px;
    text-align: center;
}

.bulk-entry-table .col-input {
    width: 200px;
    position: relative;
}

/* Bulk Autocomplete Dropdown */
.bulk-autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--qo-white);
    border: 1px solid var(--qo-border);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.bulk-autocomplete-item {
    padding: 10px;
    border-bottom: 1px solid var(--qo-gray-light);
    cursor: pointer;
    transition: background 0.2s ease;
}

.bulk-autocomplete-item:hover {
    background: var(--qo-gray-light);
}

.bulk-autocomplete-item:last-child {
    border-bottom: none;
}

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

.bulk-item-info strong {
    font-size: 14px;
    color: var(--qo-black);
}

.bulk-item-sku {
    font-size: 12px;
    color: var(--qo-gray);
}

.bulk-item-price {
    font-size: 12px;
    font-weight: 700;
    color: var(--qo-black);
}

.bulk-entry-table .col-image {
    width: 80px;
}

.bulk-entry-table .col-details {
    min-width: 250px;
}

.bulk-entry-table .col-quantity {
    width: 80px;
}

.bulk-entry-table .col-subtotal {
    width: 100px;
}

.bulk-product-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--qo-border);
    font-family: var(--qo-font-family);
    font-size: 14px;
    box-sizing: border-box;
}

.bulk-product-input:focus {
    outline: none;
    border-color: var(--qo-primary);
}

.bulk-product-input.loading {
    background: var(--qo-gray-light);
}

.bulk-product-input.found {
    border-color: var(--qo-primary);
    background: #f0fdf4;
}

.bulk-product-input.not-found {
    border-color: #cc0000;
    background: #fef2f2;
}

.bulk-product-input:disabled {
    background-color: #f5f5f5;
    color: #999;
    cursor: not-allowed;
    opacity: 0.6;
}

.input-loading {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
}

.product-image-wrapper img {
    width: 60px;
    height: auto;
    border: 1px solid var(--qo-gray-light);
}

.product-details-wrapper {
    padding: 5px 0;
}

.product-name {
    font-weight: 700;
    font-size: 14px;
    margin: 0 0 5px 0;
}

.product-sku {
    font-size: 12px;
    color: var(--qo-gray);
    margin: 0 0 5px 0;
}

.product-description {
    font-size: 13px;
    color: var(--qo-gray);
    margin: 0 0 5px 0;
}

.product-price {
    font-weight: 700;
    margin: 0;
}

.wc-quick-order-archive-quantity-wrapper {
    display: flex;
    align-items: center;
    gap: 0;
    position: relative;
}

.bulk-quantity-input {
    width: 60px;
    padding: 8px;
    border: 1px solid var(--qo-border);
    font-family: var(--qo-font-family);
    font-size: 14px;
    text-align: center;
    margin: 0;
}

.bulk-quantity-input:disabled {
    background: var(--qo-gray-light);
    cursor: not-allowed;
}

.wc-quick-order-quantity-buttons {
    display: flex;
    flex-direction: column;
    margin-left: -1px;
}

.wc-quick-order-quantity-increment,
.wc-quick-order-quantity-decrement {
    width: 24px;
    height: 20px;
    padding: 0;
    border: 1px solid var(--qo-border);
    background: var(--qo-white);
    color: var(--qo-black);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: all 0.2s ease;
    font-family: var(--qo-font-family);
}

.wc-quick-order-quantity-increment {
    border-bottom: none;
    border-radius: 0 3px 0 0;
}

.wc-quick-order-quantity-decrement {
    border-radius: 0 0 3px 0;
}

.wc-quick-order-quantity-increment:hover:not(:disabled),
.wc-quick-order-quantity-decrement:hover:not(:disabled) {
    background: var(--qo-gray-light);
}

.wc-quick-order-quantity-increment:disabled,
.wc-quick-order-quantity-decrement:disabled {
    background: var(--qo-gray-light);
    color: var(--qo-gray);
    cursor: not-allowed;
    opacity: 0.6;
}

.row-subtotal {
    font-weight: 700;
}

.wc-quick-order-add-rows {
    text-align: center;
    margin: 20px 0;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn-add-to-list,
.btn-cancel-selection,
.btn-add-to-cart,
.btn-clear-list,
.btn-add-more-rows {
    padding: 12px 24px;
    border: none;
    font-family: var(--qo-font-family);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 400;
}

.btn-primary,
.btn-add-to-list,
.btn-add-to-cart {
    background: var(--qo-primary);
    color: var(--qo-white);
}

.btn-primary:hover,
.btn-add-to-list:hover,
.btn-add-to-cart:hover {
    background: #6a928e;
}

.btn-cancel-selection,
.btn-clear-list {
    background: var(--qo-gray);
    color: var(--qo-white);
}

.btn-cancel-selection:hover,
.btn-clear-list:hover {
    background: #333333;
}

.btn-add-more-rows {
    background: var(--qo-white);
    color: var(--qo-black);
    border: 1px solid var(--qo-border);
}

.btn-add-more-rows:hover {
    background: var(--qo-gray-light);
}

.btn-add-more-rows .dashicons {
    vertical-align: middle;
    margin-right: 5px;
}

.wc-quick-order-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

/* ==========================================================================
   Loading and Messages
   ========================================================================== */

.wc-quick-order-loading {
    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: 9999;
}

.loading-content {
    background: var(--qo-white);
    padding: 30px;
    border: 1px solid var(--qo-border);
    text-align: center;
}

.loading-content p {
    margin: 10px 0 0 0;
    font-weight: 700;
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--qo-gray-light);
    border-top-color: var(--qo-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.wc-quick-order-messages {
    margin-top: 20px;
}

.wc-quick-order-message {
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid var(--qo-border);
}

.wc-quick-order-message.success {
    background: #f0fdf4;
    border-color: #22c55e;
    color: #166534;
}

.wc-quick-order-message.error {
    background: #fef2f2;
    border-color: #ef4444;
    color: #991b1b;
}

.wc-quick-order-message.info {
    background: #f0f9ff;
    border-color: #3b82f6;
    color: #1e40af;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media screen and (max-width: 768px) {
    .wc-quick-order-wrapper {
        padding: 10px;
    }

    .wc-quick-order-title {
        font-size: 24px;
    }

    .search-toggle-wrapper {
        flex-direction: column;
        align-items: flex-start;
    }

    .selected-product-details {
        flex-direction: column;
    }

    .selected-product-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .wc-quick-order-table {
        font-size: 12px;
    }

    .wc-quick-order-table thead th,
    .wc-quick-order-table tbody td {
        padding: 8px 5px;
    }

    .order-item-image img,
    .result-item-image img {
        width: 40px;
    }

    .wc-quick-order-actions {
        flex-direction: column;
    }

    .wc-quick-order-actions button {
        width: 100%;
    }

    /* Hide some columns on mobile for bulk form */
    .bulk-entry-table .col-image {
        display: none;
    }
}

/* ==========================================================================
   Notice Styles
   ========================================================================== */

.wc-quick-order-notice {
    padding: 20px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    text-align: center;
    margin: 20px 0;
}

/* ==========================================================================
   Force Display Overrides (Theme Compatibility)
   ========================================================================== */

/* Force action buttons to display and be visible */
.wc-quick-order-actions {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    gap: 15px !important;
    justify-content: center !important;
    margin: 30px 0 !important;
    clear: both !important;
    position: relative !important;
    z-index: 10 !important;
    min-height: 50px !important;
}

.wc-quick-order-actions button {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 11 !important;
}

/* Force specific button visibility */
.btn-add-to-cart,
.btn-clear-list {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    width: auto !important;
    min-height: 44px !important;
    line-height: normal !important;
}

/* Remove any potential hiding styles */
.wc-quick-order-wrapper .wc-quick-order-actions,
.wc-quick-order-wrapper .wc-quick-order-actions button,
.wc-quick-order-wrapper .btn-add-to-cart,
.wc-quick-order-wrapper .btn-clear-list {
    clip: unset !important;
    clip-path: none !important;
    height: auto !important;
    overflow: visible !important;
    position: relative !important;
    width: auto !important;
    white-space: normal !important;
}

/* Force loading spinner to hide */
.bulk-entry-row .input-loading {
    display: none !important;
}