/**
 * Centered Search Bar Styles
 * YouTube-inspired search bar design for VideoHub360
 *
 * @package Videohub360_Theme
 * @since 1.0.0
 */

/* Search Bar Container */
.vh360-search-bar-centered {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
}

/* Mobile Search Icon Toggle - Hidden on desktop */
.vh360-search-bar-centered__mobile-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-color, #1f2937);
    transition: color 0.2s ease;
}

.vh360-search-bar-centered__mobile-toggle:hover {
    color: var(--primary-color, #0066cc);
}

/* Mobile Close Button - Hidden by default */
.vh360-search-bar-centered__mobile-close {
    display: none;
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #1f2937;
    z-index: 10;
    transition: color 0.2s ease;
}

.vh360-search-bar-centered__mobile-close:hover {
    color: #0066cc;
}

.vh360-search-bar-centered__container {
    position: relative;
    width: 100%;
}

/* Input Wrapper */
.vh360-search-bar-centered__input-wrapper {
    display: flex;
    align-items: center;
    width: 100%;
    border: 1px solid #ccc;
    border-radius: 40px;
    background-color: #fff;
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.vh360-search-bar-centered__input-wrapper:hover {
    border-color: #0066cc;
}

.vh360-search-bar-centered__input-wrapper:focus-within {
    border-color: #0066cc;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

/* Search Input */
.vh360-search-bar-centered__input {
    flex: 1;
    padding: 10px 16px;
    font-size: 16px;
    border: none;
    outline: none;
    background: transparent;
    color: #1f2937;
}

.vh360-search-bar-centered__input::placeholder {
    color: #9ca3af;
}

/* Search Button */
.vh360-search-bar-centered__button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 40px;
    border: none;
    background-color: #f8f8f8;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-left: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.vh360-search-bar-centered__button:hover {
    background-color: #f0f0f0;
}

.vh360-search-bar-centered__button svg {
    color: #374151;
}

/* Results Dropdown */
.vh360-search-bar-centered__dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    max-height: 600px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.vh360-search-bar-centered__dropdown[aria-hidden="false"] {
    display: block;
}

/* Filter Tabs */
.vh360-search-bar-centered__filters {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.vh360-search-bar-centered__filters::-webkit-scrollbar {
    height: 4px;
}

.vh360-search-bar-centered__filters::-webkit-scrollbar-thumb {
    background-color: #d1d5db;
    border-radius: 2px;
}

.vh360-search-bar-centered__filter-tab {
    padding: 6px 12px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: 20px;
    background-color: transparent;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.vh360-search-bar-centered__filter-tab:hover {
    background-color: #f3f4f6;
}

.vh360-search-bar-centered__filter-tab.active {
    background-color: #1f2937;
    color: #fff;
}

/* Results Container */
.vh360-search-bar-centered__results {
    padding: 8px 0;
}

/* Result Groups */
.vh360-search-bar-centered__result-group {
    margin-bottom: 16px;
}

.vh360-search-bar-centered__result-group:last-child {
    margin-bottom: 0;
}

.vh360-search-bar-centered__result-group-title {
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Result Items */
.vh360-search-bar-centered__result-item {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    text-decoration: none;
    color: inherit;
    transition: background-color 0.2s ease;
}

.vh360-search-bar-centered__result-item:hover {
    background-color: #f2f2f2;
}

/* Video Results */
.vh360-search-bar-centered__result-item--video .vh360-search-bar-centered__result-thumbnail {
    width: 120px;
    height: 68px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

/* Member Results */
.vh360-search-bar-centered__result-item--member .vh360-search-bar-centered__result-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

/* Gallery/Event/Bulletin Results */
.vh360-search-bar-centered__result-item--gallery .vh360-search-bar-centered__result-thumbnail,
.vh360-search-bar-centered__result-item--event .vh360-search-bar-centered__result-thumbnail,
.vh360-search-bar-centered__result-item--bulletin .vh360-search-bar-centered__result-thumbnail {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

/* Post Results */
.vh360-search-bar-centered__result-item--post .vh360-search-bar-centered__result-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

/* Result Content */
.vh360-search-bar-centered__result-content {
    flex: 1;
    margin-left: 12px;
    min-width: 0;
}

.vh360-search-bar-centered__result-title {
    font-size: 14px;
    font-weight: 500;
    color: #1f2937;
    margin: 0 0 4px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vh360-search-bar-centered__result-meta {
    font-size: 12px;
    color: #606060;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Highlight matched text */
.vh360-search-bar-centered__highlight {
    font-weight: 700;
    color: #0066cc;
}

/* Loading State */
.vh360-search-bar-centered__loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    color: #6b7280;
}

.vh360-search-bar-centered__spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top-color: #0066cc;
    border-radius: 50%;
    animation: vh360-spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

.vh360-search-bar-centered__loading p {
    margin: 0;
    font-size: 14px;
}

/* Empty State */
.vh360-search-bar-centered__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    color: #6b7280;
    text-align: center;
}

.vh360-search-bar-centered__empty svg {
    color: #d1d5db;
    margin-bottom: 16px;
}

.vh360-search-bar-centered__empty p {
    margin: 0;
    font-size: 14px;
}

/* Error State */
.vh360-search-bar-centered__error {
    padding: 24px;
    text-align: center;
    color: #ef4444;
}

.vh360-search-bar-centered__error p {
    margin: 0;
    font-size: 14px;
}

/* Responsive Styles */

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
    .vh360-search-bar-centered {
        max-width: 400px;
    }
}

/* Mobile (< 768px) */
@media (max-width: 767px) {
    /* On mobile, the search appears in the right zone as an icon */
    /* The center zone is hidden (see header-layout.css) */
    
    /* Show mobile toggle icon */
    .vh360-search-bar-centered__mobile-toggle {
        display: flex;
    }
    
    /* Hide desktop search bar container */
    .vh360-search-bar-centered__container {
        display: none;
    }
    
    /* When mobile search is active */
    .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__mobile-toggle {
        display: none;
    }
    
    .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__container {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 9999;
        background: #fff;
        overflow: hidden;
        padding-top: 60px; /* Space for WordPress admin bar and search positioning */
    }
    
    /* Account for WordPress admin bar when user is logged in */
    body.admin-bar .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__container {
        padding-top: 106px; /* 46px admin bar + 60px spacing */
    }
    
    .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__input-wrapper {
        margin: 16px 20px; /* Added horizontal margin to prevent cutoff */
        max-width: calc(100% - 40px); /* Ensure it doesn't overflow */
        border-radius: 24px;
    }
    
    .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__input {
        font-size: 16px;
        padding: 12px 16px;
    }
    
    .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__button {
        width: 48px;
        height: 48px;
    }
    
    .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__dropdown {
        position: relative;
        top: 0;
        left: 0;
        right: 0;
        border: none;
        border-radius: 0;
        box-shadow: none;
        max-height: calc(100vh - 180px);
        overflow-y: auto;
        margin-top: 0;
    }
    
    /* Always show close button in mobile overlay */
    .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__mobile-close {
        display: block;
        position: fixed;
        top: 16px;
        right: 16px;
    }
    
    /* Adjust close button for WordPress admin bar */
    body.admin-bar .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__mobile-close {
        top: 62px; /* 46px admin bar + 16px spacing */
    }
    }
    
    /* Improved spacing for mobile results */
    .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__filters {
        padding: 12px 16px;
        gap: 8px;
        border-bottom: 2px solid #e5e7eb;
    }
    
    .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__filter-tab {
        font-size: 14px;
        padding: 8px 16px;
    }
    
    .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__result-item {
        padding: 16px;
        border-bottom: 1px solid #f3f4f6;
    }
    
    .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__result-item--video .vh360-search-bar-centered__result-thumbnail {
        width: 120px;
        height: 68px;
    }
    
    .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__result-content {
        margin-left: 16px;
    }
    
    .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__result-title {
        font-size: 15px;
        margin-bottom: 6px;
    }
    
    .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__result-meta {
        font-size: 13px;
    }
    
    .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__result-group-title {
        padding: 12px 16px;
        font-size: 13px;
    }
    
    /* Better empty/loading states on mobile */
    .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__loading,
    .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__empty {
        padding: 64px 32px;
    }
}

/* Small Mobile (< 480px) */
@media (max-width: 479px) {
    .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__input-wrapper {
        margin: 12px 16px; /* Smaller horizontal margins on small screens */
        max-width: calc(100% - 32px);
    }
    
    .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__input {
        padding: 10px 14px;
        font-size: 15px;
    }
    
    .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__button {
        width: 44px;
        height: 44px;
    }
    
    .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__button svg {
        width: 20px;
        height: 20px;
    }
    
    .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__result-item--video .vh360-search-bar-centered__result-thumbnail {
        width: 100px;
        height: 56px;
    }
    
    .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__result-item--gallery .vh360-search-bar-centered__result-thumbnail,
    .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__result-item--event .vh360-search-bar-centered__result-thumbnail,
    .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__result-item--bulletin .vh360-search-bar-centered__result-thumbnail {
        width: 70px;
        height: 70px;
    }
    
    .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__result-content {
        margin-left: 12px;
    }
    
    .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__result-title {
        font-size: 14px;
    }
    
    .vh360-search-bar-centered.mobile-search-active .vh360-search-bar-centered__result-meta {
        font-size: 12px;
    }
}
