// ---- Style commun des champs custom Elementum ----
.customize-control-remix_icon,
.customize-control-color_contrast,
.customize-control-page,
.customize-control-post {
    background: #fff;
    padding: 0.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    box-sizing: border-box;

    .customize-control-description {
        font-size: 11px;
        font-style: italic;
        color: #888;
        margin: 2px 0 4px;
        line-height: 1.4;
    }
}

// ---- Composants partagés (ECF = Elementum Customize Field) ----
.ecf-select-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
}

.ecf-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: #f8f8f8;
    border-radius: 6px;
    border: 1px solid #eee;

    .ecf-preview-icon {
        flex-shrink: 0;
        font-size: 16px;
        color: #2271b1;
    }

    .ecf-preview-name {
        flex: 1 1 auto;
        font-size: 12px;
        font-weight: 500;
        color: #333;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        min-width: 0;
    }

    .ecf-preview-badge {
        flex-shrink: 0;
        font-size: 10px;
        font-weight: 600;
        padding: 1px 6px;
        border-radius: 9999px;
        background: #e8f0fe;
        color: #2271b1;
        text-transform: uppercase;
        letter-spacing: 0.03em;
    }

    &.ecf-preview--empty {
        display: none;
    }
}

.ecf-select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 12px;
    background: #fff;
    cursor: pointer;
    box-sizing: border-box;
    appearance: auto;

    &:focus {
        border-color: #2271b1;
        outline: 1px solid #2271b1;
    }

    &--hidden {
        display: none;
    }
}

.ecf-loading {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #888;
    padding: 4px 0;
}

@keyframes ecf-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.ecf-spin {
    animation: ecf-spin 0.8s linear infinite;
}

// ---- RemixIconSelect field ----
.remix-icon-select {

    .ris-field {
        display: flex;
        flex-direction: column;
        gap: 6px;
        margin-top: 6px;
    }

    // ---- Aperçu de l'icône sélectionnée ----
    .ris-preview {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 6px 8px;
        background: #f8f8f8;
        border-radius: 6px;
        border: 1px solid #eee;

        .ris-preview-icon {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 36px;
            height: 36px;
            background: #fff;
            border-radius: 6px;
            border: 1px solid #ddd;
            flex-shrink: 0;
            color: #333;
        }

        .ris-preview-name {
            flex: 1 1 auto;
            font-family: ui-monospace, "SF Mono", Menlo, monospace;
            font-size: 11px;
            color: #666;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            min-width: 0;
        }
    }

    // ---- Barre de recherche ----
    .ris-search {
        position: relative;
        display: flex;
        align-items: center;

        .ris-search-icon {
            position: absolute;
            left: 8px;
            font-size: 14px;
            color: #999;
            pointer-events: none;
        }

        .ris-search-input {
            width: 100%;
            padding: 6px 30px 6px 28px;
            border: 1px solid #ddd;
            border-radius: 6px;
            font-size: 12px;
            min-width: 0;
            box-sizing: border-box;

            &:focus {
                border-color: #2271b1;
                outline: 1px solid #2271b1;
            }

            &::placeholder {
                color: #aaa;
                font-style: italic;
            }
        }

        .ris-search-clear {
            position: absolute;
            right: 4px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 22px;
            height: 22px;
            padding: 0;
            border: none;
            border-radius: 4px;
            background: transparent;
            cursor: pointer;
            color: #888;
            font-size: 14px;

            &:hover {
                background: #eee;
                color: #333;
            }
        }
    }

    // ---- Compteur de résultats ----
    .ris-count {
        font-size: 10px;
        color: #999;
        font-weight: 500;
        letter-spacing: 0.02em;
    }

    // ---- Grille d'icônes ----
    .ris-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, 32px);
        gap: 4px;
        justify-content: start;
        max-height: 180px;
        overflow-y: auto;
        padding: 6px;
        background: #f8f8f8;
        border-radius: 6px;
        border: 1px solid #eee;

        .ris-icon {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 32px;
            height: 32px;
            padding: 0;
            border: 1px solid transparent;
            border-radius: 5px;
            background: transparent;
            cursor: pointer;
            color: #555;
            font-size: 16px;
            transition: all 0.12s ease;

            &:hover {
                background: #fff;
                border-color: #ccc;
                color: #222;
                transform: scale(1.15);
            }

            &.selected {
                background: #2271b1;
                border-color: #2271b1;
                color: #fff;

                &:hover {
                    background: #135e96;
                    border-color: #135e96;
                    color: #fff;
                }
            }
        }
    }

    // ---- État vide ----
    .ris-empty {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        padding: 16px 8px;
        color: #aaa;
        font-size: 11px;
        background: #f8f8f8;
        border-radius: 6px;
        border: 1px solid #eee;

        i {
            font-size: 24px;
            opacity: 0.5;
        }
    }
}

// ---- ColorContrast field ----
.color-contrast-checker {

    // ---- Picker row : [swatch] [#hex] [reset] ----
    .cc-picker {
        display: flex;
        align-items: center;
        gap: 6px;
        margin-top: 6px;

        input[type="color"] {
            width: 36px;
            height: 36px;
            padding: 0;
            border: 2px solid #ddd;
            border-radius: 6px;
            cursor: pointer;
            flex-shrink: 0;

            &::-webkit-color-swatch-wrapper { padding: 2px; }
            &::-webkit-color-swatch { border: none; border-radius: 3px; }
            &::-moz-color-swatch { border: none; border-radius: 3px; }
        }

        .cc-hex-input {
            flex: 1 1 auto;
            font-family: ui-monospace, "SF Mono", Menlo, monospace;
            font-size: 12px;
            padding: 6px 8px;
            border: 1px solid #ddd;
            border-radius: 6px;
            text-transform: uppercase;
            letter-spacing: 0.03em;
            min-width: 0;

            &:focus {
                border-color: #2271b1;
                outline: 1px solid #2271b1;
            }
        }

        .cc-reset {
            flex-shrink: 0;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 36px;
            height: 36px;
            padding: 0;
            border: 1px solid #ddd;
            border-radius: 6px;
            background: #fafafa;
            cursor: pointer;
            color: #555;
            font-size: 16px;
            transition: background 0.15s, border-color 0.15s;

            &:hover {
                background: #f0f0f0;
                border-color: #999;
            }
        }
    }

    // ---- Contrast comparisons ----
    .cc-contrasts {
        margin-top: 8px;
        display: flex;
        flex-direction: column;
        gap: 4px;

        .cc-contrasts-title {
            font-size: 11px;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            color: #888;
            margin-bottom: 2px;
        }
    }

    .contrast-row {
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 4px 6px;
        background: #f8f8f8;
        border-radius: 5px;
        transition: background 0.15s;

        &:hover { background: #f0f0f0; }

        .contrast-swatch {
            width: 24px;
            height: 24px;
            border-radius: 4px;
            border: 1px solid rgba(0, 0, 0, 0.12);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            font-size: 11px;

            i.black { color: #000; }
            i.white { color: #fff; }
        }

        .contrast-label {
            flex: 1 1 auto;
            font-size: 11px;
            color: #444;
            line-height: 1.3;
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .contrast-badge {
            flex-shrink: 0;
            font-size: 11px;
            font-weight: 600;
            font-family: ui-monospace, "SF Mono", Menlo, monospace;
            padding: 1px 6px;
            border-radius: 9999px;

            &.pass {
                background: #d4edda;
                color: #155724;
            }

            &.fail {
                background: #f8d7da;
                color: #721c24;
            }
        }

        .wcag-level {
            flex-shrink: 0;
            font-size: 10px;
            font-weight: 700;
            padding: 1px 5px;
            border-radius: 3px;
            letter-spacing: 0.02em;

            &.aaa {
                background: #155724;
                color: #fff;
            }

            &.aa {
                background: #28a745;
                color: #fff;
            }

            &.fail {
                background: #dc3545;
                color: #fff;
            }
        }
    }
}
