/* ==========================================================================
   Vyhľadávanie + našepkávač (varianty: hero, compact)
   Stav riadi atribút data-state na <form>: idle | loading | results | empty | error
   ========================================================================== */

.search {
    position: relative;
    z-index: 5;
    width: 100%;
    text-align: left;
}

/* Rámik 1.5px s prechodom */
.search__frame {
    position: relative;
    padding: 1.5px;
    border-radius: var(--radius-xl);
    background: linear-gradient(100deg, rgba(79, 123, 255, 0.55), rgba(255, 255, 255, 0.18) 50%, rgba(255, 79, 192, 0.45));
    box-shadow: var(--shadow-search-rest);
    transition: box-shadow 0.35s ease;
}

.search:focus-within .search__frame {
    background: var(--gradient-brand);
    box-shadow: var(--shadow-search-focus);
}

.search.is-pulsing .search__frame {
    box-shadow: var(--shadow-search-pulse);
}

.search__field {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 68px;
    padding: 7px 7px 7px 22px;
    overflow: hidden;
    border-radius: 18.5px;
    background: var(--color-bg-field);
}

.search__icon {
    flex: none;
    width: 20px;
    height: 20px;
    color: var(--color-accent-soft-2);
}

.search__input {
    flex: 1;
    min-width: 0;
    padding: 0;
    border: 0;
    outline: none;
    background: transparent;
    color: #fff;
    font-size: clamp(16px, 1.55vw, 20px);
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: -0.015em;
    caret-color: var(--color-pink);
}

.search__input::-webkit-search-cancel-button {
    display: none;
}

.search__clear {
    flex: none;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--color-glass-2);
    color: var(--color-text-on-dark-nav);
    font-size: 18px;
    line-height: 1;
}

.search__clear:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

.search__submit {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    gap: 11px;
    min-width: 54px;
    min-height: 54px;
    padding: 0;
    border: 0;
    border-radius: 13px;
    background: var(--gradient-brand);
    background-size: 180% 100%;
    background-position: 0% 50%;
    box-shadow: 0 10px 30px -10px rgba(124, 77, 255, 0.8);
    color: #fff;
    font-size: 14.5px;
    font-weight: 600;
    transition: background-position 0.45s ease, box-shadow var(--duration-base);
}

.search__submit:hover {
    background-position: 100% 50%;
}

.search__submit:active {
    transform: translateY(1px);
}

.search:focus-within .search__submit {
    box-shadow: 0 0 0 6px rgba(124, 77, 255, 0.22), 0 14px 40px -8px rgba(160, 80, 240, 0.9);
}

.search__submit-text {
    display: none;
}

.search__submit-icon {
    width: 20px;
    height: 20px;
}

.search__spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: search-spin 0.9s linear infinite;
}

.search[data-state='loading'] .search__spinner {
    display: block;
}

.search[data-state='loading'] .search__submit-icon {
    display: none;
}

/* Ružový pás po spodnom okraji počas načítania */
.search__progress {
    position: absolute;
    bottom: 0;
    left: 0;
    display: none;
    width: 25%;
    height: 2px;
    background: var(--color-pink);
    animation: search-progress 1s linear infinite;
}

.search[data-state='loading'] .search__progress {
    display: block;
}

@media (min-width: 720px) {
    .search__submit {
        padding: 0 22px;
    }

    .search__submit-text {
        display: inline;
    }
}

/* --------------------------------------------------------------------------
   Panel našepkávača
   -------------------------------------------------------------------------- */

.search__panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: 0;
    overflow: hidden;
    border-radius: var(--radius-md);
    background: var(--color-bg-listbox);
    box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(107, 77, 255, 0.12);
    color: #fff;
    text-align: left;
}

.search__state {
    display: none;
}

.search[data-state='loading'] .search__state--loading,
.search[data-state='results'] .search__state--results,
.search[data-state='empty'] .search__state--empty,
.search[data-state='error'] .search__state--error {
    display: block;
}

.search__panel-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px 8px;
    color: var(--color-placeholder);
    font-family: var(--font-mono);
    font-size: 12.5px;
    font-weight: 500;
}

/* Skeleton riadky */
.search__skeleton {
    display: flex;
    flex-direction: column;
    gap: 9px;
    padding: 14px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.search__skeleton::before,
.search__skeleton::after {
    content: '';
    height: 12px;
    border-radius: 3px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.06), rgba(143, 123, 255, 0.22), rgba(255, 255, 255, 0.06));
    background-size: 200% 100%;
    animation: search-shimmer 1.4s ease-in-out infinite;
}

.search__skeleton::after {
    height: 9px;
    background: rgba(255, 255, 255, 0.06);
    animation: none;
}

.search__skeleton:nth-child(2)::before { width: 58%; }
.search__skeleton:nth-child(2)::after { width: 38%; }
.search__skeleton:nth-child(3)::before { width: 44%; }
.search__skeleton:nth-child(3)::after { width: 52%; }
.search__skeleton:nth-child(4)::before { width: 66%; }
.search__skeleton:nth-child(4)::after { width: 30%; }

/* Výsledky */
.search__listbox {
    margin: 0;
    padding: 0;
    list-style: none;
}

.search__option {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 13px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    cursor: pointer;
}

.search__option[aria-selected='true'] {
    background: rgba(107, 77, 255, 0.18);
    box-shadow: inset 2px 0 0 var(--color-violet-soft);
}

.search__option-dot {
    flex: none;
    width: 14px;
    height: 14px;
    border: 1.4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0 2px, transparent 2.5px);
}

.search__option[aria-selected='true'] .search__option-dot {
    border-color: var(--color-pink-alt);
    background: radial-gradient(circle, var(--color-pink-alt) 0 2px, transparent 2.5px);
}

.search__option-body {
    flex: 1;
    min-width: 0;
}

.search__option-name,
.search__option-addr {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search__option-name {
    font-size: 16.5px;
    font-weight: 500;
}

.search__option-name mark {
    background: transparent;
    color: var(--color-accent-soft);
    box-shadow: inset 0 -2px 0 var(--color-violet-soft);
}

.search__option-addr {
    margin-top: 3px;
    color: var(--color-text-on-dark-muted-2);
    font-size: var(--fs-caption);
}

.search__option-cin {
    flex: none;
    color: #dcd6ff;
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.search__panel-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
    color: var(--color-placeholder);
    font-size: 13px;
}

.search__panel-link {
    color: var(--color-accent-soft);
    font-weight: 500;
}

.search__panel-link:hover {
    color: #fff;
}

/* Prázdny stav a chyba */
.search__message {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    padding: 26px 22px;
}

.search__message-icon {
    flex: none;
    width: 36px;
    height: 36px;
}

.search__message-title {
    font-size: 17px;
    font-weight: 600;
}

.search__message-text {
    max-width: 460px;
    margin-top: 8px;
    color: #b7b5d6;
    font-size: var(--fs-small);
    line-height: 1.55;
}

.search__message-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 18px;
    margin-top: 16px;
}

.search__retry {
    padding: 10px 16px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 7px;
    background: transparent;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
}

.search__retry:hover {
    border-color: #fff;
    background: var(--color-glass-2);
}

@media (max-width: 719px) {
    .search__kbd-hint {
        display: none;
    }
}

/* --------------------------------------------------------------------------
   Variant compact – v navigácii detailu
   -------------------------------------------------------------------------- */

.search--compact .search__frame {
    padding: 0;
    border-radius: 11px;
    background: none;
    box-shadow: none;
}

.search--compact .search__field {
    gap: 10px;
    min-height: 40px;
    height: 40px;
    padding: 0 4px 0 14px;
    border-radius: 11px;
    background: var(--color-glass-2);
    transition: background 0.25s, box-shadow var(--duration-base);
}

.search--compact:focus-within .search__frame {
    background: none;
    box-shadow: none;
}

.search--compact:focus-within .search__field {
    background: var(--color-glass-4);
    box-shadow: 0 0 0 4px rgba(124, 77, 255, 0.35), 0 20px 60px -20px rgba(140, 70, 255, 0.8);
}

.search--compact .search__icon {
    width: 15px;
    height: 15px;
}

.search--compact .search__input {
    font-size: 13px;
    letter-spacing: 0;
}

.search--compact .search__input::placeholder {
    color: #8f8cb8;
}

.search--compact .search__clear {
    width: 28px;
    height: 28px;
    font-size: 15px;
}

.search--compact .search__submit,
.search--compact:focus-within .search__submit {
    min-width: 32px;
    min-height: 32px;
    padding: 0;
    border-radius: 8px;
    box-shadow: none;
}

.search--compact .search__submit-text {
    display: none;
}

.search--compact .search__submit-icon,
.search--compact .search__spinner {
    width: 14px;
    height: 14px;
}

.search--compact .search__panel {
    z-index: 20;
}

@keyframes search-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes search-progress {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(400%);
    }
}

@keyframes search-shimmer {
    from {
        background-position: 100% 0;
    }

    to {
        background-position: -100% 0;
    }
}
