/**
 * EJS Search Box Styles
 * @file ejs-search.css
 * @version 1.0.0
 */

/* Search Box Container */
.ejs-search-box {
    position: relative;
    width: 100%;
    max-width: 450px;
    margin: 0 auto;
}

/* Search Input */
.ejs-search-input {
    width: 100%;
    padding: 12px 80px 12px 20px;
    font-size: 16px;
    border: 1px solid #ddd;
    border-radius: 25px;
    outline: none;
    transition: all 0.3s ease;
    background-color: #f8f9fa;
}

.ejs-search-input:focus {
    background-color: #fff !important;
}

/* Keyboard Shortcut Display - repositioned to right edge */
.ejs-search-shortcut {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: #e9ecef;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    color: #666;
    font-weight: 500;
    font-family: monospace;
    pointer-events: none;
    z-index: 2;
}

/* Search Button - moved to accommodate shortcut */
.ejs-search-btn {
    position: absolute;
    right: 50px;
    top: 50%;
    transform: translateY(-50%);
    background-color: transparent;
    border: none;
    padding: 8px 10px;
    cursor: pointer;
    color: #666;
    font-size: 16px;
    transition: color 0.3s ease;
}

.ejs-search-btn:hover {
    color: #4CAF50;
}

/* Hide search button when shortcut is shown to avoid overlap */
.ejs-search-box:has(.ejs-search-shortcut) .ejs-search-btn {
    display: none;
}

/* Search Results Container */
.ejs-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 8px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-height: 500px;
    overflow-y: auto;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.ejs-search-results.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Discovery Section */
.ejs-search-discovery-header {
    padding: 15px 20px 5px;
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.ejs-search-discovery-games {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    padding: 10px 20px 20px;
}

.ejs-search-discovery-item {
    display: block;
    text-decoration: none;
    color: #333;
    transition: transform 0.2s ease;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.ejs-search-discovery-item:hover {
    transform: translateY(-2px);
}

/* Vertical Video Thumbnails for Discovery */
.ejs-search-game-thumbnail {
    position: relative;
    width: 100%;
    padding-bottom: 133%; /* 3:4 aspect ratio for vertical videos */
    overflow: hidden;
    background-color: #000;
    border-radius: 8px;
}

.ejs-search-game-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s ease;
}

.ejs-search-game-thumbnail .ejs-games-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Show video automatically when discovery is active */
.ejs-search-results.active .ejs-search-game-thumbnail img {
    opacity: 0;
}

.ejs-search-results.active .ejs-search-game-thumbnail .ejs-games-video {
    opacity: 1;
}

/* Game Overlay Info - removed title, only genre */
.ejs-search-game-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.6) 70%, transparent 100%);
    color: white;
    z-index: 10; /* Higher than video to ensure visibility */
    pointer-events: none; /* Allow clicks to pass through to video/link */
}

.ejs-search-game-overlay .ejs-search-game-meta {
    font-size: 10px;
    opacity: 0.9;
}

.ejs-search-game-overlay .ejs-search-game-genre {
    background: rgba(255, 255, 255, 0.25);
    padding: 3px 6px;
    border-radius: 3px;
    display: inline-block;
    font-size: 9px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    pointer-events: auto; /* Allow interactions with genre tag */
    
    /* Ensure single line only */
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
}

/* Search Results List */
.ejs-search-results-list {
    padding: 10px 0;
}

.ejs-search-result-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    text-decoration: none;
    color: #333;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
}

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

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

/* Horizontal thumbnails for search results */
.ejs-search-result-thumbnail {
    width: 60px;
    height: 60px;
    margin-right: 15px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background-color: #f0f0f0;
}

.ejs-search-result-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Game Info */
.ejs-search-result-info {
    flex: 1;
    min-width: 0;
}

.ejs-search-result-title {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ejs-search-result-meta {
    font-size: 13px;
    color: #666;
    display: flex;
    gap: 10px;
}

.ejs-search-result-system,
.ejs-search-result-genre {
    display: inline-block;
    padding: 2px 8px;
    background-color: #e9ecef;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
}

/* Highlight Search Matches */
.ejs-search-result-title mark {
    background-color: #ffeb3b;
    padding: 0 2px;
    border-radius: 2px;
}

/* View All Results */
.ejs-search-view-all {
    padding: 15px 20px;
    text-align: center;
    border-top: 1px solid #f0f0f0;
    cursor: pointer;
    color: #4CAF50;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.ejs-search-view-all:hover {
    background-color: #f8f9fa;
}

/* Loading State */
.ejs-search-loading {
    padding: 40px 20px;
    text-align: center;
}

.ejs-search-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #f0f0f0;
    border-top-color: #4CAF50;
    border-radius: 50%;
    margin: 0 auto 10px;
    animation: ejs-search-spin 0.8s linear infinite;
}

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

.ejs-search-loading span {
    color: #666;
    font-size: 14px;
}

/* No Results */
.ejs-search-no-results {
    padding: 20px 20px 0;
    font-size: .875rem;
}

.ejs-search-no-results p {
    color: #666;
    margin-bottom: 15px;
}

.ejs-search-clear-btn {
    padding: 8px 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.ejs-search-clear-btn:hover {
    background-color: #45a049;
}

/* Error State */
.ejs-search-error {
    padding: 30px 20px;
    text-align: center;
    color: #d32f2f;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .ejs-search-box {
        max-width: 100%;
    }
    
    .ejs-search-input {
        padding: 12px 45px 12px 20px;
    }
    
    .ejs-search-results {
        max-height: 400px;
    }
    
    .ejs-search-result-thumbnail {
        width: 50px;
        height: 50px;
    }
    
    .ejs-search-result-title {
        font-size: 14px;
    }
    
    .ejs-search-result-meta {
        font-size: 12px;
    }

    /* Hide shortcut on mobile */
    .ejs-search-shortcut {
        display: none;
    }
    
    /* Show search button on mobile when shortcut is hidden */
    .ejs-search-btn {
        display: block;
        right: 5px;
    }
}

/* Scrollbar Styling */
.ejs-search-results::-webkit-scrollbar {
    width: 6px;
}

.ejs-search-results::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.ejs-search-results::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.ejs-search-results::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.ejs-games-content p {
	margin-bottom: 0;
}

.ejs-search-form .ejs-search-input {
    background-color: #fff;
    border: 1px solid #e9e6ed;
    border-radius: 5px;
}