/* Search Modal Styling */
.search-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    overflow: hidden; /* Prevent scrolling when modal is hidden */
}

.search-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    visibility: visible;
    overflow-y: auto; /* Allow scrolling only when active */
}

/* Desktop: Show search below header */
@media (min-width: 992px) {
    .search-modal.active {
        align-items: flex-start;
        padding-top: 80px;
    }

    .search-modal-content {
        animation: slideDown 0.3s ease-out;
    }

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

.search-modal-content {
    background: var(--bg-card, #1a1a1a);
    border: 2px solid var(--accent-primary, #9b2c88);
    border-radius: 10px;
    padding: 30px;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.search-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.search-modal-header h3 {
    color: var(--text-heading, #ffffff);
    margin: 0;
    font-family: 'Orbitron', sans-serif;
}

.search-close {
    background: none;
    border: none;
    color: var(--text-primary, #ffffff);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.3s ease;
}

.search-close:hover {
    color: var(--accent-primary, #9b2c88);
}

.search-modal-input, .search-modal input {
    width: 100%;
    padding: 15px 20px 15px 45px;
    background: var(--bg-secondary, #2a2a2a);
    border: 2px solid var(--border-color, #333);
    border-radius: 8px;
    color: var(--text-primary, #ffffff);
    font-size: 1rem;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.search-modal-input:focus, .search-modal input:focus {
    outline: none;
    border-color: var(--accent-primary, #9b2c88);
    box-shadow: 0 0 15px rgba(155, 44, 136, 0.3);
}

.search-modal-input::placeholder {
    color: var(--text-secondary, #888);
}

/* Search box with icon */
.search-modal .search-box {
    position: relative;
    margin-bottom: 20px;
}

.search-modal .search-box i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--accent-primary, #9b2c88);
    pointer-events: none;
}

.search-modal .search-box input {
    padding-left: 45px;
    margin-bottom: 0;
}

.search-modal-results {
    max-height: calc(85vh - 180px);
    overflow-y: auto;
}

/* Search Results Grid */
.search-results-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-top: 20px;
}

.search-results-header {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--accent-primary, #9b2c88);
}

.search-results-header h3 {
    color: var(--text-heading, #ffffff);
    font-size: 1.1rem;
    margin: 0;
}

.search-result-item {
    display: flex;
    gap: 15px;
    padding: 15px;
    background: var(--bg-secondary, #2a2a2a);
    border: 1px solid var(--border-color, #333);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    color: inherit;
}

.search-result-item:hover {
    background: var(--bg-card, #1a1a1a);
    border-color: var(--accent-primary, #9b2c88);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(155, 44, 136, 0.3);
}

.search-result-image {
    flex-shrink: 0;
    width: 120px;
    height: 68px;
    border-radius: 6px;
    overflow: hidden;
    background: #000;
}

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

.search-result-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.search-result-title {
    font-weight: 600;
    color: var(--text-heading, #ffffff);
    font-size: 1rem;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-title mark {
    background: transparent;
    color: #ff4444;
    padding: 0;
    font-weight: 700;
}

.search-result-description {
    font-size: 0.85rem;
    color: var(--text-secondary, #ccc);
    margin: 4px 0;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.search-result-developer {
    display: inline-block;
    font-size: 0.75rem;
    color: #fff;
    background: var(--accent-primary, #9b2c88);
    padding: 3px 10px;
    border-radius: 4px;
    margin: 4px 0;
    font-weight: 500;
    width: fit-content;
}

.search-result-date {
    font-size: 0.75rem;
    color: var(--text-secondary, #888);
    margin-top: 4px;
}

.search-result-date i {
    margin-right: 5px;
    color: var(--accent-primary, #9b2c88);
}

.search-tag {
    display: inline-block;
    font-size: 0.7rem;
    padding: 2px 8px;
    background: rgba(155, 44, 136, 0.2);
    color: var(--accent-primary, #9b2c88);
    border-radius: 3px;
    margin-right: 5px;
    margin-bottom: 3px;
    text-transform: uppercase;
    font-weight: 500;
}

.search-result-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.search-result-tags .tag {
    font-size: 0.7rem;
    padding: 3px 8px;
}

/* Placeholder, Loading, No Results */
.search-placeholder,
.search-loading,
.search-no-results {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary, #888);
}

.search-placeholder i,
.search-loading i,
.search-no-results i {
    color: var(--accent-primary, #9b2c88);
    margin-bottom: 15px;
    display: block;
}

.search-placeholder h3,
.search-loading h3,
.search-no-results h3 {
    color: var(--text-heading, #ffffff);
    margin-bottom: 10px;
}

.search-placeholder p,
.search-loading p,
.search-no-results p {
    color: var(--text-secondary, #888);
    margin: 0;
}

.search-tips {
    margin-top: 20px;
    padding: 20px;
    background: var(--bg-secondary, #2a2a2a);
    border-radius: 8px;
    text-align: left;
}

.search-tips small {
    color: var(--accent-primary, #9b2c88);
    font-weight: 600;
}

.search-tips ul {
    margin: 10px 0 0 0;
    padding-left: 20px;
    list-style: none;
}

.search-tips ul li {
    margin: 5px 0;
    color: var(--text-secondary, #888);
}

.search-tips ul li::before {
    content: "→ ";
    color: var(--accent-primary, #9b2c88);
    font-weight: bold;
    margin-right: 5px;
}

.no-search-results {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary, #888);
}

.no-search-results i {
    font-size: 2rem;
    color: var(--accent-primary, #9b2c88);
    margin-bottom: 10px;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .search-modal-content {
        padding: 20px;
        width: 95%;
        max-width: 95%;
    }

    .search-modal-input {
        padding: 12px 15px;
        font-size: 0.95rem;
    }

    .search-result-item {
        flex-direction: column;
        gap: 10px;
    }

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

    .search-result-title {
        white-space: normal;
        font-size: 0.95rem;
    }

    .search-tips {
        padding: 15px;
    }

    .search-results-header h3 {
        font-size: 1rem;
    }
}