/* =============================================================
   WP Advanced Search — Frontend Styles
   Version: 1.0.0
   ============================================================= */

/* ── Widget wrapper ── */
.wpas-widget {
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

.wpas-widget *,
.wpas-widget *::before,
.wpas-widget *::after {
    box-sizing: border-box;
}

/* ── Search row ── */
.wpas-search-row {
    position: relative;
    width: 100%;
}

/* ── Input wrap ── */
.wpas-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

/* ── Input ── */
.wpas-input {
    display: block;
    width: 100%;
    padding: 12px 44px 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 15px;
    line-height: 1.5;
    color: #111827;
    background-color: #ffffff;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.wpas-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Remove browser default search cancel button */
.wpas-input::-webkit-search-cancel-button,
.wpas-input::-webkit-search-decoration {
    -webkit-appearance: none;
}

/* ── Search icon ── */
.wpas-search-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    pointer-events: none;
    display: flex;
    align-items: center;
    line-height: 1;
    transition: color 0.15s;
}

.wpas-input:focus + .wpas-search-icon,
.wpas-input:focus ~ .wpas-search-icon {
    color: #2563eb;
}

/* When clear button is visible, shift icon left */
.wpas-clear-btn[style*="inline"] ~ .wpas-search-icon,
.wpas-clear-btn:not([style*="none"]) ~ .wpas-search-icon {
    right: 38px;
}

/* ── Clear button ── */
.wpas-clear-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: color 0.15s, background-color 0.15s;
    line-height: 1;
}

.wpas-clear-btn:hover {
    color: #374151;
    background-color: #f3f4f6;
}

/* ── Results area ── */
.wpas-results-area {
    margin-top: 16px;
    width: 100%;
}

/* ── Loading indicator ── */
.wpas-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    color: #6b7280;
    font-size: 14px;
}

.wpas-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid #e5e7eb;
    border-top-color: #2563eb;
    border-radius: 50%;
    flex-shrink: 0;
    animation: wpas-spin 0.65s linear infinite;
}

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

/* ── Result count ── */
.wpas-result-count {
    font-size: 13px;
    color: #6b7280;
    margin: 0 0 12px;
}

.wpas-result-count strong {
    font-weight: 600;
    color: #374151;
}

/* ── Results grid ── */
.wpas-results-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    width: 100%;
}

/* Fallback result item (no loop template) */
.wpas-result-item {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.15s ease;
}

.wpas-result-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.wpas-result-thumb {
    display: block;
    width: 100%;
    overflow: hidden;
    line-height: 0;
}

.wpas-result-thumb img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
    transition: transform 0.2s ease;
}

.wpas-result-item:hover .wpas-result-thumb img {
    transform: scale(1.02);
}

.wpas-result-body {
    padding: 14px 16px 16px;
}

.wpas-result-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 6px;
    line-height: 1.4;
}

.wpas-result-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.15s;
}

.wpas-result-title a:hover {
    color: #2563eb;
}

.wpas-result-excerpt {
    font-size: 13px;
    color: #6b7280;
    margin: 0 0 8px;
    line-height: 1.6;
}

.wpas-result-type {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9ca3af;
    background: #f3f4f6;
    border-radius: 4px;
    padding: 2px 7px;
    display: inline-block;
}

/* ── No results ── */
.wpas-no-results {
    padding: 32px 16px;
    text-align: center;
}

.wpas-no-results-text {
    font-size: 15px;
    color: #6b7280;
    margin: 0;
}

/* ── Load more ── */
.wpas-load-more-wrap {
    margin-top: 24px;
    text-align: center;
}

.wpas-load-more-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 28px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    background-color: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
    line-height: 1;
}

.wpas-load-more-btn:hover {
    background-color: #f9fafb;
    border-color: #9ca3af;
}

.wpas-load-more-btn:disabled,
.wpas-load-more-btn.loading {
    opacity: 0.65;
    cursor: not-allowed;
}

.wpas-load-more-btn .wpas-btn-spinner {
    display: none;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: wpas-spin 0.65s linear infinite;
}

.wpas-load-more-btn.loading .wpas-btn-spinner {
    display: inline-block;
}

/* ── Loop item wrapper ── */
.wpas-loop-item {
    min-height: 1px;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    .wpas-results-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .wpas-results-grid {
        grid-template-columns: 1fr;
    }

    .wpas-input {
        font-size: 16px; /* Prevents iOS zoom */
    }
}
