@use '../abstracts/variables' as *;

@use 'sass:color';

.modal {
    display: none; // Domyślnie ukryty

    &.is-open {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        justify-content: center;
        align-items: center;
        z-index: 100;
    }

    &__overlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.6);
        cursor: pointer;
    }

    &__content {
        position: relative;
        background-color: $white;
        border-radius: 8px;
        width: 90%;
        max-width: 600px;
        display: flex;
        flex-direction: column;
        max-height: 80vh;
    }

    &__header, &__footer {
        padding: 1rem 1.5rem;
        flex-shrink: 0;
    }

    &__header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid $color-border;
    }

    &__title {
        font-size: 1.25rem;
        margin: 0;
    }

    &__close {
        background: transparent;
        border: none;
        font-size: 2rem;
        cursor: pointer;
        line-height: 1;
    }

    &__body {
        padding: 1.5rem;
        overflow-y: auto;
        flex-grow: 1;
    }

    &__footer {
        border-top: 1px solid $color-border;
        text-align: right;
    }

    &__search-results {
        margin-top: 1rem;
        display: grid; // Używamy siatki (grid)
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); // Automatyczne dopasowanie kafelków
        gap: 1rem;
        
        .result-item {
            border: 2px solid $color-border;
            border-radius: 4px;
            padding: 0.75rem;
            cursor: pointer;
            text-align: center;
            font-size: 0.9rem;
            transition: all 0.2s ease-in-out;
            
            &:hover { 
                border-color: color.scale($color-main, $lightness: -10%);
                background-color: $color-bg-element-hover;
            }

            // Styl dla wybranego kafelka
            &.is-selected {
                background-color: $color-main;
                border-color: color.scale($color-main, $lightness: -10%);
                color: $white;
                font-weight: 600;
            }
        }
    }
}