/* ==== COMPACT BULK ORDER MATRIX ==== */

/* Reset table defaults */
.matrix-table {
    border-collapse: collapse;
    border-spacing: 0;
    width: 100%;
    table-layout: fixed;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Fix for BUY NOW button positioning */
.single_add_to_cart_button.button.alt {
    width: auto !important;
    min-width: 200px !important;
    max-width: 250px !important;
    padding: 16px 30px !important;
    margin: 20px 0 !important;
    display: inline-block !important;
}

/* Ensure the bulk order modal button works */
a.bulk-order-trigger {
    cursor: pointer;
    color: #0C1FAB !important;
    text-decoration: underline !important;
    font-weight: 600;
}

/* When modal is open */
body.bulk-order-open {
    overflow: hidden !important;
}

body.bulk-order-open .bulk-order-popup {
    display: block !important;
}

/* Table Container */
.matrix-table-container {
    max-width: 100%;
    max-height: 600px;
    overflow-x: auto;
    overflow-y: auto;
    margin-bottom: 20px;
    border: 1px solid #eaeeae;
    border-radius: 8px;
    background: #fff;
    position: relative;
    scroll-behavior: smooth;
}

/* ==== TABLE HEADER ==== */
.matrix-table-head {
    position: sticky;
    top: 0;
    z-index: 20;
    background: #f8f9ff !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Header Cells - Matching Footer */
.matrix-table-th {
    padding: 12px 8px !important;
    text-align: center !important;
    font-weight: 700;
    color: #0C1FAB !important;
    border-bottom: 2px solid #0C1FAB;
    font-size: 12px !important;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    background: #f8f9ff !important;
    position: sticky;
    top: 0;
    z-index: 100;
    min-width: 100px;
    vertical-align: middle !important;
    height: 50px;
    box-sizing: border-box;
    border-top: none !important;
}

/* Color Column Header - Matching Footer */
.matrix-table th.color-column {
    text-align: left !important;
    padding: 16px 10px !important;
    position: sticky;
    left: 0;
    top: 0;
    z-index: 150;
    background: #f8f9ff !important;
    border-right: 2px solid #e0e0e0;
    min-width: 120px;
    max-width: 120px;
    font-weight: 700;
    color: #0C1FAB !important;
    height: 50px;
    line-height: 1.2;
    display: table-cell !important;
    border-top: none !important;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
    vertical-align: middle !important;
}

/* Ensure all table cells have same vertical alignment */
.matrix-table th,
.matrix-table td {
    vertical-align: middle !important;
}

/* ==== TABLE BODY ==== */
.matrix-table tbody {
    background: #fff;
    position: relative;
}

/* Table Rows */
.matrix-table tr {
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s;
}

.matrix-table tr:hover {
    background-color: #fafafa;
}

/* ==== COLOR COLUMN ==== */
.color-column {
    min-width: 120px;
    max-width: 120px;
    background: #fafafa;
    border-right: 2px solid #e0e0e0;
    position: sticky;
    left: 0;
    z-index: 15;
    vertical-align: middle !important;
    padding: 0 !important;
    height: 100px;
}

.color-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px !important;
    min-height: 100px;
    height: 100%;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
}

.color-image {
    width: 50px !important;
    height: 50px !important;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    background: #f5f5f5;
    flex-shrink: 0;
}

/* Color Name Display - UPDATED TO 10px */
.color-name {
    font-weight: 600;
    color: #333;
    font-size: 10px !important;
    line-height: 1.3;
    word-break: break-word;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    width: 100%;
    text-align: center;
    margin: 0;
    padding: 0;
}

/* ==== QUANTITY CELLS ==== */
.qty-cell {
    min-width: 100px !important;
    max-width: 100px !important;
    padding: 8px 4px !important;
    text-align: center !important;
    vertical-align: middle !important;
    box-sizing: border-box;
    height: 100px;
}

.qty-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 6px;
    border-radius: 6px;
    background: #fff;
    border: 1px solid #e0e0e0;
    transition: all 0.2s;
    min-height: 85px;
    height: 100%;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

.qty-card:hover {
    border-color: #0C1FAB;
    box-shadow: 0 2px 8px rgba(12, 31, 171, 0.1);
}

/* Quantity Input */
.qty-input-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
}

.qty-input {
    width: 70px !important;
    height: 34px !important;
    text-align: center !important;
    border: 1px solid #0C1FAB !important;
    border-radius: 6px;
    font-size: 13px !important;
    font-weight: 700;
    color: #0C1FAB;
    background: #fff;
    padding: 0 5px;
    -moz-appearance: textfield;
    display: block !important;
    margin: 0 auto !important;
    box-sizing: border-box;
    transition: all 0.2s;
}

.qty-input:focus {
    outline: none;
    border-color: #0C1FAB !important;
    box-shadow: 0 0 0 3px rgba(12, 31, 171, 0.1) !important;
}

/* Hide spinner arrows */
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Price Display */
.price-display {
    font-size: 9px !important;
    font-weight: 700;
    color: #0C1FAB;
    margin-top: 2px;
    text-align: center !important;
    display: block !important;
    width: 100%;
    line-height: 1.2;
    white-space: nowrap;
    overflow: visible;
    word-break: keep-all;
    min-height: 16px;
    padding: 0 2px;
}

/* ===== BOTTOM HEADER ROW ===== */
.bottom-header-row {
    background: #f8f9ff !important;
    border-top: 2px solid #0C1FAB;
    position: sticky;
    bottom: 0;
    z-index: 90;
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.05);
}

.bottom-header-cell {
    padding: 12px 8px !important;
    font-size: 12px !important;
    text-transform: uppercase;
    font-weight: 700;
    color: #0C1FAB !important;
    text-align: center !important;
    vertical-align: middle !important;
    border-top: 2px solid #0C1FAB;
    background: #f8f9ff !important;
    min-width: 100px;
    height: 50px;
    border-bottom: none !important;
    position: sticky;
    bottom: 0;
    z-index: 90;
}

.bottom-header-row .color-column {
    background: #f8f9ff !important;
    text-align: left !important;
    padding: 16px 10px !important;
    font-weight: 700;
    color: #0C1FAB !important;
    border-bottom: none !important;
    height: 50px;
    line-height: 1.2;
    position: sticky;
    left: 0;
    bottom: 0;
    z-index: 95;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
    vertical-align: middle !important;
}

/* ===== OUT OF STOCK STYLING ===== */
.qty-cell.out-of-stock .qty-card {
    opacity: 0.6;
    background: #f9f9f9;
    border-color: #ddd;
}

.qty-cell.out-of-stock .qty-input {
    border-color: #ccc !important;
    color: #999;
    background: #f5f5f5;
}

.qty-cell.out-of-stock .price-display {
    color: #999;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .matrix-table-container {
        border-radius: 6px;
        border-width: 1px;
        max-height: 500px;
    }

    .color-column {
        min-width: 100px !important;
        max-width: 100px !important;
    }

    .color-cell {
        flex-direction: column;
        text-align: center;
        gap: 6px;
        padding: 10px 6px !important;
        min-height: 90px;
        height: 90px;
    }

    .color-image {
        width: 40px !important;
        height: 40px !important;
    }

    .color-name {
        font-size: 9px !important;
        -webkit-line-clamp: 2;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
        width: 100%;
        text-align: center;
    }

    .qty-cell {
        min-width: 85px !important;
        max-width: 85px !important;
        padding: 6px 4px !important;
        height: 90px;
    }

    .qty-card {
        min-height: 75px;
        height: 100%;
        padding: 8px 4px;
        gap: 6px;
    }

    .qty-input {
        width: 65px !important;
        height: 30px !important;
        font-size: 12px !important;
    }

    .price-display {
        font-size: 8px !important;
    }

    .matrix-table th,
    .matrix-table-th,
    .bottom-header-cell {
        font-size: 11px !important;
        padding: 10px 6px !important;
        min-width: 85px;
        height: 40px;
    }

    .matrix-table th.color-column,
    .bottom-header-row .color-column {
        padding-left: 12px !important;
        height: 40px;
    }
}

/* Extra Small Screens */
@media (max-width: 480px) {
    .matrix-table-container {
        max-height: 450px;
    }

    .color-column {
        min-width: 90px !important;
        max-width: 90px !important;
    }

    .color-cell {
        padding: 8px 6px !important;
        min-height: 85px;
        height: 85px;
    }

    .color-name {
        font-size: 8px !important;
    }

    .qty-cell {
        min-width: 80px !important;
        max-width: 80px !important;
        height: 85px;
    }

    .qty-input {
        width: 60px !important;
        height: 28px !important;
        font-size: 11px !important;
    }

    .price-display {
        font-size: 7px !important;
    }

    .matrix-table th,
    .matrix-table-th,
    .bottom-header-cell {
        font-size: 10px !important;
        min-width: 80px;
        height: 35px;
    }
}

/* ===== POPUP STYLES ===== */
.bulk-order-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    display: none;
}

.bulk-order-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(2px);
}

.bulk-order-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 95%;
    max-width: 1200px;
    max-height: 90vh;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.bulk-order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: #0C1FAB;
    color: white;
    flex-shrink: 0;
}

.bulk-order-header h3 {
    margin: 0;
    font-size: 24px;
    color: #ffffff;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.bulk-order-close {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 32px;
    cursor: pointer;
    line-height: 1;
    opacity: 0.8;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.bulk-order-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

.bulk-order-body {
    padding: 30px;
    overflow-y: auto;
    max-height: calc(90vh - 140px);
    flex-grow: 1;
}

.bulk-order-info {
    display: flex;
    gap: 20px;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.product-thumbnail {
    flex-shrink: 0;
}

.product-thumbnail img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #eee;
    background: #f5f5f5;
}

.product-details {
    flex-grow: 1;
}

.product-title {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
}

.product-sku {
    margin: 0;
    color: #666;
    font-size: 14px;
    font-weight: 500;
}

.bulk-order-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    flex-shrink: 0;
    gap: 20px;
}

.totals-display {
    display: flex;
    gap: 30px;
    flex-grow: 1;
}

.total-products,
.total-amount {
    display: flex;
    flex-direction: column;
    min-width: 120px;
}

.total-label {
    font-size: 14px;
    color: #666;
    margin-bottom: 5px;
    font-weight: 500;
}

.total-value {
    font-size: 24px;
    font-weight: 700;
    color: #0C1FAB;
    line-height: 1.2;
}

.add-all-btn {
    background: linear-gradient(135deg, #EF4545 0%, #ff6b6b 100%);
    color: white;
    border: none;
    padding: 16px 40px;
    font-size: 16px;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
    min-width: 180px;
    letter-spacing: 0.5px;
}

.add-all-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #0C1FAB 0%, #1a2fd6 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(12, 31, 171, 0.2);
}

.add-all-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Loading Spinner */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0C1FAB;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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

    100% {
        transform: rotate(360deg);
    }
}

/* Notification */
.bulk-notification {
    position: fixed;
    top: 30px;
    right: 30px;
    padding: 16px 24px;
    background: #28a745;
    color: white;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    z-index: 100000;
    max-width: 400px;
    font-size: 14px;
    font-weight: 500;
    animation: slideIn 0.3s ease;
}

.bulk-notification.error {
    background: #dc3545;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Scrollbar Styling */
.matrix-table-container::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

.matrix-table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.matrix-table-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.matrix-table-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

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

.bulk-order-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.bulk-order-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

/* Empty State */
.empty-matrix {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-matrix-icon {
    font-size: 48px;
    margin-bottom: 20px;
    color: #ddd;
}

.empty-matrix h4 {
    margin: 0 0 10px 0;
    font-size: 18px;
    color: #333;
}

.empty-matrix p {
    margin: 0;
    font-size: 14px;
    max-width: 400px;
    margin: 0 auto;
}

/* Force Hide WooCommerce Notices */
body.single-product .woocommerce-error,
body.single-product .woocommerce-message,
body.single-product .woocommerce-info,
body.single-product .woocommerce-notices-wrapper {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    opacity: 0 !important;
    position: absolute !important;
    z-index: -9999 !important;
}

/* Print Styles */
@media print {

    .bulk-order-popup,
    .bulk-order-overlay {
        display: none !important;
    }
}

/* Accessibility */
.qty-input:focus-visible {
    outline: 2px solid #0C1FAB;
    outline-offset: 2px;
}

.add-all-btn:focus-visible {
    outline: 2px solid #0C1FAB;
    outline-offset: 2px;
}

.bulk-order-close:focus-visible {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .matrix-table th {
        border-bottom: 3px solid #0C1FAB;
    }

    .qty-input {
        border: 2px solid #0C1FAB !important;
    }

    .add-all-btn {
        border: 2px solid transparent;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {

    .bulk-order-popup,
    .bulk-order-container,
    .bulk-notification,
    .qty-card,
    .add-all-btn {
        transition: none !important;
        animation: none !important;
    }
}

/* Ensure consistency between top and bottom headers */
.matrix-table thead th,
.bottom-header-cell {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 12px !important;
    font-weight: 700 !important;
    color: #0C1FAB !important;
    text-transform: uppercase !important;
    letter-spacing: 0.3px;
    background: #f8f9ff !important;
    border-bottom: 2px solid #0C1FAB !important;
}

/* Ensure all header cells are in the same row and properly aligned */
.matrix-table thead tr {
    display: table-row;
    height: 50px;
}

/* Fix for table cell display */
.matrix-table th,
.matrix-table td {
    display: table-cell !important;
}