/* Elementor Products Table Styles - Refactored */

:root {
    --pt-ink: #1f2933;
    --pt-muted: #6b7280;
    --pt-accent: #1f7a6b;
    --pt-accent-dark: #0f6d5f;
    --pt-surface: #ffffff;
    --pt-bg: #f7f9f9;
    --pt-border: rgba(31, 41, 51, 0.15);
    --pt-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.products-table-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    background: var(--pt-surface);
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--pt-border);
    position: relative;
    overflow: visible;
}

.products-table-container * {
    box-sizing: border-box;
}

/* Filters */
.products-filters {
    background: linear-gradient(135deg, #1f7a6b, #2f8b7c);
    padding: 18px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.15);
}

.products-filters .filters-grid {
    display: grid;
    grid-template-columns: minmax(240px, 1.1fr) minmax(240px, 1.1fr) minmax(180px, 0.8fr) minmax(160px, 0.7fr);
    gap: 12px 16px;
    align-items: end;
}

.products-filters .filters-grid > div,
.products-filters .filter-group {
    min-width: 0;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group.is-clear {
    align-self: end;
}

.filter-group label {
    font-weight: 600;
    font-size: 13px;
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.filter-group input,
.filter-group select {
    height: 42px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.25);
    background: #ffffff;
    color: var(--pt-ink);
    outline: none;
    transition: all 0.2s ease;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.filter-group input:focus,
.filter-group select:focus {
    border-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25);
}

#clear-filters {
    height: 42px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

#clear-filters:hover {
    background: #ffffff;
    color: var(--pt-accent);
}

.bulk-order-toggle {
    display: grid;
    gap: 8px;
    align-content: end;
    justify-items: stretch;
}

#bulk-order-button,
.bulk-order-button {
    height: 42px;
    border-radius: 10px;
    background: var(--pt-accent-dark);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.35);
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
    transition: all 0.2s ease;
    width: 100%;
}

#bulk-order-button:hover,
.bulk-order-button:hover {
    background: #111111;
    border-color: #111111;
    transform: translateY(-1px);
    box-shadow: 0 10px 18px rgba(0, 0, 0, 0.22);
}

#bulk-order-section,
.bulk-order-section {
    width: 100%;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    padding: 12px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

#bulk-order-input,
.bulk-order-input {
    width: 100%;
    height: 70px;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 10px;
    font-size: 14px;
    resize: none;
}

#bulk-order-submit,
.bulk-order-submit {
    margin-top: 10px;
    height: 38px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    background: var(--pt-accent);
    color: #ffffff;
    font-weight: 600;
    cursor: pointer;
}

@media (max-width: 980px) {
    .products-filters .filters-grid {
        grid-template-columns: 1fr;
    }
}

/* Table */
.products-table-wrapper {
    position: relative;
    min-height: 300px;
    background: var(--pt-bg);
    width: 100%;
    overflow-x: auto;
}

.products-table {
    background: var(--pt-bg);
    width: 100%;
}

.products-table table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 10px;
    font-size: 14px;
    line-height: 1.5;
}

.products-table thead th {
    background: var(--pt-accent);
    color: #ffffff;
    font-weight: 700;
    text-align: left;
    padding: 14px 18px;
    position: sticky;
    top: 0;
    z-index: 5;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-size: 12px;
}

.products-table table,
.products-table th,
.products-table td {
    border: 0;
}

.products-table tbody tr {
    background: #ffffff;
    box-shadow: var(--pt-shadow);
    border-radius: 12px;
}

.products-table tbody tr td:first-child {
    border-radius: 12px 0 0 12px;
}

.products-table tbody tr td:last-child {
    border-radius: 0 12px 12px 0;
}

.products-table td {
    padding: 14px 18px;
    vertical-align: middle;
    color: var(--pt-ink);
    border: none;
}

/* Product Image */
.products-table-container .product-image {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid #e0e0e0;
}

.products-table-container .product-name {
    color: var(--pt-ink);
    text-decoration: none;
    font-weight: 600;
    display: inline-block;
}

.products-table-container .product-name:hover {
    color: var(--pt-accent);
}

.product-sku {
    font-family: "Menlo", "Monaco", "Ubuntu Mono", monospace;
    background: #f3f4f6;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    color: var(--pt-ink);
    border: 1px solid #e0e0e0;
}

.products-table-container .product-price {
    font-weight: 700;
    color: var(--pt-accent);
    font-size: 15px;
}

.products-table-container .stock-status {
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.products-table-container .stock-status.instock {
    background: #e8f5e8;
    color: var(--pt-accent);
    border: 1px solid #1f7a6b;
}

.products-table-container .stock-status.outofstock {
    background: #ffeaea;
    color: #d32f2f;
    border: 1px solid #d32f2f;
}

.products-table-container .stock-status.onbackorder {
    background: #fff3e0;
    color: #f57c00;
    border: 1px solid #f57c00;
}

/* Actions */
.products-table-container .product-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    min-width: 120px;
}

.products-table-container .add-to-cart-btn,
.products-table-container .select-options-btn {
    height: 36px;
    background: var(--pt-accent);
    color: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.2);
    padding: 0 14px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 110px;
    white-space: nowrap;
}

.products-table-container .add-to-cart-btn:hover,
.products-table-container .select-options-btn:hover {
    background: #111827;
    border-color: #111827;
}

.products-table-container .add-to-cart-btn:disabled,
.products-table-container .select-options-btn:disabled {
    background: #cccccc;
    border-color: #cccccc;
    color: #666666;
    cursor: not-allowed;
}

.products-table-container .add-to-cart-btn.loading,
.products-table-container .select-options-btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

.products-table-container .add-to-cart-btn.loading::after,
.products-table-container .select-options-btn.loading::after {
    content: "";
    width: 12px;
    height: 12px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 6px;
}

.products-table-container .quantity-input {
    width: 60px;
    height: 32px;
    padding: 4px 8px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    text-align: center;
    font-size: 12px;
}

/* Loading */
.loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 10;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid var(--pt-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 12px;
}

.loading-spinner p {
    color: var(--pt-ink);
    font-weight: 500;
    margin: 0;
}

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

/* Modal */
.variations-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.variations-modal .modal-content {
    background: #ffffff;
    border-radius: 12px;
    max-width: 520px;
    width: 92%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--pt-border);
}

.variations-modal .modal-header {
    padding: 18px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--pt-accent);
    color: #ffffff;
    border-radius: 12px 12px 0 0;
}

.variations-modal .modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.variations-modal .modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #ffffff;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

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

.variations-modal .modal-body {
    padding: 18px;
}

.variations-modal .variation-option {
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #ffffff;
}

.variations-modal .variation-option:hover {
    border-color: var(--pt-accent);
    background: #f8f9fa;
}

.variations-modal .variation-option.selected {
    border-color: var(--pt-accent);
    background: #e8f5e8;
}

.variations-modal .variation-name {
    font-weight: 600;
    color: var(--pt-ink);
    margin-bottom: 4px;
}

.variations-modal .variation-price {
    color: var(--pt-accent);
    font-weight: 700;
}

.variations-modal .variation-sku {
    font-size: 12px;
    color: var(--pt-muted);
    font-family: monospace;
}

.variations-modal .quantity-group {
    margin: 12px 0;
    padding: 10px;
}

.variations-modal .quantity-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--pt-ink);
}

.variations-modal .quantity-spinner {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.variations-modal .qty-minus,
.variations-modal .qty-plus {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-size: 18px;
    border-radius: 8px;
    border: 1px solid var(--pt-border);
    background: #ffffff;
    color: var(--pt-ink);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.variations-modal .qty-minus:hover,
.variations-modal .qty-plus:hover {
    border-color: var(--pt-accent);
    color: var(--pt-accent);
}

.variations-modal #product-quantity {
    width: 70px;
    height: 34px;
    padding: 0 8px;
    line-height: 34px;
    border-radius: 8px;
    border: 1px solid var(--pt-border);
    text-align: center;
    font-weight: 600;
}

.variations-modal .modal-footer {
    padding: 16px 18px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #ffffff;
    border-radius: 0 0 12px 12px;
}

.variations-modal .modal-cancel,
.variations-modal .modal-add-to-cart {
    height: 36px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid var(--pt-border);
    background: #ffffff;
    color: var(--pt-ink);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.variations-modal .modal-add-to-cart {
    background: var(--pt-accent);
    color: #ffffff;
    border-color: var(--pt-accent);
}

.variations-modal .modal-cancel:hover {
    border-color: var(--pt-accent);
    color: var(--pt-accent);
}

.variations-modal .modal-add-to-cart:hover {
    background: #111827;
    border-color: #111827;
}

/* Bulk Order Summary */
.bulk-order-summary {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.bulk-order-summary__content {
    background: #ffffff;
    border-radius: 14px;
    width: min(520px, 92vw);
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.25);
    padding: 20px;
    position: relative;
}

.bulk-order-summary__content h3 {
    margin: 0 0 12px;
    font-size: 18px;
    color: var(--pt-ink);
}

.bulk-order-summary__section h4 {
    margin: 12px 0 6px;
    font-size: 14px;
    color: var(--pt-ink);
}

.bulk-order-summary__list {
    margin: 0;
    padding-left: 18px;
    color: var(--pt-ink);
    font-size: 13px;
}

.bulk-order-summary__close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
}

/* WooCommerce cart quantity field fix */
.woocommerce-cart .woocommerce table.shop_table .quantity .qty {
    min-width: 4.5em;
    width: 4.5em;
    text-align: center;
    padding-left: 6px;
    padding-right: 6px;
}
