/**
 * GarasiKami Search Component Styles
 * Modern, professional, responsive
 *
 * @version 2.0.0
 */

/* Base Component */
.gk-search {
    --gk-search-height: 48px;
    --gk-search-radius: 24px;
    --gk-search-bg: #f8f9fa;
    --gk-search-border: #e9ecef;
    --gk-search-text: #1a1a2e;
    --gk-search-placeholder: #6c757d;
    --gk-search-focus: #0d6efd;
    --gk-search-button-bg: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
    --gk-search-button-hover: linear-gradient(135deg, #0a58ca 0%, #084298 100%);
    --gk-search-shadow: 0 4px 15px rgba(13, 110, 253, 0.15);
    --gk-search-dropdown-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);

    position: relative;
    width: 100%;
}

.gk-search--desktop {
    max-width: 550px;
}

.gk-search--mobile {
    display: none;
}

/* Form Reset */
.gk-search__form {
    margin: 0;
    padding: 0;
}

/* Search Wrapper */
.gk-search__wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

/* Search Icon */
.gk-search__icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gk-search-placeholder);
    pointer-events: none;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Input Field */
.gk-search__input {
    width: 100%;
    height: var(--gk-search-height);
    padding: 0 120px 0 48px;
    border: 2px solid var(--gk-search-border);
    border-radius: var(--gk-search-radius);
    background: var(--gk-search-bg);
    color: var(--gk-search-text);
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.gk-search__input::placeholder {
    color: var(--gk-search-placeholder);
    opacity: 1;
}

/* Remove browser autofill styling */
.gk-search__input:-webkit-autofill,
.gk-search__input:-webkit-autofill:hover,
.gk-search__input:-webkit-autofill:focus,
.gk-search__input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px var(--gk-search-bg) inset !important;
    -webkit-text-fill-color: var(--gk-search-text) !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* Remove search cancel button */
.gk-search__input::-webkit-search-cancel-button,
.gk-search__input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

.gk-search__input:focus {
    border-color: var(--gk-search-focus);
    background: #fff;
    box-shadow: var(--gk-search-shadow);
}

/* Search Button */
.gk-search__button {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    height: 38px;
    padding: 0 20px;
    background: var(--gk-search-button-bg);
    color: #fff;
    border: none;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    outline: none;
}

.gk-search__button:hover {
    background: var(--gk-search-button-hover);
}

.gk-search__button:focus {
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.25);
}

.gk-search__button-text {
    display: inline;
}

.gk-search__button-icon {
    flex-shrink: 0;
}

/* Results Dropdown */
.gk-search__results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--gk-search-dropdown-shadow);
    border: 1px solid var(--gk-search-border);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    overscroll-behavior: contain;
}

.gk-search__results[hidden] {
    display: none;
}

/* Results List */
.gk-search__results-list {
    padding: 8px;
}

/* Result Item */
.gk-search__result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--gk-search-text);
    transition: background 0.15s ease;
}

.gk-search__result-item:hover,
.gk-search__result-item--active {
    background: #f8f9fa;
    text-decoration: none;
}

.gk-search__result-image {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
    background: #e9ecef;
    flex-shrink: 0;
}

.gk-search__result-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.gk-search__result-title {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gk-search__result-brand {
    font-size: 0.8rem;
    color: var(--gk-search-placeholder);
}

.gk-search__result-price {
    font-weight: 700;
    font-size: 0.85rem;
    color: #28a745;
    flex-shrink: 0;
}

/* Loading State */
.gk-search__loading {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--gk-search-placeholder);
}

.gk-search__loading[hidden] {
    display: none;
}

.gk-search__spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--gk-search-border);
    border-top-color: var(--gk-search-focus);
    border-radius: 50%;
    animation: gk-spin 0.8s linear infinite;
}

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

/* Empty State */
.gk-search__no-results {
    padding: 30px 20px;
    text-align: center;
    color: var(--gk-search-placeholder);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.gk-search__no-results[hidden] {
    display: none;
}

.gk-search__no-results svg {
    opacity: 0.5;
}

/* Dark Mode */
[data-theme="dark"] .gk-search {
    --gk-search-bg: #16213e;
    --gk-search-border: #2d2d44;
    --gk-search-text: #fff;
    --gk-search-placeholder: #adb5bd;
}

[data-theme="dark"] .gk-search__results {
    background: #1a1a2e;
    border-color: #2d2d44;
}

[data-theme="dark"] .gk-search__result-item:hover,
[data-theme="dark"] .gk-search__result-item--active {
    background: #16213e;
}

[data-theme="dark"] .gk-search__input:-webkit-autofill,
[data-theme="dark"] .gk-search__input:-webkit-autofill:hover,
[data-theme="dark"] .gk-search__input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 30px #16213e inset !important;
    -webkit-text-fill-color: #fff !important;
}

/* Mobile Responsive */
@media (max-width: 991px) {
    .gk-search--desktop {
        display: none;
    }

    .gk-search--mobile {
        display: block;
        margin-top: 12px;
    }

    .gk-search {
        --gk-search-height: 44px;
    }

    .gk-search__input {
        padding-right: 55px;
        font-size: 0.9rem;
    }

    .gk-search__button {
        padding: 0 14px;
    }

    .gk-search__button-text {
        display: none;
    }

    .gk-search__results {
        max-height: 60vh;
    }
}

@media (max-width: 575px) {
    .gk-search {
        --gk-search-height: 42px;
        --gk-search-radius: 21px;
    }

    .gk-search__icon {
        left: 14px;
    }

    .gk-search__input {
        padding-left: 42px;
        padding-right: 50px;
    }

    .gk-search__button {
        padding: 0 12px;
        height: 34px;
    }

    .gk-search__result-image {
        width: 40px;
        height: 40px;
    }
}
