/**
 * HEU Matrix Ordering Styles
 *
 * @package HEU_Admin
 * @version 1.0.0
 */

/* Matrix Ordering Container */
.heu-matrix-ordering-container {
    margin: 20px 0;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
}

.heu-matrix-ordering {
    max-width: 100%;
}

/* Attribute Selection */
.heu-attribute-selection {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.heu-attribute-group {
    margin-bottom: 15px;
}

.heu-attribute-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.heu-attribute-select {
    width: 100%;
    max-width: 300px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    font-size: 14px;
}

.heu-attribute-select:focus {
    outline: none;
    border-color: #93a21e;
    box-shadow: 0 0 0 1px #93a21e;
}

/* Tab Interface */
.heu-tab-interface {
    margin-top: 20px;
}

.heu-tab-buttons {
    display: flex;
    border-bottom: 2px solid #eee;
    margin-bottom: 20px;
}

.heu-tab-button {
    flex: 1;
    padding: 12px 20px;
    background: #f8f9fa;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    transition: all 0.3s ease;
}

.heu-tab-button:hover {
    background: #e9ecef;
    color: #333;
}

.heu-tab-button.active {
    background: #fff;
    color: #93a21e;
    border-bottom-color: #93a21e;
}

.heu-tab-content {
    display: none;
    padding: 20px 0;
}

.heu-tab-content.active {
    display: block;
}

/* Single Size Selection */
.heu-single-size-selection {
    max-width: 400px;
}

.heu-single-size-selection label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.heu-size-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    font-size: 14px;
    margin-bottom: 15px;
}

.heu-size-select:focus {
    outline: none;
    border-color: #93a21e;
    box-shadow: 0 0 0 1px #93a21e;
}

.heu-quantity-wrapper {
    margin-bottom: 20px;
}

.heu-quantity-wrapper label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.heu-quantity-input {
    width: 80px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    font-size: 14px;
    text-align: center;
}

.heu-quantity-input:focus {
    outline: none;
    border-color: #93a21e;
    box-shadow: 0 0 0 1px #93a21e;
}

/* Matrix Grid */
.heu-matrix-grid {
    max-width: 600px;
}

.heu-matrix-header {
    margin-bottom: 20px;
}

.heu-matrix-header h4 {
    margin: 0;
    color: #333;
    font-size: 16px;
}

.heu-matrix-sizes {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
    max-width: 1000px;
    justify-content: center;
}

.heu-matrix-size-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 12px 8px 18px 8px;
    border: none;
    border-radius: 8px;
    background: #fff;
    transition: all 0.2s ease;
    min-height: 110px;
    position: relative;
    width: 100%;
    max-width: 120px;
    justify-self: center;
    box-shadow: none;
}

.heu-matrix-size-item:hover {
    box-shadow: none;
    transform: none;
}

.heu-matrix-size-item label {
    margin-bottom: 6px;
    font-weight: 700;
    color: #B8860B;
    text-align: center;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    line-height: 1.1;
}

/* Compact size price display - removed, will be replaced by price difference badge */
.heu-size-price {
    display: none;
}

/* Price difference badge - positioned at bottom of card with better spacing */
.heu-size-price-badge {
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    font-weight: 700;
    padding: 3px 6px;
    line-height: 1;
    text-align: center;
    min-width: 40px;
    max-width: 70px;
    background: transparent;
    color: #dc3232;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border: none;
}

/* Base price items - no badge shown */
.heu-matrix-size-item.is-base-price .heu-size-price-badge {
    display: none;
}

/* Upcharge items - show red badge */
.heu-matrix-size-item.has-upcharge {
    border: none;
    background: #fff;
}

.heu-matrix-size-item.has-upcharge .heu-size-price-badge {
    background: transparent;
    color: #dc3232;
    border: none;
    display: block;
}

/* Discount items - show green badge */
.heu-matrix-size-item.has-discount {
    border: none;
    background: #fff;
}

.heu-matrix-size-item.has-discount .heu-size-price-badge {
    background: transparent;
    color: #46b450;
    border: none;
    display: block;
}

/* Base price items - subtle styling */
.heu-matrix-size-item.is-base-price {
    border: none;
    background: #fff;
}

.heu-quantity-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
}

.heu-quantity-decrease,
.heu-quantity-increase {
    width: 24px;
    height: 24px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    line-height: 1;
}

.heu-quantity-decrease:hover,
.heu-quantity-increase:hover {
    background: #c2d259;
    color: #fff;
    border-color: #c2d259;
}

.heu-quantity-decrease:disabled,
.heu-quantity-increase:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.heu-matrix-quantity {
    width: 32px;
    height: 24px;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: 3px;
    background: transparent;
    font-size: 12px;
    text-align: center;
    font-weight: 600;
    color: #333;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    line-height: 24px;
}

.heu-matrix-quantity:focus {
    outline: none;
}

/* Matrix Summary */
.heu-matrix-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: transparent;
    border: none;
    border-radius: 0;
    margin-bottom: 20px;
}

.heu-total-quantity,
.heu-total-price {
    font-size: 14px;
    color: #333;
}

.heu-total-quantity span,
.heu-total-price span {
    font-weight: 600;
    color: #bf7602;
}

/* Unified Summary */
.heu-unified-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border: 2px solid #93a21e;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 16px;
    color: #333;
}

.heu-unified-total-quantity,
.heu-unified-total-price {
    font-weight: 500;
    color: #333;
}

.heu-unified-total-quantity span,
.heu-unified-total-price span {
    font-weight: 700;
    color: #93a21e;
    margin-left: 5px;
}

/* Buttons */
.heu-add-single-to-cart,
.heu-add-matrix-to-cart {
    width: 100%;
    max-width: 200px;
    padding: 12px 20px;
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    display: inline-block;
    line-height: 1.4;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.heu-add-single-to-cart:hover:not(.disabled),
.heu-add-matrix-to-cart:hover:not(.disabled) {
    background: #005a87;
}

.heu-add-single-to-cart:focus,
.heu-add-matrix-to-cart:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.heu-add-single-to-cart:disabled,
.heu-add-matrix-to-cart:disabled,
.heu-add-single-to-cart.disabled,
.heu-add-matrix-to-cart.disabled {
    background: #ccc !important;
    cursor: not-allowed !important;
    opacity: 0.6;
    pointer-events: none;
}

/* Loading States */
.heu-loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.heu-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: heu-spin 1s linear infinite;
}

.heu-matrix-ordering-container.loading {
    position: relative;
}

.heu-matrix-ordering-container.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 10;
}

.heu-matrix-ordering-container.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0073aa;
    border-radius: 50%;
    animation: heu-spin 1s linear infinite;
    z-index: 11;
}

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

/* Disabled States */
.heu-matrix-size-item.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.heu-matrix-size-item.disabled .heu-quantity-controls {
    opacity: 0.3;
}

/* Unavailable Sizes */
.heu-matrix-size-item.unavailable {
    display: none;
}

/* Error States */
.heu-error {
    color: #dc3232;
    font-size: 14px;
    margin-top: 10px;
}

.heu-success {
    color: #46b450;
    font-size: 14px;
    margin-top: 10px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .heu-matrix-ordering-container {
        padding: 15px;
        margin: 15px 0;
    }

    .heu-tab-buttons {
        flex-direction: column;
    }

    .heu-tab-button {
        border-bottom: 1px solid #eee;
        border-right: none;
    }

    .heu-tab-button.active {
        border-bottom-color: #93a21e;
    }

    .heu-matrix-sizes {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .heu-matrix-summary {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .heu-add-single-to-cart,
    .heu-add-matrix-to-cart {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .heu-matrix-ordering-container {
        padding: 10px;
    }

    .heu-tab-content {
        padding: 15px 0;
    }

    .heu-matrix-size-item {
        padding: 10px;
    }

    .heu-quantity-controls {
        gap: 5px;
    }

    .heu-quantity-decrease,
    .heu-quantity-increase {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    .heu-matrix-quantity {
        width: 50px;
        height: 28px;
        font-size: 12px;
    }
}

/* PEWC Integration - Hide Grand Total since we have unified total */
.pewc-total-field-wrapper:has(bdi:contains("Grand total")),
p:contains("Grand total") {
    display: none !important;
}

/* Alternative selectors for Grand Total removal */
.heu-matrix-ordering .pewc-total-field-wrapper bdi {
    /* Let JavaScript handle Grand Total hiding */
}

/* PEWC Fields Container */
.pewc-fields-container {
    margin: 20px 0;
}

.pewc-fields-container .pewc-placeholder {
    padding: 20px;
    text-align: center;
    color: #666;
    font-style: italic;
}

.pewc-fields-container .pewc-product-extra-groups-wrap {
    margin-top: 0;
}

/* PEWC Logo Field Customizations */
.heu-logo-status {
    font-weight: 500;
    color: #2c5530;
    background: #e8f5e8;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 13px;
}

.heu-logo-thumbnail {
    display: inline-block;
    vertical-align: middle;
}

.heu-logo-thumb {
    border: 2px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: border-color 0.2s ease;
}

.heu-logo-thumb:hover {
    border-color: #007cba;
}

/* Remove flat rate cost text for logo fields */
.pewc-flat-rate-cart-label {
    display: none !important;
}

/* Custom styling for logo fields in cart */
.cart .pewc-cart-item-name {
    position: relative;
}

.cart .heu-logo-field {
    margin-top: 5px;
    padding: 5px 0;
    border-top: 1px solid #f0f0f0;
}

.cart .heu-logo-field dt {
    font-weight: 500;
    color: #333;
}

.cart .heu-logo-field dd {
    margin: 0;
    padding: 0;
}
