/**
 * Frontend Styles for AI SearchBar
 */

/* Search Button */
.aisb-search-button {
    background: #2271b1;
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background 0.3s ease;
}

.aisb-search-button:hover {
    background: #135e96;
}

.aisb-search-button .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* Modal */
.aisb-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    overflow-y: auto;
}

.aisb-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 1;
}

.aisb-modal-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 800px;
    width: 90%;
    background: #fff;
    border-radius: 12px;
    padding: 40px;
    z-index: 2;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: aisb-modal-fade-in 0.2s ease;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes aisb-modal-fade-in {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.aisb-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.aisb-modal-close:hover {
    background: #f0f0f0;
    color: #000;
}

.aisb-modal-close .dashicons {
    width: 24px;
    height: 24px;
    font-size: 24px;
}

/* Search Container */
.aisb-search-container h2 {
    margin: 0 0 32px 0;
    font-size: 28px;
    font-weight: 600;
    color: #000;
    text-align: center;
}

/* Search Form */
.aisb-search-form {
    margin-bottom: 30px;
}

.aisb-search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}

.aisb-search-input-wrapper .dashicons {
    position: absolute;
    left: 15px;
    color: #666;
    font-size: 20px;
    width: 20px;
    height: 20px;
    pointer-events: none;
}

.aisb-search-input {
    flex: 1;
    padding: 15px 15px 15px 45px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.3s ease;
}

.aisb-search-input:focus {
    border-color: #2271b1;
}

.aisb-search-submit {
    padding: 15px 30px;
    background: #2271b1;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s ease;
}

.aisb-search-submit:hover {
    background: #135e96;
}

/* Search Results */
.aisb-search-results {
    max-height: 500px;
    overflow-y: auto;
}

.aisb-results-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.aisb-result-item {
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.aisb-result-item:hover {
    border-color: #2271b1;
    box-shadow: 0 4px 12px rgba(34, 113, 177, 0.1);
    transform: translateY(-2px);
}

.aisb-result-link {
    display: flex;
    gap: 15px;
    padding: 15px;
    text-decoration: none;
    color: inherit;
}

.aisb-result-thumbnail {
    flex-shrink: 0;
    width: 120px;
    height: 90px;
    border-radius: 6px;
    overflow: hidden;
    background: #f5f5f5;
}

.aisb-result-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.aisb-result-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.aisb-result-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 10px;
}

.aisb-result-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #000;
    line-height: 1.4;
}

.aisb-content-type {
    padding: 4px 10px;
    background: #e7f3ff;
    color: #2271b1;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    text-transform: capitalize;
}

.aisb-result-description {
    margin: 0;
    font-size: 14px;
    color: #666;
    line-height: 1.6;
}

.aisb-result-description mark {
    background: #fff3cd;
    padding: 2px 4px;
    border-radius: 2px;
}

.aisb-result-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.aisb-tag {
    padding: 4px 8px;
    background: #f0f0f0;
    color: #666;
    border-radius: 4px;
    font-size: 12px;
}

/* View All Link */
.aisb-view-all {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e5e5e5;
    text-align: center;
}

.aisb-view-all-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 12px 24px;
    background: #f0f0f0;
    color: #2271b1;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.aisb-view-all-link:hover {
    background: #2271b1;
    color: #fff;
}

/* Loading State */
.aisb-search-loading {
    text-align: center;
    padding: 40px 20px;
}

.aisb-spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2271b1;
    border-radius: 50%;
    animation: aisb-spin 1s linear infinite;
}

@keyframes aisb-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.aisb-search-loading p {
    color: #666;
    font-size: 16px;
}

/* Placeholder State */
.aisb-search-placeholder,
.aisb-search-message {
    text-align: center;
    padding: 60px 20px;
}

.aisb-search-placeholder p,
.aisb-search-message p {
    color: #999;
    font-size: 16px;
    margin: 0;
}

/* Body Lock */
body.aisb-modal-open {
    overflow: hidden;
}

/* Tablet (769px - 1024px) */
@media screen and (max-width: 1024px) and (min-width: 769px) {
    .aisb-modal-content {
        width: 80%;
        max-width: 700px;
        padding: 36px;
    }
    
    .aisb-search-container h2 {
        font-size: 26px;
        margin-bottom: 28px;
    }
}

/* Mobile Landscape & Small Tablet (481px - 768px) */
@media screen and (max-width: 768px) {
    .aisb-modal-content {
        width: 92%;
        padding: 32px 24px;
    }
    
    .aisb-search-container h2 {
        font-size: 24px;
        margin-bottom: 26px;
    }
    
    .aisb-search-input-wrapper {
        flex-direction: column;
        gap: 12px;
    }
    
    .aisb-search-input {
        width: 100%;
        font-size: 16px; /* Prevents iOS zoom */
    }
    
    .aisb-search-submit {
        width: 100%;
        padding: 16px;
    }
}

/* Mobile Portrait (up to 480px) */
@media screen and (max-width: 480px) {
    .aisb-modal-content {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        padding: 24px 20px;
        transform: translate(-50%, -50%);
    }
    
    .aisb-search-container h2 {
        font-size: 22px;
        margin-bottom: 24px;
    }
    
    .aisb-search-input {
        padding: 14px 16px 14px 45px;
        font-size: 16px; /* Prevents iOS zoom */
    }
    
    .aisb-search-submit {
        padding: 15px;
        font-size: 16px;
    }
    
    .aisb-modal-close {
        top: 12px;
        right: 12px;
    }
}

/* Scrollbar Styling */
.aisb-search-results::-webkit-scrollbar {
    width: 8px;
}

.aisb-search-results::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.aisb-search-results::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.aisb-search-results::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}