/**
 * Advanced Search System - Mantos Alvinegros
 * Modern, visual, intuitive search experience
 */

/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
    --search-overlay-bg: rgba(0, 0, 0, 0.85);
    --search-modal-bg: rgba(255, 255, 255, 0.95);
    --search-accent: #1a1a1a;
    --search-accent-light: rgba(0, 0, 0, 0.08);
    --search-accent-hover: #333333;
    --search-border-radius: 24px;
    --search-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   SEARCH TRIGGER BUTTON (Updated Style)
   ============================================ */
.search-container {
    position: relative;
    cursor: pointer;
    transition: var(--search-transition);
}

.search-container:hover {
    transform: scale(1.02);
}

.search-container .search-shortcut {
    display: none;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    font-size: 0.7rem;
    color: #999;
    background: rgba(0, 0, 0, 0.08);
    padding: 2px 8px;
    border-radius: 6px;
    font-family: var(--font-body);
}

@media (min-width: 768px) {
    .search-container .search-shortcut {
        display: flex;
    }
}

/* ============================================
   SEARCH OVERLAY (Full Screen)
   ============================================ */
.search-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--search-overlay-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 10vh 5vw;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.search-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   SEARCH MODAL
   ============================================ */
.search-modal {
    width: 100%;
    max-width: 700px;
    background: var(--search-modal-bg);
    border-radius: var(--search-border-radius);
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    overflow: hidden;
    transform: translateY(-30px) scale(0.95);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.search-overlay.active .search-modal {
    transform: translateY(0) scale(1);
}

/* ============================================
   SEARCH INPUT AREA
   ============================================ */
.search-input-wrapper {
    display: flex;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    gap: 1rem;
}

.search-input-icon {
    width: 28px;
    height: 28px;
    color: var(--search-accent);
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.search-input-wrapper:focus-within .search-input-icon {
    transform: scale(1.1);
}

#global-search-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 1.3rem;
    font-family: var(--font-body);
    font-weight: 500;
    color: #1a1a1a;
}

#global-search-input::placeholder {
    color: #aaa;
    font-weight: 400;
}

.search-close-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--search-transition);
    flex-shrink: 0;
}

.search-close-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: rotate(90deg);
}

.search-close-btn svg {
    width: 18px;
    height: 18px;
    color: #666;
}

/* ============================================
   SEARCH QUICK ACTIONS (Tags)
   ============================================ */
.search-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1rem 2rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.search-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.4rem 0.9rem;
    background: linear-gradient(135deg,
            rgba(0, 0, 0, 0.06) 0%,
            rgba(0, 0, 0, 0.03) 100%);
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 20px;
    font-size: 0.8rem;
    font-family: var(--font-body);
    color: #444;
    cursor: pointer;
    transition: var(--search-transition);
}

.search-tag:hover {
    background: var(--search-accent);
    color: #fff;
    border-color: var(--search-accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.search-tag svg {
    width: 14px;
    height: 14px;
}

/* ============================================
   SEARCH RESULTS AREA
   ============================================ */
.search-results-container {
    max-height: 50vh;
    overflow-y: auto;
    padding: 1rem 0;
}

.search-results-container::-webkit-scrollbar {
    width: 6px;
}

.search-results-container::-webkit-scrollbar-track {
    background: transparent;
}

.search-results-container::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 10px;
}

/* Section Headers */
.search-results-section {
    padding: 0.5rem 2rem;
}

.search-results-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #999;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-results-section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.1) 0%, transparent 100%);
}

/* Result Items */
.search-result-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 2rem;
    cursor: pointer;
    transition: var(--search-transition);
    text-decoration: none;
    color: inherit;
}

.search-result-item:hover,
.search-result-item.selected {
    background: linear-gradient(90deg,
            rgba(0, 0, 0, 0.06) 0%,
            rgba(0, 0, 0, 0.02) 100%);
}

.search-result-item:hover .result-preview,
.search-result-item.selected .result-preview {
    transform: scale(1.1);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

/* Result Preview Image */
.result-preview {
    width: 56px;
    height: 70px;
    border-radius: 12px;
    overflow: hidden;
    flex-shrink: 0;
    background: linear-gradient(135deg, #e8e8e8 0%, #d0d0d0 100%);
    transition: var(--search-transition);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.result-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Result Info */
.result-info {
    flex: 1;
    min-width: 0;
}

.result-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.result-title .highlight {
    background: linear-gradient(135deg,
            rgba(0, 0, 0, 0.12) 0%,
            rgba(0, 0, 0, 0.06) 100%);
    padding: 0 4px;
    border-radius: 4px;
    font-weight: 700;
    color: #000;
}

.result-type-badge {
    font-size: 0.65rem;
    padding: 2px 8px;
    background: #f0f0f0;
    border-radius: 6px;
    color: #666;
    font-weight: 500;
    text-transform: uppercase;
}

.result-subtitle {
    font-size: 0.85rem;
    color: #777;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Result Arrow */
.result-arrow {
    width: 24px;
    height: 24px;
    color: #ccc;
    transition: var(--search-transition);
    flex-shrink: 0;
}

.search-result-item:hover .result-arrow,
.search-result-item.selected .result-arrow {
    color: var(--search-accent);
    transform: translateX(4px);
}

/* ============================================
   EMPTY & LOADING STATES
   ============================================ */
.search-empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: #888;
}

.search-empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.search-empty-state h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 0.5rem;
}

.search-empty-state p {
    font-size: 0.9rem;
    max-width: 300px;
    margin: 0 auto;
}

.search-loading {
    display: flex;
    justify-content: center;
    padding: 2rem;
}

.search-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--search-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   RECENT SEARCHES
   ============================================ */
.recent-search-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 2rem;
    cursor: pointer;
    transition: var(--search-transition);
}

.recent-search-item:hover {
    background: rgba(0, 0, 0, 0.03);
}

.recent-icon {
    width: 20px;
    height: 20px;
    color: #aaa;
}

.recent-text {
    flex: 1;
    font-size: 0.95rem;
    color: #555;
}

.recent-remove {
    width: 20px;
    height: 20px;
    color: #ccc;
    cursor: pointer;
    opacity: 0;
    transition: var(--search-transition);
}

.recent-search-item:hover .recent-remove {
    opacity: 1;
}

.recent-remove:hover {
    color: #e74c3c;
}

/* ============================================
   FOOTER (Keyboard Hints)
   ============================================ */
.search-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 2rem;
    background: rgba(0, 0, 0, 0.02);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.search-hints {
    display: flex;
    gap: 1.5rem;
}

.search-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: #888;
}

.search-hint kbd {
    padding: 3px 8px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 0.7rem;
    font-weight: 600;
    color: #555;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.search-powered {
    font-size: 0.7rem;
    color: #aaa;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .search-overlay {
        padding: 0;
        align-items: stretch;
    }

    .search-modal {
        max-width: none;
        border-radius: 0;
        height: 100%;
        display: flex;
        flex-direction: column;
    }

    .search-input-wrapper {
        padding: 1rem 1.25rem;
    }

    #global-search-input {
        font-size: 1.1rem;
    }

    .search-quick-actions {
        padding: 0.75rem 1.25rem;
    }

    .search-results-container {
        flex: 1;
        max-height: none;
    }

    .search-result-item {
        padding: 0.75rem 1.25rem;
    }

    .search-results-section {
        padding: 0.5rem 1.25rem;
    }

    .search-footer {
        padding: 0.5rem 1.25rem;
    }

    .search-hints {
        display: none;
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes resultFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-result-item {
    animation: resultFadeIn 0.3s ease forwards;
}

.search-result-item:nth-child(1) {
    animation-delay: 0.05s;
}

.search-result-item:nth-child(2) {
    animation-delay: 0.1s;
}

.search-result-item:nth-child(3) {
    animation-delay: 0.15s;
}

.search-result-item:nth-child(4) {
    animation-delay: 0.2s;
}

.search-result-item:nth-child(5) {
    animation-delay: 0.25s;
}