/* Premium Vocabulary Search - Quick Jump System */

/* Search Container */
.vocab-search-container {
    position: relative;
    display: flex;
    align-items: center;
    z-index: 1;
}

/* Search Input */
.vocab-search-input {
    width: 260px;
    padding: 10px 40px 10px 38px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.95);
    color: var(--text-primary);
    font-size: 0.95em;
    font-weight: 500;
    font-family: 'Inter', -apple-system, sans-serif;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.vocab-search-input::placeholder {
    color: rgba(0, 0, 0, 0.4);
    font-weight: 400;
}

.vocab-search-input:focus {
    outline: none;
    width: 320px;
    border-color: var(--category-primary, #667eea);
    box-shadow:
        0 0 0 3px rgba(102, 126, 234, 0.1),
        0 4px 16px rgba(102, 126, 234, 0.2);
    background: rgba(255, 255, 255, 1);
}

/* Search Icon */
.vocab-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1em;
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.vocab-search-input:focus + .vocab-search-icon {
    opacity: 0.8;
    color: var(--category-primary, #667eea);
}

/* Clear Button */
.vocab-search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.15);
    border: none;
    color: #4a5568;
    font-size: 0.85em;
    font-weight: 700;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10;
    opacity: 0;
}

.vocab-search-clear:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
    transform: translateY(-50%) scale(1.15) rotate(90deg);
}

.vocab-search-clear:active {
    transform: translateY(-50%) scale(0.9);
}

/* Show clear button when input has text */
.vocab-sidebar .vocab-search-input:not(:placeholder-shown) ~ .vocab-search-clear {
    display: flex;
    opacity: 1;
}

/* Search Results Dropdown */
.vocab-search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    max-height: 420px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(24px) saturate(140%);
    -webkit-backdrop-filter: blur(24px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.2),
        0 4px 12px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
    z-index: 10005;
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.vocab-search-results.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Washi paper texture */
.vocab-search-results::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255, 255, 255, 0.03) 2px, rgba(255, 255, 255, 0.03) 4px),
        repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(255, 255, 255, 0.03) 2px, rgba(255, 255, 255, 0.03) 4px),
        repeating-linear-gradient(45deg, transparent, transparent 3px, rgba(0, 0, 0, 0.01) 3px, rgba(0, 0, 0, 0.01) 6px);
    opacity: 0.4;
    mix-blend-mode: overlay;
    pointer-events: none;
    border-radius: inherit;
    z-index: 1;
}

/* Category tint overlay */
.vocab-search-results::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg,
        var(--category-primary, #667eea) 0%,
        var(--category-secondary, #764ba2) 100%);
    opacity: 0.06;
    border-radius: inherit;
    pointer-events: none;
    z-index: 0;
}

/* Results list */
.vocab-search-list {
    position: relative;
    z-index: 2;
    padding: 8px;
}

/* Individual result item */
.vocab-search-result {
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0;
    animation: resultFadeIn 0.3s ease forwards;
}

@keyframes resultFadeIn {
    from {
        opacity: 0;
        transform: translateX(-8px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Staggered animation delay */
.vocab-search-result:nth-child(1) { animation-delay: 0ms; }
.vocab-search-result:nth-child(2) { animation-delay: 50ms; }
.vocab-search-result:nth-child(3) { animation-delay: 100ms; }
.vocab-search-result:nth-child(4) { animation-delay: 150ms; }
.vocab-search-result:nth-child(5) { animation-delay: 200ms; }
.vocab-search-result:nth-child(n+6) { animation-delay: 250ms; }

.vocab-search-result:hover,
.vocab-search-result.selected {
    background: rgba(255, 255, 255, 0.85);
    border-color: var(--category-primary, #667eea);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25);
    transform: translateX(4px);
}

.vocab-search-result:active {
    transform: scale(0.98) translateX(4px);
}

/* Result content */
.result-main {
    flex: 1;
    min-width: 0;
}

.result-japanese {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 1.3em;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 4px;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

/* Highlight matched characters */
.result-japanese mark,
.result-romanization mark,
.result-english mark {
    background: linear-gradient(135deg,
        rgba(102, 126, 234, 0.3) 0%,
        rgba(118, 75, 162, 0.3) 100%);
    color: inherit;
    border-radius: 4px;
    padding: 0 2px;
    font-weight: 700;
}

.result-details {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.9em;
    color: #4a5568;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.result-romanization {
    font-style: italic;
    color: var(--category-primary, #667eea);
    font-weight: 500;
}

.result-separator {
    opacity: 0.4;
}

.result-english {
    color: #2d3748;
}

/* Result metadata */
.result-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.result-badge {
    padding: 3px 10px;
    background: linear-gradient(135deg,
        rgba(102, 126, 234, 0.12) 0%,
        rgba(118, 75, 162, 0.12) 100%);
    border: 1px solid rgba(102, 126, 234, 0.25);
    border-radius: 10px;
    font-size: 0.75em;
    font-weight: 600;
    color: #4a5568;
    text-transform: lowercase;
    white-space: nowrap;
}

.result-category {
    padding: 3px 10px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    font-size: 0.7em;
    font-weight: 500;
    color: #718096;
    white-space: nowrap;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Progress dots */
.result-progress {
    display: flex;
    gap: 4px;
}

.progress-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.2);
}

.progress-dot.known {
    background: #16a34a;
    box-shadow: 0 0 4px rgba(22, 163, 74, 0.4);
}

.progress-dot.learning {
    background: #ea580c;
    box-shadow: 0 0 4px rgba(234, 88, 12, 0.4);
}

/* Empty state */
.vocab-search-empty {
    padding: 40px 20px;
    text-align: center;
    position: relative;
    z-index: 2;
}

.vocab-search-empty-icon {
    font-size: 3em;
    margin-bottom: 12px;
    opacity: 0.4;
}

.vocab-search-empty-text {
    font-family: 'Inter', sans-serif;
    font-size: 0.95em;
    color: #718096;
    line-height: 1.5;
}

/* Loading state */
.vocab-search-loading {
    padding: 30px 20px;
    text-align: center;
    position: relative;
    z-index: 2;
}

.vocab-search-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(102, 126, 234, 0.2);
    border-top-color: var(--category-primary, #667eea);
    border-radius: 50%;
    animation: searchSpin 0.8s linear infinite;
    margin: 0 auto 12px;
}

@keyframes searchSpin {
    to { transform: rotate(360deg); }
}

/* Keyboard hint */
.vocab-search-hint {
    position: absolute;
    right: 50px;
    top: 50%;
    transform: translateY(-50%);
    font-family: 'Inter', sans-serif;
    font-size: 0.75em;
    color: rgba(0, 0, 0, 0.4);
    background: rgba(0, 0, 0, 0.05);
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.vocab-search-input:focus ~ .vocab-search-hint {
    opacity: 0;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .vocab-search-input {
        width: 200px;
        font-size: 16px; /* Prevent iOS zoom */
    }

    .vocab-search-input:focus {
        width: 240px;
    }

    .vocab-search-results {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 24px 24px 0 0;
        max-height: 60vh;
    }

    .result-japanese {
        font-size: 1.2em;
    }

    .result-details {
        font-size: 0.85em;
    }

    .vocab-search-hint {
        display: none;
    }
}

/* Focus mode specific */
body.focus-mode .vocab-search-container {
    display: none;
}

/* Video mode specific */
body.video-mode .vocab-search-container {
    display: none;
}

/* Scrollbar styling */
.vocab-search-results::-webkit-scrollbar {
    width: 8px;
}

.vocab-search-results::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
}

.vocab-search-results::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 8px;
}

.vocab-search-results::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.5);
}
