/**
 * @package     Yapuka Search Module
 * @subpackage  mod_yapuka_search
 *
 * @copyright   (C) 2025 Yapuka.dev. All rights reserved.
 * @license     GNU General Public License version 3 or later
 */

/* Main module container */
.mod-yapuka-search {
    position: relative;
    width: 100%;
    max-width: 400px;
}

/* Search form container */
.yapuka-search-form {
    position: relative;
}

/* Input wrapper */
.yapuka-search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

/* Search input */
.yapuka-search-input {
    width: 100%;
    padding: 12px 16px;
    padding-right: 50px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 16px;
    line-height: 1.4;
    background-color: #fff;
    transition: all 0.3s ease;
    outline: none;
}

.yapuka-search-input:focus {
    border-color: #007cba;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
}

.yapuka-search-input::placeholder {
    color: #999;
    font-style: italic;
}

/* Loading spinner */
.yapuka-search-loading {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #007cba;
}

/* Results container */
.yapuka-search-results {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    z-index: 1000;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 400px;
    overflow-y: auto;
    min-width: 100%;
    animation: yapukaSlideDown 0.2s ease-out;
}

/* Results list */
.yapuka-search-results-list {
    padding: 0;
    margin: 0;
    list-style: none;
}

/* Individual result item */
.yapuka-search-result-item {
    display: block;
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    text-decoration: none;
    color: inherit;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.yapuka-search-result-item:hover,
.yapuka-search-result-item.active {
    background-color: #f8f9fa;
    text-decoration: none;
    color: inherit;
}

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

/* Featured content indicator */
.yapuka-search-result-item.featured {
    border-left: 4px solid #ffc107;
}

/* Result content wrapper */
.yapuka-search-result-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

/* Result image */
.yapuka-search-result-image {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    background-color: #f0f0f0;
}

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

/* Result text content */
.yapuka-search-result-text {
    flex: 1;
    min-width: 0;
}

/* Result title */
.yapuka-search-result-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0 0 4px 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Result category */
.yapuka-search-result-category {
    font-size: 12px;
    color: #666;
    margin: 0 0 6px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Result introtext */
.yapuka-search-result-introtext {
    font-size: 14px;
    color: #666;
    line-height: 1.4;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* No results message */
.yapuka-search-no-results {
    padding: 20px 16px;
    text-align: center;
    color: #999;
    font-style: italic;
}

/* Highlight search terms */
.yapuka-search-highlight {
    background-color: #fff3cd;
    padding: 1px 2px;
    border-radius: 2px;
    font-weight: 600;
}

/* Animation for results appearing */
@keyframes yapukaSlideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .mod-yapuka-search {
        max-width: 100%;
    }

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

    .yapuka-search-result-content {
        gap: 8px;
    }

    .yapuka-search-result-image {
        width: 50px;
        height: 50px;
    }

    .yapuka-search-result-title {
        font-size: 15px;
    }

    .yapuka-search-result-introtext {
        font-size: 13px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .yapuka-search-input {
        background-color: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }

    .yapuka-search-input::placeholder {
        color: #a0aec0;
    }

    .yapuka-search-results {
        background-color: #2d3748;
        border-color: #4a5568;
    }

    .yapuka-search-result-item {
        border-bottom-color: #4a5568;
        color: #e2e8f0;
    }

    .yapuka-search-result-item:hover,
    .yapuka-search-result-item.active {
        background-color: #4a5568;
    }

    .yapuka-search-result-title {
        color: #e2e8f0;
    }

    .yapuka-search-result-category,
    .yapuka-search-result-introtext {
        color: #a0aec0;
    }

    .yapuka-search-no-results {
        color: #a0aec0;
    }

    .yapuka-search-highlight {
        background-color: #856404;
        color: #fff3cd;
    }
}
