/**
 * OfiSearch Styles - Solaris theme
 *
 * @package OfiSearch
 * @version 1.0.0
 */

/* ─── Variables ────────────────────────────────────────────────── */
:root {
    --ofisearch-primary: #4a90d9;
    --ofisearch-bg: #fff;
    --ofisearch-border: #dfe1e5;
    --ofisearch-text: #333;
    --ofisearch-text-muted: #777;
    --ofisearch-hover: #f5f7fa;
    --ofisearch-highlight: #e8f0fe;
    --ofisearch-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    --ofisearch-radius: 4px;
    --ofisearch-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
}

/* ─── Search Form ──────────────────────────────────────────────── */
.ofisearch-wrapp {
    position: relative;
    width: 100%;
    max-width: 600px;
    font-family: var(--ofisearch-font);
    z-index: 9999;
}

.ofisearch-form {
    margin: 0;
    padding: 0;
}

.ofisearch-sf-wrapp {
    display: flex;
    align-items: center;
    background: var(--ofisearch-bg);
    border: 1px solid var(--ofisearch-border);
    border-radius: var(--ofisearch-radius);
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ofisearch-sf-wrapp:focus-within {
    border-color: var(--ofisearch-primary);
    box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.2);
}

.ofisearch-ico-magnifier {
    flex-shrink: 0;
    padding: 0 8px 0 12px;
    color: var(--ofisearch-text-muted);
    pointer-events: none;
}

.ofisearch-input {
    flex: 1;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    padding: 10px 8px;
    font-size: 14px;
    line-height: 1.4;
    color: var(--ofisearch-text);
    background: transparent !important;
    min-width: 0;
    -webkit-appearance: none;
    appearance: none;
}

.ofisearch-input::placeholder {
    color: var(--ofisearch-text-muted);
}

.ofisearch-input::-webkit-search-cancel-button,
.ofisearch-input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

.ofisearch-preloader {
    flex-shrink: 0;
    padding: 0 8px;
    color: var(--ofisearch-primary);
}

.ofisearch-spinner {
    animation: ofisearch-spin 0.8s linear infinite;
}

@keyframes ofisearch-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.ofisearch-close {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--ofisearch-text-muted);
    cursor: pointer;
    padding: 0;
    border-radius: 50%;
    transition: background 0.15s;
}

.ofisearch-close:hover {
    background: var(--ofisearch-hover);
    color: var(--ofisearch-text);
}

.ofisearch-submit {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: none;
    background: var(--ofisearch-primary);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s;
    height: 100%;
    min-height: 40px;
}

.ofisearch-submit:hover {
    background: #3a7bc8;
}

/* ─── Suggestions Dropdown ─────────────────────────────────────── */
.ofisearch-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--ofisearch-bg);
    border: 1px solid var(--ofisearch-border);
    border-top: none;
    border-radius: 0 0 var(--ofisearch-radius) var(--ofisearch-radius);
    box-shadow: var(--ofisearch-shadow);
    max-height: 70vh;
    overflow-y: auto;
    z-index: 99999;
    scrollbar-width: thin;
}

.ofisearch-suggestion-list {
    padding: 4px 0;
}

/* Headlines (Categories, Products) */
.ofisearch-headline {
    padding: 8px 16px 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ofisearch-text-muted);
    border-top: 1px solid var(--ofisearch-border);
}

.ofisearch-headline:first-child {
    border-top: none;
}

/* Category suggestion */
.ofisearch-suggestion-tax {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    text-decoration: none;
    color: var(--ofisearch-text);
    cursor: pointer;
    transition: background 0.1s;
    gap: 8px;
}

.ofisearch-suggestion-tax:hover,
.ofisearch-suggestion-tax.ofisearch-selected {
    background: var(--ofisearch-hover);
    text-decoration: none;
    color: var(--ofisearch-text);
}

.ofisearch-tax-icon {
    flex-shrink: 0;
    color: var(--ofisearch-text-muted);
}

.ofisearch-tax-name {
    font-size: 13px;
}

/* Product suggestion */
.ofisearch-suggestion-product {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    text-decoration: none;
    color: var(--ofisearch-text);
    cursor: pointer;
    transition: background 0.1s;
    gap: 12px;
    border-bottom: 1px solid #f0f0f0;
}

.ofisearch-suggestion-product:last-child {
    border-bottom: none;
}

.ofisearch-suggestion-product:hover,
.ofisearch-suggestion-product.ofisearch-selected {
    background: var(--ofisearch-hover);
    text-decoration: none;
    color: var(--ofisearch-text);
}

.ofisearch-product-img {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 4px;
    overflow: hidden;
    background: #f5f5f5;
}

.ofisearch-product-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ofisearch-product-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ofisearch-product-name {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ofisearch-product-name strong {
    font-weight: 700;
    color: var(--ofisearch-primary);
}

.ofisearch-product-sku {
    font-size: 11px;
    color: var(--ofisearch-text-muted);
}

.ofisearch-product-sku strong {
    font-weight: 700;
    color: var(--ofisearch-primary);
}

.ofisearch-product-desc {
    font-size: 11px;
    color: var(--ofisearch-text-muted);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ofisearch-product-price {
    flex-shrink: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--ofisearch-text);
    white-space: nowrap;
}

.ofisearch-product-price del {
    font-weight: 400;
    color: var(--ofisearch-text-muted);
    font-size: 12px;
}

.ofisearch-product-price ins {
    text-decoration: none;
    color: #e74c3c;
}

/* More products link */
.ofisearch-more-products {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--ofisearch-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-top: 1px solid var(--ofisearch-border);
    gap: 4px;
}

.ofisearch-more-products:hover,
.ofisearch-more-products.ofisearch-selected {
    background: var(--ofisearch-hover);
    text-decoration: none;
    color: var(--ofisearch-primary);
}

.ofisearch-more-count {
    font-weight: 400;
    color: var(--ofisearch-text-muted);
}

/* No results */
.ofisearch-no-results {
    padding: 24px 16px;
    text-align: center;
    color: var(--ofisearch-text-muted);
    font-size: 14px;
}

/* ─── History ──────────────────────────────────────────────────── */
.ofisearch-history {
    padding: 4px 0;
}

.ofisearch-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
}

.ofisearch-history-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ofisearch-text-muted);
}

.ofisearch-history-clear {
    border: none;
    background: none;
    color: var(--ofisearch-primary);
    font-size: 11px;
    cursor: pointer;
    padding: 0;
}

.ofisearch-history-clear:hover {
    text-decoration: underline;
}

.ofisearch-history-item {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    gap: 8px;
    cursor: pointer;
    transition: background 0.1s;
    font-size: 13px;
    color: var(--ofisearch-text);
}

.ofisearch-history-item:hover {
    background: var(--ofisearch-hover);
}

.ofisearch-history-item svg {
    flex-shrink: 0;
    color: var(--ofisearch-text-muted);
}

/* ─── Background Overlay ───────────────────────────────────────── */
.ofisearch-bg-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
}

.ofisearch-bg-overlay.ofisearch-bg-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ─── Mobile Overlay ───────────────────────────────────────────── */
.ofisearch-mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--ofisearch-bg);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.25s ease;
}

.ofisearch-mobile-overlay.ofisearch-mobile-active {
    transform: translateY(0);
}

.ofisearch-body-overlay {
    overflow: hidden !important;
}

.ofisearch-mobile-header {
    display: flex;
    align-items: center;
    padding: 8px;
    gap: 8px;
    border-bottom: 1px solid var(--ofisearch-border);
    background: var(--ofisearch-bg);
    flex-shrink: 0;
}

.ofisearch-mobile-back {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--ofisearch-text);
    cursor: pointer;
    padding: 0;
}

.ofisearch-mobile-input-wrapp {
    flex: 1;
}

.ofisearch-mobile-input {
    width: 100%;
    border: 1px solid var(--ofisearch-border) !important;
    border-radius: var(--ofisearch-radius);
    padding: 10px 12px;
    font-size: 16px; /* Prevent zoom on iOS */
    line-height: 1.4;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.ofisearch-mobile-input:focus {
    border-color: var(--ofisearch-primary) !important;
}

.ofisearch-mobile-results {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.ofisearch-mobile-results .ofisearch-suggestion-product {
    padding: 12px 16px;
}

.ofisearch-mobile-results .ofisearch-product-img {
    width: 56px;
    height: 56px;
}

/* Mobile trigger button (appears in Astra header on mobile) */
.ofisearch-mobile-trigger {
    display: none;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    padding: 4px;
}

/* ─── Solaris Theme specific ───────────────────────────────────── */
.ofisearch-style-solaris .ofisearch-sf-wrapp {
    border-radius: 24px;
    border-color: #e0e0e0;
}

.ofisearch-style-solaris .ofisearch-sf-wrapp:focus-within {
    box-shadow: 0 1px 6px rgba(32, 33, 36, 0.28);
    border-color: transparent;
}

.ofisearch-style-solaris .ofisearch-input {
    padding: 10px 8px;
}

.ofisearch-style-solaris .ofisearch-submit {
    border-radius: 0 24px 24px 0;
    padding: 8px 18px;
}

.ofisearch-style-solaris .ofisearch-suggestions {
    border-radius: 0 0 16px 16px;
    margin-top: 4px;
    border: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

/* ─── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
    .ofisearch-product-desc {
        display: none;
    }

    .ofisearch-product-price {
        font-size: 13px;
    }
}

/* ─── Astra-specific fixes ─────────────────────────────────────── */
.ast-search-menu-icon .ofisearch-wrapp {
    max-width: none;
}

.ast-dropdown-active .ofisearch-wrapp {
    width: 100%;
}

/* Ensure Astra header search doesn't overflow */
.site-header .ofisearch-wrapp {
    z-index: 10000;
}

.site-header .ofisearch-suggestions {
    z-index: 100001;
}

/* Fix for Astra search box padding */
.ast-search-menu-icon .ofisearch-form {
    margin: 0;
    padding: 0;
}

/* WooCommerce price styles in suggestions */
.ofisearch-product-price .woocommerce-Price-amount {
    color: inherit;
    font-size: inherit;
}

.ofisearch-product-price .woocommerce-Price-currencySymbol {
    font-size: inherit;
}
