.ehtgrid-attributes-container {
    margin-top: 10px;
    position: relative;
    z-index: 10;
}

/* --- Positioning Classes (Over Image) for Container --- */
.ehtgrid-attributes-container.pos-over_bottom,
.ehtgrid-attributes-container.pos-over_top_right,
.ehtgrid-attributes-container.pos-over_top_left,
.ehtgrid-attributes-container.pos-over_bottom_right,
.ehtgrid-attributes-container.pos-over_bottom_left {
    position: absolute;
    margin: 0;
    padding: 5px;
    width: auto;
    max-width: 100%;
    box-sizing: border-box;
}

.ehtgrid-attributes-container.pos-over_bottom { bottom: 10px; left: 50%; transform: translateX(-50%); width: 90%; display: flex; justify-content: center; }
.ehtgrid-attributes-container.pos-over_bottom .ehtgrid-attribute-values { justify-content: center; }

.ehtgrid-attributes-container.pos-over_top_right { top: 10px; right: 10px; display: flex; flex-direction: column; align-items: flex-end; }
.ehtgrid-attributes-container.pos-over_top_right .ehtgrid-attribute-values { flex-direction: column; gap: 5px; }

.ehtgrid-attributes-container.pos-over_top_left { top: 10px; left: 10px; display: flex; flex-direction: column; align-items: flex-start; }
.ehtgrid-attributes-container.pos-over_top_left .ehtgrid-attribute-values { flex-direction: column; gap: 5px; }

.ehtgrid-attributes-container.pos-over_bottom_right { bottom: 10px; right: 10px; display: flex; flex-direction: column; align-items: flex-end; }
.ehtgrid-attributes-container.pos-over_bottom_right .ehtgrid-attribute-values { flex-direction: column; gap: 5px; }

.ehtgrid-attributes-container.pos-over_bottom_left { bottom: 10px; left: 10px; display: flex; flex-direction: column; align-items: flex-start; }
.ehtgrid-attributes-container.pos-over_bottom_left .ehtgrid-attribute-values { flex-direction: column; gap: 5px; }


/* --- Positioning Classes (Over Image) for Badges --- */
.ehtgrid-badge.pos-over_bottom { bottom: 10px; left: 50%; transform: translateX(-50%); }
.ehtgrid-badge.pos-over_top_right { top: 10px; right: 10px; }
.ehtgrid-badge.pos-over_top_left { top: 10px; left: 10px; }
.ehtgrid-badge.pos-over_bottom_right { bottom: 10px; right: 10px; }
.ehtgrid-badge.pos-over_bottom_left { bottom: 10px; left: 10px; }


/* Alignment Classes (Standard Flow) */
.ehtgrid-attributes-container.align-left .ehtgrid-attribute-values { justify-content: flex-start; }
.ehtgrid-attributes-container.align-center .ehtgrid-attribute-values { justify-content: center; }
.ehtgrid-attributes-container.align-right .ehtgrid-attribute-values { justify-content: flex-end; }
.ehtgrid-attributes-container.align-center .ehtgrid-group-name { text-align: center; }
.ehtgrid-attributes-container.align-right .ehtgrid-group-name { text-align: right; }


.ehtgrid-badges {
    position: absolute;
    top: -200px;
    left: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* Badge Styles with Dynamic Variables */
.ehtgrid-badge {
    border-radius: 3px;
    color: white;
    font-size: 0.8em;
    font-weight: bold;
    text-transform: uppercase;
    display: inline-block;
}

.badge-stock-in {
    background-color: var(--ehtgrid-stock-in);
    margin: var(--ehtgrid-margin-stock);
    padding: var(--ehtgrid-padding-stock);
}
.badge-stock-last {
    background-color: var(--ehtgrid-stock-last);
    margin: var(--ehtgrid-margin-last);
    padding: var(--ehtgrid-padding-last);
}
.badge-stock-oos {
    background-color: #999;
    margin: var(--ehtgrid-margin-oos);
    padding: var(--ehtgrid-padding-oos);
}
.badge-discount {
    background-color: var(--ehtgrid-discount);
    margin: var(--ehtgrid-margin-discount);
    padding: var(--ehtgrid-padding-discount);
}

.ehtgrid-attribute-group { margin-bottom: 5px; }
.ehtgrid-group-name { font-size: 0.9em; font-weight: bold; display: block; margin-bottom: 3px; }
.ehtgrid-attribute-values { display: flex; flex-wrap: wrap; gap: 5px; }

.ehtgrid-attribute-option {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid #ddd;
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 0.85em;
    transition: all 0.2s;
    text-decoration: none !important;
    color: inherit;
    min-height: 24px;
    vertical-align: middle;
    text-align: center;
    background-color: rgba(255, 255, 255, 0.9);
}
.ehtgrid-attribute-option:hover { border-color: #999; }

/* --- Stock Alert Themes --- */
.ehtgrid-envelope { display: flex; align-items: center; justify-content: center; }
.ehtgrid-envelope svg { stroke: #666; }

/* Theme: Overlay (Envelope background, Attribute on top) */
.ehtgrid-attribute-option.out-of-stock.theme-overlay { opacity: 0.8; }
.ehtgrid-attribute-option.out-of-stock.theme-overlay .ehtgrid-envelope { position: absolute; width: 100%; height: 100%; top: 0; left: 0; z-index: 1; opacity: 0.3; pointer-events: none; }
.ehtgrid-attribute-option.out-of-stock.theme-overlay .text-swatch, .ehtgrid-attribute-option.out-of-stock.theme-overlay .color-swatch { position: relative; z-index: 2; }

/* Theme: Crossed (Envelope background, Attribute crossed out) */
.ehtgrid-attribute-option.out-of-stock.theme-crossed { flex-direction: column; align-items: center; justify-content: center; height: auto; padding: 4px 5px; gap: 2px; }
.ehtgrid-attribute-option.out-of-stock.theme-crossed .ehtgrid-envelope { position: relative; width: auto; height: auto; opacity: 1; margin-top: 2px; margin-left: auto; margin-right: auto; }
.ehtgrid-attribute-option.out-of-stock.theme-crossed .ehtgrid-envelope svg { width: 12px; height: 12px; display: block; }
.ehtgrid-attribute-option.out-of-stock.theme-crossed.text-option .text-swatch { text-decoration: line-through; opacity: 0.7; display: block; margin: 0 auto; }
.ehtgrid-attribute-option.out-of-stock.theme-crossed.color-option .color-swatch { position: relative; margin: 0 auto; }
.ehtgrid-attribute-option.out-of-stock.theme-crossed.color-option .color-swatch::after { content: ''; position: absolute; top: 50%; left: -2px; width: calc(100% + 4px); height: 1px; background-color: #555; transform: rotate(-45deg); }

/* Theme: Line (Attribute crossed out horizontally) */
.ehtgrid-attribute-option.out-of-stock.theme-line { opacity: 0.7; }
.ehtgrid-attribute-option.out-of-stock.theme-line .ehtgrid-envelope { display: none; } /* Hide envelope */
.ehtgrid-attribute-option.out-of-stock.theme-line.text-option .text-swatch { text-decoration: line-through; }
.ehtgrid-attribute-option.out-of-stock.theme-line.color-option .color-swatch { position: relative; }
.ehtgrid-attribute-option.out-of-stock.theme-line.color-option .color-swatch::after { content: ''; position: absolute; top: 50%; left: -2px; width: calc(100% + 4px); height: 1px; background-color: #555; transform: rotate(0deg); }

/* Theme: X (Attribute crossed out with an X) */
.ehtgrid-attribute-option.out-of-stock.theme-x { opacity: 0.7; }
.ehtgrid-attribute-option.out-of-stock.theme-x .ehtgrid-envelope { display: none; } /* Hide envelope */
.ehtgrid-attribute-option.out-of-stock.theme-x.text-option .text-swatch { /* position: relative; */ }
.ehtgrid-attribute-option.out-of-stock.theme-x.text-option .text-swatch::before,
.ehtgrid-attribute-option.out-of-stock.theme-x.text-option .text-swatch::after { content: ''; position: absolute; top: 50%; left: 0; width: 100%; height: 1px; background-color: #555; }
.ehtgrid-attribute-option.out-of-stock.theme-x.text-option .text-swatch::before { transform: rotate(45deg); }
.ehtgrid-attribute-option.out-of-stock.theme-x.text-option .text-swatch::after { transform: rotate(-45deg); }

.ehtgrid-attribute-option.out-of-stock.theme-x.color-option .color-swatch { /* The cross is now on the parent */ }
.ehtgrid-attribute-option.out-of-stock.theme-x.color-option::before,
.ehtgrid-attribute-option.out-of-stock.theme-x.color-option::after { content: ''; position: absolute; top: 50%; left: 0; width: 100%; height: 1px; background-color: #555; }
.ehtgrid-attribute-option.out-of-stock.theme-x.color-option::before { transform: rotate(45deg); }
.ehtgrid-attribute-option.out-of-stock.theme-x.color-option::after { transform: rotate(-45deg); }


.color-option .color-swatch { display: block; width: 16px; height: 16px; border-radius: 50%; border: 1px solid #ccc; }
.text-option .text-swatch { display: block; padding: 0 2px; line-height: 1.2; }
.ehtgrid-attribute-option.active { border-color: var(--ehtgrid-btn-bg); box-shadow: 0 0 3px var(--ehtgrid-btn-bg); }

/* --- Modal --- */
.ehtgrid-modal {
    position: fixed;
    z-index: 2147483647;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}
.ehtgrid-modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 25px;
    border: 1px solid #888;
    width: 90%;
    max-width: 500px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    position: relative;
    animation: ehtgrid-animatetop 0.4s;
    /* Ensure content is not affected by parent styles */
    text-align: left;
    color: #333;
}
@keyframes ehtgrid-animatetop { from {top: -300px; opacity: 0} to {top: 0; opacity: 1} }
.ehtgrid-close { color: #aaa; float: right; font-size: 28px; font-weight: bold; cursor: pointer; position: absolute; right: 15px; top: 10px; line-height: 1; }
.ehtgrid-close:hover, .ehtgrid-close:focus { color: black; text-decoration: none; cursor: pointer; }
.ehtgrid-modal h3 { margin-top: 0; margin-bottom: 20px; font-size: 1.2rem; text-transform: uppercase; text-align: center; padding-right: 20px; }
.ehtgrid-modal-body p { text-align: center; margin-bottom: 20px; color: #666; }
.ehtgrid-mailalert-form .form-group { margin-bottom: 15px; }
.ehtgrid-mailalert-form .form-control { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 4px; box-sizing: border-box; }
.ehtgrid-mailalert-form .btn { width: 100%; background-color: var(--ehtgrid-btn-bg); color: var(--ehtgrid-btn-text); border: none; padding: 12px; border-radius: 4px; font-weight: bold; text-transform: uppercase; cursor: pointer; transition: opacity 0.2s; }
.ehtgrid-mailalert-form .btn:hover { opacity: 0.9; }
.ehtgrid-message { padding: 10px; border-radius: 3px; font-size: 0.9em; text-align: center; }
.ehtgrid-message.success { background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.ehtgrid-message.error { background-color: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
