﻿.global-search-container {
    position: relative;
    width: 100%;
    max-width: 380px;
    margin: 0 auto;

    @media (max-width: 768px) {
        max-width: 100%;
        margin-top: 8px;
        margin-bottom: 8px;
    }

    .global-search-input-wrapper {
        position: relative;
        display: flex;
        align-items: center;
        width: 100%;

        .search-icon {
            position: absolute;
            left: 12px;
            width: 18px;
            height: 18px;
            stroke: #8e9aab;
            pointer-events: none;
            z-index: 2;
        }

        .global-search-input {
            display: block;
            flex: 1; /* Forza l'input a occupare tutto lo spazio flex */
            width: 100% !important; /* Scavalca eventuali width: auto di Bootstrap */
            max-width: 100% !important; /* Scavalca eventuali max-width di Bootstrap */
            box-sizing: border-box;
            padding: 9px 36px 9px 38px;
            font-size: 0.9rem;
            color: #fff;
            background-color: rgba(255, 255, 255, 0.08);
            border: 1px solid rgba(255, 255, 255, 0.18);
            border-radius: 24px;
            backdrop-filter: blur(8px);
            transition: all 0.25s ease;

            &:focus {
                outline: none;
                background-color: rgba(255, 255, 255, 0.15);
                border-color: #00d285;
                box-shadow: 0 0 12px rgba(0, 210, 133, 0.25);
            }

            &::placeholder {
                color: #8e9aab;
            }

            @media (max-width: 768px) and (pointer: coarse) {
                font-size: 16px;
            }
        }

        .search-clear-btn {
            position: absolute;
            right: 15px;
            background: none;
            border: none;
            color: #8e9aab;
            font-size: 1.2rem;
            cursor: pointer;
            padding: 0;
            line-height: 1;
            z-index: 2;
            text-align: center;

            &:hover {
                color: #fff;
            }
        }
    }

    .global-search-results-dropdown {
        position: absolute;
        top: calc(100% + 8px);
        left: 0;
        right: 0;
        max-height: 480px;
        overflow-y: auto;
        background: #192231;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 12px;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
        z-index: 1050;
        padding: 10px;

        @media (max-width: 576px) {
            position: absolute;
            max-height: 350px;
        }

        &::-webkit-scrollbar {
            width: 6px;
        }

        &::-webkit-scrollbar-thumb {
            background-color: rgba(255, 255, 255, 0.2);
            border-radius: 10px;
        }

        .search-loader {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 24px;
            color: #a0aec0;
            font-size: 0.85rem;

            .loader-icon {
                width: 36px;
                height: 36px;
                margin-bottom: 8px;
                fill: currentColor;
                animation: global-search-loader-spin 1.2s linear infinite;
            }
        }

        .search-empty-state {
            padding: 20px;
            text-align: center;
            color: #a0aec0;
            font-size: 0.88rem;
        }

        .cards-list {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .player-card {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 10px 12px;
            background: rgba(255, 255, 255, 0.03);
            border: 1px solid rgba(255, 255, 255, 0.06);
            border-radius: 8px;
            transition: transform 0.15s ease, background-color 0.15s ease;
            cursor: pointer;

            &:hover {
                background: rgba(255, 255, 255, 0.07);
                transform: translateY(-1px);
            }

            .player-main-info {
                display: flex;
                align-items: center;
                gap: 10px;
                flex: 1;
                min-width: 0;

                .player-details {
                    min-width: 0;

                    .player-name {
                        font-size: 0.92rem;
                        font-weight: 600;
                        color: #f8fafc;
                        margin-bottom: 2px;
                        white-space: nowrap;
                        overflow: hidden;
                        text-overflow: ellipsis;
                    }

                    .player-meta {
                        font-size: 0.75rem;
                        color: #94a3b8;
                        /* Nuovo stile testuale per il ruolo */
                        .player-role-text {
                            font-weight: 700;
                            font-size: 0.72rem;
                            letter-spacing: 0.5px;

                            &.role-text-p {
                                color: #f59e0b;
                            }

                            &.role-text-d {
                                color: #3b82f6;
                            }

                            &.role-text-c {
                                color: #10b981;
                            }

                            &.role-text-a {
                                color: #ef4444;
                            }

                            &.role-text-u {
                                color: #cbd5e1;
                            }
                        }
                    }
                }
            }

            .player-side-info {
                display: flex;
                flex-direction: column;
                align-items: flex-end;
                gap: 4px;
                flex-shrink: 0;
                margin-left: 10px;

                .player-financials {
                    font-size: 0.75rem;
                    color: #cbd5e1;
                    white-space: nowrap;

                    .valore {
                        font-weight: 600;
                        color: #38bdf8;
                    }
                }

                .status-badge {
                    display: inline-flex;
                    align-items: center;
                    gap: 5px;
                    font-size: 0.72rem;
                    padding: 2px 8px;
                    border-radius: 12px;
                    white-space: nowrap;

                    &.free {
                        background: rgba(16, 185, 129, 0.15);
                        color: #34d399;
                        border: 1px solid rgba(16, 185, 129, 0.3);
                    }

                    &.assigned {
                        background: rgba(59, 130, 246, 0.15);
                        color: #93c5fd;
                        border: 1px solid rgba(59, 130, 246, 0.3);

                        .team-logo-thumb {
                            width: 14px;
                            height: 14px;
                            object-fit: contain;
                        }
                    }
                }
            }
        }
    }
}

@keyframes global-search-loader-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .global-search-results-dropdown .search-loader .loader-icon {
        animation: none;
    }
}
