/* Farbwähler Modal v1.3.2 */

/* ── SOFORT ausblenden – verhindert Aufblitzen ───────────────────────
   Wird gesetzt sobald fw_active=1 am Produkt → PHP injiziert diese Klasse
   auf body, BEVOR JS lädt                                              */
body.fw-active div.ux-swatches[data-attribute_name],
body.fw-active div.variation-selector {
    display: none !important;
}

/* ── Button ─────────────────────────────────────────────────────────── */
.fw-button-wrap {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.fw-trigger-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px 12px 16px;
    background: #1260a5;
    border: 2px solid #1260a5;
    border-radius: 15px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    line-height: 1.2;
}
.fw-trigger-btn:hover {
    background: #fff;
    border-color: #1260a5;
    color: #1260a5;
    box-shadow: 0 2px 8px rgba(18,96,165,0.15);
}
.fw-trigger-btn.has-selection {
    background: #fff;
    border-color: #1260a5;
    color: #111;
}
.fw-trigger-btn.has-selection .fw-btn-icon {
    display: none;
}
.fw-trigger-btn.has-selection:hover {
    background: #fff;
    border-color: #1260a5;
    color: #1260a5;
}

.fw-btn-preview {
    width: 22px;
    height: 22px;
    border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.15);
    display: none;
    flex-shrink: 0;
}

.fw-btn-icon svg { transition: fill 0.15s; }
.fw-trigger-btn:hover .fw-btn-icon svg { fill: #1260a5; }

.fw-selected-label {
    font-size: 13px;
    color: #555;
}

/* ── Overlay ─────────────────────────────────────────────────────────── */
.fw-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99990;
}

/* ── Modal ──────────────────────────────────────────────────────────── */
.fw-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25), 0 0 0 1px rgba(0,0,0,0.07);
    z-index: 99999;
    overflow: hidden;
    min-width: 300px;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    transform: translate(-50%, -48%);
}
.fw-modal.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%);
}
.fw-modal.is-closing {
    opacity: 0;
    transform: translate(-50%, -48%);
    pointer-events: none;
}
.fw-modal .fw-grid {
    overflow-y: auto;
    flex: 1;
}

.fw-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px 10px 20px;
    border-bottom: 1px solid #f0f0f0;
}
.fw-modal-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.fw-modal-title {
    font-size: 16px;
    font-weight: 500;
    color: #111;
    letter-spacing: 0.01em;
}
.fw-modal-subtitle {
    font-size: 11px;
    font-weight: 400;
    color: #999;
}
.fw-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: #aaa;
    padding: 2px 4px;
    border-radius: 3px;
    line-height: 1;
    transition: background 0.1s, color 0.1s;
}
.fw-modal-close:hover {
    background: #f3f4f6;
    color: #111;
}

/* ── Suchfeld ───────────────────────────────────────────────────────── */
.fw-search-wrap {
    position: relative;
    padding: 8px 10px 6px;
    border-bottom: 1px solid #f0f0f0;
}
.fw-search {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 36px 8px 14px;
    border: 1.5px solid #e2e8f0 !important;
    border-radius: 8px !important;
    -webkit-border-radius: 8px !important;
    -moz-border-radius: 8px !important;
    border-top-left-radius: 8px !important;
    border-top-right-radius: 8px !important;
    border-bottom-left-radius: 8px !important;
    border-bottom-right-radius: 8px !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    font-size: 13px;
    color: #111;
    background: #f8f9fa;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
}
.fw-search:focus {
    border-color: #111;
    background: #fff;
}
.fw-search-icon {
    position: absolute;
    right: 20px;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    line-height: 0;
}

/* ── Swatch-Grid ────────────────────────────────────────────────────── */
.fw-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px;
}

/* ── Swatch Wrapper (mit Nummer) ────────────────────────────────────── */
.fw-swatch-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    cursor: pointer;
}
.fw-swatch-num {
    font-size: 13px;
    color: #444;
    font-weight: 700;
    line-height: 1;
    text-align: center;
}

/* ── Swatch ─────────────────────────────────────────────────────────── */
.fw-swatch {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    border-radius: 5px;
    cursor: pointer;
    border: 2px solid transparent;
    position: relative;
    box-sizing: border-box;
    transition: transform 0.1s ease;
}
.fw-swatch:hover {
    transform: scale(1.15);
    z-index: 2;
}
.fw-swatch.is-light {
    border-color: #ddd;
}
.fw-swatch.is-active {
    border-color: #111;
    box-shadow: 0 0 0 1px #fff inset;
}
.fw-swatch.is-active::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 2px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 6l3 3 5-5' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E") center/11px no-repeat;
}

/* ── Hover-Preview Box ──────────────────────────────────────────────── */
#fw-hover-preview {
    position: fixed;
    z-index: 999999;
    pointer-events: none;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: #fff;
    border-radius: 10px;
    padding: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.22), 0 0 0 1px rgba(0,0,0,0.07);
    transform: translate(-50%, calc(-100% - 14px));
}
#fw-hover-preview.is-visible {
    display: flex;
}
#fw-hover-preview-color {
    width: 150px;
    height: 150px;
    border-radius: 10px;
    border: 1px solid rgba(0,0,0,0.10);
}
#fw-hover-preview-label {
    font-size: 13px;
    font-weight: 600;
    color: #111;
    white-space: nowrap;
    max-width: 140px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Mobile ─────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .fw-modal {
        top: 50% !important;
        left: 50% !important;
        right: auto !important;
        bottom: auto !important;
        width: calc(100vw - 32px) !important;
        max-width: calc(100vw - 32px) !important;
        max-height: 80vh !important;
        border-radius: 12px !important;
    }
    #fw-hover-preview { display: none !important; }
}
