/**
 * eWiDa Global Search - Styles
 *
 * A clean, modern search interface with dropdown results
 *
 * Author: Sebastian Kühn
 * Date: 2025-11-19
 */

/* ============================================================================
   SEARCH CONTAINER
   ============================================================================ */

/* Desktop: hidden by default, toggled by search icon */
.global-search-wrapper {
    display: none;
    position: fixed;
    top: 11px;
    right: 131px;
    z-index: 9998;
    max-width: 500px;
    width: 500px;
}

.search-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

/* ============================================================================
   SEARCH INPUT
   ============================================================================ */

#globalSearch {
    width: 100%;
    padding: 12px 20px;
    padding-left: 40px; /* Space for search icon */
    font-size: 15px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background-color: #ffffff;
  
    background-repeat: no-repeat;
    background-position: 12px center;
    background-size: 18px;
    transition: all 0.2s ease;
    outline: none;
    box-sizing: border-box;
}

#globalSearch:focus {
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

#globalSearch::placeholder {
    color: #999;
    font-size: 14px;
}

/* ============================================================================
   SEARCH RESULTS DROPDOWN
   ============================================================================ */

#searchResults {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    max-height: 500px;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    display: none; /* Hidden by default */
}

/* Custom scrollbar */
#searchResults::-webkit-scrollbar {
    width: 8px;
}

#searchResults::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 8px;
}

#searchResults::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 8px;
}

#searchResults::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* ============================================================================
   PHASE 2: QUICK ACCESS BUTTONS
   ============================================================================ */

.search-quick-buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    margin-bottom: 8px;
}

.search-quick-btn {
    flex: 1;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.search-quick-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.search-quick-btn:active {
    background: #dee2e6;
}

/* ============================================================================
   SEARCH RESULT ITEMS WITH PHASE 2 FEATURES
   ============================================================================ */

.search-results-header {
    padding: 12px 16px;
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
    color: #495057;
    font-size: 13px;
}

.search-item-container {
    position: relative;
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid #f0f0f0;
}

.search-item-container:last-child {
    border-bottom: none;
}

.search-item {
    flex: 1;
    display: flex;
    align-items: flex-start;
    padding: 14px 16px;
    text-decoration: none;
    color: #333;
    transition: background-color 0.15s ease;
    cursor: pointer;
}

.search-item:hover {
    background-color: #f8f9fa;
}

.search-item:active {
    background-color: #e9ecef;
}

/* Search icon */
.search-icon {
    margin-right: 12px;
    font-size: 18px;
    color: #6c757d;
    min-width: 24px;
}

/* Search content wrapper */
.search-content {
    flex: 1;
}

/* Search result title with badge */
.search-title-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.search-title {
    font-weight: 600;
    font-size: 15px;
    color: #2c3e50;
}

/* Usage count badge */
.usage-badge {
    display: inline-block;
    padding: 2px 6px;
    background: #28a745;
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: 10px;
}

/* Search result description */
.search-desc {
    font-size: 13px;
    color: #7f8c8d;
    margin-top: 4px;
    line-height: 1.4;
}

/* Tags (Phase 2) */
.search-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.search-tag {
    display: inline-block;
    padding: 2px 8px;
    background: #e3f2fd;
    color: #1976d2;
    font-size: 11px;
    border-radius: 12px;
    font-weight: 500;
}

/* Category path (breadcrumb) */
.search-path {
    font-size: 12px;
    color: #95a5a6;
    margin-top: 6px;
    font-style: italic;
}

.search-path::before {
    content: "📂 ";
    opacity: 0.7;
}

/* Author info */
.search-author {
    font-size: 11px;
    color: #bdc3c7;
    margin-top: 4px;
}

/* Favorite button (Phase 2) */
.favorite-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    background: transparent;
    border: none;
    border-left: 1px solid #f0f0f0;
    font-size: 20px;
    color: #dee2e6;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.favorite-btn:hover {
    background: #f8f9fa;
    color: #ffc107;
}

.favorite-btn.active {
    color: #ffc107;
}

/* Access info for most-used */
.access-info {
    padding: 8px 16px;
    background: #f8f9fa;
    font-size: 11px;
    color: #6c757d;
    border-top: 1px solid #e9ecef;
}

/* Search history item */
.search-history-item {
    display: block;
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    text-decoration: none;
    color: #495057;
    transition: background-color 0.15s ease;
}

.search-history-item:hover {
    background-color: #f8f9fa;
}

.history-icon {
    margin-right: 8px;
}

/* Clear history button */
.clear-history-btn {
    width: 100%;
    padding: 12px;
    background: #f8f9fa;
    border: none;
    border-top: 1px solid #e9ecef;
    color: #dc3545;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.clear-history-btn:hover {
    background: #e9ecef;
}

/* Search hint */
.search-hint {
    padding: 30px 20px;
    text-align: center;
    color: #6c757d;
    font-size: 14px;
}

/* ============================================================================
   SPECIAL STATES
   ============================================================================ */

/* Loading state */
.search-loading {
    padding: 20px;
    text-align: center;
    color: #7f8c8d;
    font-size: 14px;
}

.search-loading::before {
    content: "⏳ ";
}

/* No results state */
.search-no-results {
    padding: 30px 20px;
    text-align: center;
}

.search-no-results-text {
    font-size: 15px;
    color: #555;
    margin-bottom: 8px;
}

.search-no-results-hint {
    font-size: 13px;
    color: #999;
}

/* Error state */
.search-error {
    padding: 20px;
    text-align: center;
    color: #e74c3c;
    font-size: 14px;
}

.search-error::before {
    content: "⚠️ ";
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

/* Mobile devices (up to 768px) */
@media (max-width: 768px) {
    /* Mobile: full width bar below header */
    .global-search-wrapper {
        display: none; /* Hidden by default on mobile, toggled by search icon */
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        background: white;
        padding: 10px 15px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        z-index: 99;
        max-width: none;
        width: auto;
    }

    .search-container {
        max-width: 100%;
        padding: 0;
        margin: 0 auto;
        max-width: 600px;
        position: relative;
    }

    #globalSearch {
        font-size: 14px;
        padding: 10px 16px;
        padding-left: 38px;
    }

    #searchResults {
        max-height: 400px;
    }

    .search-item {
        padding: 12px 14px;
    }

    .search-title {
        font-size: 14px;
    }

    .search-desc {
        font-size: 12px;
    }

    /* Adjust content margin for mobile */
    #content.frontend {
        margin-top: 155px !important;
    }
}

/* Tablets (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    .search-container {
        max-width: 600px;
    }
}

/* Large screens (1024px+) */
@media (min-width: 1024px) {
    .search-container {
        max-width: 500px;
    }

    #searchResults {
        max-height: 550px;
    }
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

/* Focus states for keyboard navigation */
.search-item:focus {
    outline: 2px solid #4a90e2;
    outline-offset: -2px;
    background-color: #f0f7ff;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    #globalSearch {
        border-width: 3px;
    }

    .search-item {
        border-bottom-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    #globalSearch,
    .search-item {
        transition: none;
    }
}

/* ============================================================================
   DARK MODE (Optional - activate if needed)
   ============================================================================ */

/*
@media (prefers-color-scheme: dark) {
    #globalSearch {
        background-color: #2c2c2c;
        border-color: #444;
        color: #fff;
    }

    #searchResults {
        background-color: #2c2c2c;
        border-color: #444;
    }

    .search-item {
        border-bottom-color: #3a3a3a;
        color: #e0e0e0;
    }

    .search-item:hover {
        background-color: #3a3a3a;
    }

    .search-title {
        color: #fff;
    }

    .search-desc,
    .search-path,
    .search-author {
        color: #aaa;
    }

    .search-loading,
    .search-no-results-text {
        color: #ccc;
    }
}
*/

/* ============================================================================
   KEYBOARD SHORTCUT HINT (Optional)
   ============================================================================ */

.search-shortcut-hint {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    padding: 4px 8px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 11px;
    color: #999;
    font-family: monospace;
    pointer-events: none;
}

#globalSearch:focus + .search-shortcut-hint {
    display: none;
}

/* ============================================================================
   MOBILE SEARCH TOGGLE BUTTON
   ============================================================================ */

.mobile-search-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    font-size: 18px;
    color: #333;
    cursor: pointer;
    margin: 0;
    padding: 0;
    position: absolute;
    right: 91px;
    top: 16px;
    transition: all 0.2s ease;
}

.mobile-search-toggle:hover {
    color: #4a90e2;
}

.mobile-search-toggle:active {
    transform: scale(0.95);
}

@media (max-width: 768px) {
    .mobile-search-toggle {
        left: 30px;
        right: auto;
    }
}
