/**
 * Spotlight-style Search Modal
 * Inspired by macOS Spotlight search
 */

/* Modal Container */
.spotlight-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100000;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.spotlight-modal.active {
    display: block;
    opacity: 1;
}

/* Backdrop */
.spotlight-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Main Container */
.spotlight-container {
    position: relative;
    max-width: 700px;
    width: 90%;
    margin: 0 auto;
    top: 15vh;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    animation: spotlightSlideDown 0.3s ease;
    transition: max-width 0.3s ease, width 0.3s ease;
}

/* Expand container when showing results (70% of screen) */
.spotlight-container.has-results {
    max-width: 70vw;
    width: 70vw;
}

@keyframes spotlightSlideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Search Box */
.spotlight-search-box {
    display: flex;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
}

.spotlight-search-icon {
    font-size: 1.5rem;
    margin-right: 12px;
    color: #6b7280;
}

.spotlight-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1.25rem;
    font-weight: 400;
    background: transparent;
    color: #1f2937;
}

.spotlight-input::placeholder {
    color: #9ca3af;
}

.spotlight-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: #6b7280;
    cursor: pointer;
    padding: 8px;
    margin-left: 12px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.spotlight-close:hover {
    background: #e5e7eb;
    color: #1f2937;
}

/* Results Container */
.spotlight-results {
    max-height: 500px;
    overflow-y: auto;
    background: #ffffff;
    transition: max-height 0.3s ease;
}

/* Expand results container when showing results (60vh for more content) */
.spotlight-container.has-results .spotlight-results {
    max-height: 60vh;
}

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

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

.spotlight-results::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.spotlight-results::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Empty State */
.spotlight-empty,
.spotlight-loading,
.spotlight-no-results,
.spotlight-error {
    padding: 60px 40px;
    text-align: center;
    color: #6b7280;
}

.spotlight-empty p,
.spotlight-no-results p:first-child,
.spotlight-error p:first-child {
    font-size: 1.1rem;
    color: #374151;
    margin-bottom: 8px;
}

.spotlight-hint-text {
    font-size: 0.9rem;
    color: #9ca3af !important;
    margin-top: 8px;
}

/* Loading State */
.spotlight-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.spotlight-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Results List */
.spotlight-results-list {
    padding: 8px;
}

.spotlight-result-item {
    display: flex;
    gap: 16px;
    padding: 16px;
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: all 0.15s ease;
    cursor: pointer;
    border: 1px solid transparent;
}

.spotlight-result-item:hover {
    background: #f9fafb;
    border-color: #e5e7eb;
    transform: translateY(-1px);
}

.spotlight-result-item:active {
    transform: translateY(0);
}

/* Result Image */
.spotlight-result-image {
    flex-shrink: 0;
    width: 100px;
    height: 75px;
    border-radius: 8px;
    overflow: hidden;
    background: #f3f4f6;
    transition: width 0.3s ease, height 0.3s ease;
}

/* Larger images in expanded view */
.spotlight-container.has-results .spotlight-result-image {
    width: 140px;
    height: 105px;
}

.spotlight-result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.spotlight-result-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.spotlight-result-summary {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 0 0 8px 0;
    line-height: 1.5;
}

.spotlight-result-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
    color: #9ca3af;
}

.spotlight-result-source {
    font-weight: 500;
    color: #667eea;
}

.spotlight-result-date {
    color: #9ca3af;
}

/* Results Footer */
.spotlight-results-footer {
    padding: 12px 24px;
    text-align: center;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
}

.spotlight-results-footer p {
    margin: 0;
    font-size: 0.875rem;
    color: #6b7280;
}

/* Modal Footer */
.spotlight-footer {
    padding: 16px 20px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.spotlight-view-all {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.spotlight-view-all:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.spotlight-view-all:active {
    transform: translateY(0);
}

.spotlight-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: #9ca3af;
}

.spotlight-hint kbd {
    display: inline-block;
    padding: 3px 8px;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.75rem;
    color: #374151;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Responsive Design */
@media (max-width: 768px) {
    .spotlight-container {
        width: 95%;
        top: 10vh;
    }

    .spotlight-search-box {
        padding: 16px;
    }

    .spotlight-input {
        font-size: 1.1rem;
    }

    .spotlight-results {
        max-height: 400px;
    }

    .spotlight-result-item {
        flex-direction: column;
        gap: 12px;
    }

    .spotlight-result-image {
        width: 100%;
        height: 150px;
    }

    .spotlight-footer {
        flex-direction: column;
        gap: 12px;
    }

    .spotlight-hint {
        display: none;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    .spotlight-container {
        background: #1f2937;
    }

    .spotlight-search-box {
        background: #111827;
        border-bottom-color: #374151;
    }

    .spotlight-input {
        color: #f9fafb;
    }

    .spotlight-input::placeholder {
        color: #6b7280;
    }

    .spotlight-results {
        background: #1f2937;
    }

    .spotlight-result-item:hover {
        background: #111827;
        border-color: #374151;
    }

    .spotlight-result-title {
        color: #f9fafb;
    }

    .spotlight-result-summary {
        color: #9ca3af;
    }

    .spotlight-footer,
    .spotlight-results-footer {
        background: #111827;
        border-top-color: #374151;
    }

    .spotlight-hint kbd {
        background: #374151;
        border-color: #4b5563;
        color: #d1d5db;
    }
}
