/**
 * Icon Picker — styles pour les champs IconPickerField des CRUDs.
 */

.icon-picker {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;

    &__input-group {
        display: flex;
        gap: 0.5rem;
        align-items: stretch;

        input[type="text"] {
            flex: 1;
        }
    }

    &__btn {
        white-space: nowrap;
    }

    &__preview {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.4rem 0.75rem;
        background: #f8f9fa;
        border: 1px solid #dee2e6;
        border-radius: 4px;
        min-height: 36px;
        font-size: 0.85rem;

        img {
            width: 20px;
            height: 20px;
            display: block;
        }
    }

    &__empty,
    &__missing {
        color: #6c757d;
        font-style: italic;
    }
}

// ─── Modal ────────────────────────────────────────────────────────────

.icon-picker-modal {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: flex;
    align-items: center;
    justify-content: center;

    &__backdrop {
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
    }

    &__dialog {
        position: relative;
        background: #fff;
        border-radius: 8px;
        max-width: 600px;
        width: 90%;
        max-height: 80vh;
        display: flex;
        flex-direction: column;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    }

    &__header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 1rem 1.25rem;
        border-bottom: 1px solid #dee2e6;

        h3 {
            margin: 0;
            font-size: 1.1rem;
        }
    }

    &__close {
        background: none;
        border: none;
        font-size: 1.5rem;
        line-height: 1;
        cursor: pointer;
        color: #6c757d;
        padding: 0 0.5rem;

        &:hover {
            color: #000;
        }
    }

    &__body {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        padding: 1rem 1.25rem;
        overflow: hidden;
    }

    &__search {
        flex-shrink: 0;
    }

    &__grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 0.4rem;
        overflow-y: auto;
        max-height: 50vh;
        padding: 0.25rem;
    }

    &__item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.3rem;
        padding: 0.6rem 0.3rem;
        background: none;
        border: 1px solid transparent;
        border-radius: 4px;
        cursor: pointer;
        transition: all 0.15s;

        img {
            display: block;
        }

        span {
            font-size: 0.65rem;
            color: #6c757d;
            text-align: center;
            word-break: break-word;
            line-height: 1.1;
        }

        &:hover {
            background: #f1f3f5;
            border-color: #ced4da;
        }
    }

    &__empty {
        padding: 2rem;
        text-align: center;
        color: #6c757d;
    }

    &__loading {
        padding: 2rem;
        text-align: center;
        color: #6c757d;
    }
}
