/**
 * Global Search Modal Styling
 * Modern search interface with keyboard shortcuts and recent searches
 */

.global-search-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.global-search-modal.active {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 60px;
    animation: searchFadeIn 0.15s ease-out;
}

@keyframes searchFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.search-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
}

.search-container {
    position: relative;
    z-index: 10001;
    width: 100%;
    max-width: 600px;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    animation: searchSlideDown 0.2s ease-out;
}

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

/* Search Header */
.search-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    margin-bottom: 12px;
}

.search-input-wrapper i {
    color: var(--text-secondary);
    font-size: 16px;
}

.search-input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 16px;
    color: var(--text-primary);
    padding: 0;
}

.search-input::placeholder {
    color: var(--text-secondary);
}

.search-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.search-close-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

/* Search Shortcuts */
.search-shortcuts {
    display: flex;
    gap: 12px;
    font-size: 12px;
}

.shortcut {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
}

/* Search Results */
.search-results {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
    min-height: 200px;
}

.search-results::-webkit-scrollbar {
    width: 6px;
}

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

.search-results::-webkit-scrollbar-thumb {
    background: var(--text-secondary);
    border-radius: 3px;
}

.search-results::-webkit-scrollbar-thumb:hover {
    background: var(--text-primary);
}

/* Search Category */
.search-category {
    margin-bottom: 8px;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

.category-header i {
    font-size: 14px;
}

.category-count {
    margin-left: auto;
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
}

.category-items {
    padding: 0;
}

/* Search Result Item */
.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    cursor: pointer;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
}

.search-result-item:hover {
    background: var(--bg-secondary);
    border-left-color: var(--primary);
}

.result-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
    font-size: 14px;
}

.result-content {
    flex: 1;
    min-width: 0;
}

.result-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.result-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-meta {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: right;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Recent Searches */
.recent-search-text {
    flex: 1;
}

.recent-search-delete {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: -8px;
    opacity: 0;
    transition: all 0.2s ease;
}

.search-result-item:hover .recent-search-delete {
    opacity: 1;
}

.recent-search-delete:hover {
    color: var(--danger);
}

/* Search States */
.search-loading,
.search-error,
.search-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-secondary);
}

.search-loading i {
    font-size: 24px;
    margin-bottom: 12px;
    animation: spin 1s linear infinite;
}

.search-error {
    color: var(--danger);
}

.search-error i {
    font-size: 24px;
    margin-bottom: 12px;
}

.search-empty i {
    font-size: 32px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.search-empty p {
    margin: 0;
    font-size: 14px;
}

.category-more {
    padding: 8px 20px;
    font-size: 12px;
    color: var(--primary);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.category-more:hover {
    color: var(--primary);
    text-decoration: underline;
}

/* Animations */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .global-search-modal.active {
        padding-top: 20px;
    }

    .search-container {
        max-width: calc(100% - 20px);
        max-height: 80vh;
    }

    .search-shortcuts {
        display: none;
    }

    .search-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

@media (max-width: 480px) {
    .search-container {
        max-width: calc(100% - 10px);
        max-height: 90vh;
        border-radius: 8px;
    }

    .search-header {
        padding: 12px 16px;
    }

    .search-input-wrapper {
        margin-bottom: 8px;
    }

    .search-results {
        min-height: 150px;
    }

    .search-result-item {
        padding: 8px 16px;
        gap: 10px;
    }

    .result-icon {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .result-title {
        font-size: 13px;
    }

    .result-subtitle,
    .result-meta {
        font-size: 11px;
    }

    .category-header {
        padding: 6px 16px;
        font-size: 11px;
    }
}
