/* ═══════════════════════════════════════════════════════════════════════════════
   Spotlight Search - Global "Search All" Modal
   Beautiful animated gradient border using mode colors
   ═══════════════════════════════════════════════════════════════════════════════ */

/* CSS Custom Property for animated gradient angle */
@property --spotlight-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Overlay / Backdrop
   ═══════════════════════════════════════════════════════════════════════════════ */

.spotlight-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.spotlight-overlay.open {
    opacity: 1;
    visibility: visible;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Container with Animated Gradient Border
   ═══════════════════════════════════════════════════════════════════════════════ */

.spotlight-container {
    --spotlight-angle: 0deg;
    position: relative;
    width: 100%;
    max-width: 64rem; /* max-w-5xl, matches detail modal */
    max-height: 92vh;
    border-radius: 1rem;
    
    /* Animated conic gradient as the "border" */
    background: conic-gradient(
        from var(--spotlight-angle),
        #3B82F6,  /* Kanji - Blue */
        #10B981,  /* Vocab - Green */
        #FACC15,  /* Grammar - Yellow */
        #EC4899,  /* Names - Pink */
        #2DD4BF,  /* Sentences - Teal */
        #C084FC,  /* Radicals - Purple */
        #3B82F6   /* Back to Blue for seamless loop */
    );
    padding: 2px;
    animation: spotlight-gradient-rotate 8s linear infinite;
    
    /* Entry animation */
    transform: scale(0.96) translateY(10px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.spotlight-overlay.open .spotlight-container {
    transform: scale(1) translateY(0);
    opacity: 1;
}

@keyframes spotlight-gradient-rotate {
    to {
        --spotlight-angle: 360deg;
    }
}

/* Fallback for browsers without @property support */
@supports not (background: conic-gradient(from 0deg, red, blue)) {
    .spotlight-container {
        background: linear-gradient(
            135deg,
            #3B82F6, #10B981, #FACC15, #EC4899, #2DD4BF, #C084FC
        );
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Inner Content Panel
   ═══════════════════════════════════════════════════════════════════════════════ */

.spotlight-inner {
    background: var(--color-bg-secondary, #1a1a1f);
    border-radius: calc(1rem - 2px);
    display: flex;
    flex-direction: column;
    max-height: calc(92vh - 4px);
    overflow: hidden;
}

/* Light theme */
.light .spotlight-inner {
    background: var(--color-bg-secondary, #ffffff);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Header / Search Input Area
   ═══════════════════════════════════════════════════════════════════════════════ */

.spotlight-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border, rgba(255, 255, 255, 0.1));
}

.spotlight-search-icon {
    flex-shrink: 0;
    width: 1.5rem;
    height: 1.5rem;
    color: var(--color-text-muted, #6b7280);
}

.spotlight-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--color-text-primary, #fff);
    caret-color: var(--color-accent, #3B82F6);
}

.spotlight-input::placeholder {
    color: var(--color-text-muted, #6b7280);
    font-weight: 400;
}

.spotlight-close-btn {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    background: transparent;
    border: none;
    color: var(--color-text-muted, #6b7280);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.spotlight-close-btn:hover {
    background: var(--color-bg-tertiary, rgba(255, 255, 255, 0.1));
    color: var(--color-text-primary, #fff);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Results Area
   ═══════════════════════════════════════════════════════════════════════════════ */

.spotlight-results {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    min-height: 200px;
    max-height: 60vh;
}

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

.spotlight-results::-webkit-scrollbar-track {
    background: transparent;
}

.spotlight-results::-webkit-scrollbar-thumb {
    background: var(--color-border, rgba(255, 255, 255, 0.15));
    border-radius: 4px;
}

.spotlight-results::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted, rgba(255, 255, 255, 0.25));
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Result Row
   ═══════════════════════════════════════════════════════════════════════════════ */

.spotlight-result {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.1s, border-color 0.1s;
}

.spotlight-result:hover {
    background: var(--color-bg-tertiary, rgba(255, 255, 255, 0.05));
}

.spotlight-result.selected {
    background: var(--color-bg-tertiary, rgba(255, 255, 255, 0.08));
    border-left-color: var(--result-mode-color, var(--color-accent));
}

/* Unactivated/catalog items (not yet added to study list) */
.spotlight-result-unactivated {
    opacity: 0.7;
}

.spotlight-result-unactivated:hover,
.spotlight-result-unactivated.selected {
    opacity: 1;
}

.spotlight-result-unactivated .spotlight-result-icon {
    opacity: 0.8;
}

/* Mode icon badge */
.spotlight-result-icon {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    font-size: 1rem;
    font-weight: 600;
    background: var(--result-mode-color, var(--color-accent));
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Display text (kanji/word) */
.spotlight-result-display {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text-primary, #fff);
    min-width: 3rem;
}

/* Separator */
.spotlight-result-sep {
    color: var(--color-text-muted, #6b7280);
    font-size: 0.875rem;
}

/* Meaning text */
.spotlight-result-meaning {
    flex: 1;
    font-size: 0.9375rem;
    color: var(--color-text-secondary, #9ca3af);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mode label */
.spotlight-result-mode {
    flex-shrink: 0;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: var(--result-mode-color, var(--color-accent));
    opacity: 0.8;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Empty / Initial State
   ═══════════════════════════════════════════════════════════════════════════════ */

.spotlight-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--color-text-muted, #6b7280);
}

.spotlight-empty-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    opacity: 0.7;
}

.spotlight-empty-icon svg {
    width: 100%;
    height: 100%;
}

/* Animated shine sweep on search icon lens */
.spotlight-empty-icon .search-shine {
    opacity: 0;
    animation: search-shine-sweep 3s ease-in-out infinite;
    animation-delay: 1s;
}

@keyframes search-shine-sweep {
    0%, 100% {
        transform: translateX(-20px) translateY(-20px);
        opacity: 0;
    }
    10% {
        opacity: 0.6;
    }
    50% {
        transform: translateX(20px) translateY(20px);
        opacity: 0;
    }
    51%, 99% {
        opacity: 0;
    }
}

.spotlight-empty-title {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--color-text-secondary, #9ca3af);
}

.spotlight-empty-subtitle {
    font-size: 0.875rem;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Footer / Keyboard Hints
   ═══════════════════════════════════════════════════════════════════════════════ */

.spotlight-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--color-border, rgba(255, 255, 255, 0.1));
    font-size: 0.75rem;
    color: var(--color-text-muted, #6b7280);
}

.spotlight-hint {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.spotlight-hint kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.375rem;
    font-size: 0.6875rem;
    font-family: inherit;
    font-weight: 500;
    background: var(--color-bg-tertiary, rgba(255, 255, 255, 0.1));
    border-radius: 0.25rem;
    border: 1px solid var(--color-border, rgba(255, 255, 255, 0.15));
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Search Bar Actions Wrapper (Clear + Pill)
   Contains the clear button and spotlight pill together
   ═══════════════════════════════════════════════════════════════════════════════ */

.search-actions-wrapper {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-clear-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.375rem;
    height: 1.375rem;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--color-text-muted, #6b7280);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s, color 0.15s, background 0.15s;
}

.search-clear-btn.visible {
    opacity: 1;
    visibility: visible;
}

.search-clear-btn:hover {
    color: var(--color-text-primary, #fff);
    background: var(--color-bg-tertiary, rgba(255, 255, 255, 0.1));
}

.search-clear-btn svg {
    width: 0.75rem;
    height: 0.75rem;
}

/* Light theme */
.light .search-clear-btn:hover {
    color: var(--color-text-primary, #111);
    background: var(--color-bg-tertiary, rgba(0, 0, 0, 0.08));
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Search Bar Hint Pill (in main search input)
   Animated gradient border matching the spotlight modal exactly
   ═══════════════════════════════════════════════════════════════════════════════ */

/* CSS Custom Property for pill gradient animation */
@property --pill-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

/* Outer wrapper - the gradient IS the background (like .spotlight-container) */
.spotlight-trigger-pill {
    --pill-angle: 0deg;
    position: relative;
    isolation: isolate; /* Contain z-index stacking context for ::before */
    display: flex;
    align-items: center;
    gap: 0.375rem;
    /* Padding includes 1px for border + content spacing */
    padding: calc(0.25rem + 1px) calc(0.625rem + 1px);
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--color-text-muted, #6b7280);
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    
    /* Animated conic gradient as the "border" - exactly like spotlight */
    background: conic-gradient(
        from var(--pill-angle),
        #3B82F6,  /* Kanji - Blue */
        #10B981,  /* Vocab - Green */
        #FACC15,  /* Grammar - Yellow */
        #EC4899,  /* Names - Pink */
        #2DD4BF,  /* Sentences - Teal */
        #C084FC,  /* Radicals - Purple */
        #3B82F6   /* Back to Blue for seamless loop */
    );
    animation: pill-gradient-rotate 6s linear infinite;
}

/* Inner solid background - exactly like .spotlight-inner */
.spotlight-trigger-pill::before {
    content: '';
    position: absolute;
    inset: 1px;
    background: #1a1a1f;
    border-radius: calc(0.375rem - 1px);
    z-index: -1;
    transition: background 0.15s;
}

@keyframes pill-gradient-rotate {
    to {
        --pill-angle: 360deg;
    }
}

/* Fallback for browsers without @property support */
@supports not (background: conic-gradient(from 0deg, red, blue)) {
    .spotlight-trigger-pill {
        background: linear-gradient(
            135deg,
            #3B82F6, #10B981, #FACC15, #EC4899, #2DD4BF, #C084FC
        );
    }
}

.spotlight-trigger-pill:hover {
    color: var(--color-text-secondary, #9ca3af);
}

.spotlight-trigger-pill:hover::before {
    background: #252529;
}

.spotlight-trigger-pill kbd {
    font-family: inherit;
    font-size: 0.625rem;
    font-weight: 600;
    padding: 0.125rem 0.25rem;
    background: var(--color-bg-primary, rgba(0, 0, 0, 0.3));
    border-radius: 0.1875rem;
    border: 1px solid var(--color-border, rgba(255, 255, 255, 0.1));
}

/* Light theme adjustments */
.light .spotlight-trigger-pill::before {
    background: #ffffff;
}

.light .spotlight-trigger-pill:hover::before {
    background: #f5f5f5;
}

.light .spotlight-trigger-pill kbd {
    background: var(--color-bg-primary, rgba(0, 0, 0, 0.08));
    border-color: var(--color-border, rgba(0, 0, 0, 0.1));
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Results Count
   ═══════════════════════════════════════════════════════════════════════════════ */

.spotlight-results-count {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    color: var(--color-text-muted, #6b7280);
    border-bottom: 1px solid var(--color-border, rgba(255, 255, 255, 0.05));
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
    .spotlight-overlay {
        padding: 0.5rem;
    }
    
    .spotlight-container {
        max-height: 95vh;
    }
    
    .spotlight-inner {
        max-height: calc(95vh - 4px);
    }
    
    .spotlight-header {
        padding: 1rem;
    }
    
    .spotlight-input {
        font-size: 1.125rem;
    }
    
    .spotlight-results {
        max-height: 55vh;
    }
    
    .spotlight-result {
        padding: 0.625rem 0.75rem;
        gap: 0.625rem;
    }
    
    .spotlight-result-display {
        font-size: 1.125rem;
    }
    
    .spotlight-footer {
        gap: 1rem;
        padding: 0.625rem 1rem;
    }
    
    .spotlight-hint:not(:first-child) {
        display: none;
    }
}

