/**
 * Netflix-Style Search - Royal Pharmacy Theme
 * Version: 1.0
 */

/* ============================================
   SEARCH ICON & CONTAINER
   ============================================ */

.royal-search-container {
    position: relative;
    display: flex;
    align-items: center;
    margin-right: auto;
    /* Changed from margin-left to position on left */
    margin-left: 0;
    order: -1;
    /* Ensure it appears first (leftmost in RTL) */
}

.search-icon-btn {
    background: none;
    border: none;
    color: var(--gold-main);
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(12px);
    /* Lowered further as requested */
}

.search-icon-btn:hover {
    color: #fff;
    transform: scale(1.1);
}

/* ============================================
   EXPANDABLE SEARCH BAR
   ============================================ */

.royal-search-form {
    position: absolute;
    left: 0;
    /* Changed from right to left */
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    opacity: 0;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.royal-search-form.active {
    width: 400px;
    opacity: 1;
    pointer-events: all;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(5, 5, 5, 0.95);
    border: 2px solid var(--gold-main);
    border-radius: 4px;
    padding: 0;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(212, 175, 55, 0.2);
}

.royal-search-input {
    width: 100%;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 16px;
    padding: 12px 45px 12px 15px;
    font-family: 'Cairo', sans-serif;
    outline: none;
}

.royal-search-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.search-submit-btn {
    position: absolute;
    right: 5px;
    background: none;
    border: none;
    color: var(--gold-main);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    transition: all 0.3s ease;
}

.search-submit-btn:hover {
    color: #fff;
    transform: scale(1.1);
}

.search-close-btn {
    position: absolute;
    left: -35px;
    /* Changed from right to left */
    background: none;
    border: none;
    color: var(--gold-main);
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    transition: all 0.3s ease;
    opacity: 0;
}

.royal-search-form.active .search-close-btn {
    opacity: 1;
}

.search-close-btn:hover {
    color: #fff;
    transform: rotate(90deg);
}

/* ============================================
   FOCUS EFFECTS
   ============================================ */

.royal-search-input:focus {
    outline: none;
}

.search-input-wrapper:focus-within {
    border-color: #fff;
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.4);
}

/* ============================================
   LOADING STATE
   ============================================ */

.search-loading {
    position: absolute;
    right: 45px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border: 2px solid rgba(212, 175, 55, 0.3);
    border-top-color: var(--gold-main);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: none;
}

.royal-search-form.loading .search-loading {
    display: block;
}

.royal-search-form.loading .search-submit-btn {
    opacity: 0;
}

@keyframes spin {
    to {
        transform: translateY(-50%) rotate(360deg);
    }
}

/* ============================================
   LIVE RESULTS DROPDOWN
   ============================================ */

.search-results-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    /* Changed from right to left */
    width: 500px;
    max-height: 500px;
    overflow-y: auto;
    background: rgba(5, 5, 5, 0.98);
    border: 2px solid var(--gold-main);
    border-radius: 8px;
    backdrop-filter: blur(15px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: 9999;
}

.search-results-dropdown.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

.search-results-header {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
    color: var(--gold-main);
    font-weight: bold;
    font-size: 14px;
}

.search-result-category {
    padding: 10px 20px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.search-result-item {
    padding: 12px 20px;
    color: #fff;
    text-decoration: none;
    display: block;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.search-result-item:hover {
    background: rgba(212, 175, 55, 0.1);
    border-left-color: var(--gold-main);
    padding-left: 25px;
}

.search-result-title {
    font-size: 15px;
    margin-bottom: 5px;
    color: #fff;
}

.search-result-excerpt {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.4;
}

.search-result-type {
    display: inline-block;
    padding: 2px 8px;
    background: var(--gold-main);
    color: #000;
    font-size: 10px;
    border-radius: 3px;
    margin-left: 8px;
    font-weight: bold;
}

.search-no-results {
    padding: 40px 20px;
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
}

.search-view-all {
    padding: 15px 20px;
    text-align: center;
    border-top: 1px solid rgba(212, 175, 55, 0.2);
}

.search-view-all a {
    color: var(--gold-main);
    text-decoration: none;
    font-weight: bold;
    transition: all 0.3s ease;
}

.search-view-all a:hover {
    color: #fff;
}

/* ============================================
   HIGHLIGHT MATCHED TEXT
   ============================================ */

.search-highlight {
    background: var(--gold-main);
    color: #000;
    padding: 2px 4px;
    border-radius: 2px;
    font-weight: bold;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .royal-search-form.active {
        width: 280px;
    }

    .search-results-dropdown {
        width: 100vw;
        right: -20px;
        max-width: 400px;
    }

    .search-close-btn {
        right: -30px;
    }
}

@media (max-width: 480px) {
    .royal-search-container {
        margin-left: 10px;
    }

    .royal-search-form.active {
        width: 220px;
    }

    .royal-search-input {
        font-size: 14px;
        padding: 10px 40px 10px 12px;
    }
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */

.search-results-dropdown::-webkit-scrollbar {
    width: 8px;
}

.search-results-dropdown::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.search-results-dropdown::-webkit-scrollbar-thumb {
    background: var(--gold-main);
    border-radius: 4px;
}

.search-results-dropdown::-webkit-scrollbar-thumb:hover {
    background: #fff;
}