/**
 * Search Plus WP - Frontend Styles
 * Modern 2025 Minimal Design
 */

/* ========================================
   Search Field Styles - Minimal Design
   ======================================== */

.spwp-search-container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
}

.spwp-search-field {
    width: 450px;
    padding: 8px 20px;
    font-size: 16px;
    color: #111;
    background-color: #f8f9fa;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s ease;
    box-shadow: none;
    /* No shadow as per requirements */
}


.spwp-search-field:focus-visible {
    outline: none !important;
    border: 1px solid #e8e8e8 !important;
}

.spwp-search-field::placeholder {
    color: #999999;
    opacity: 1;
}

.spwp-search-field:hover {
    background: #f1f1f1;
    color: #132507;
}

/* ========================================
   Results Container - Modern 2025 Design
   ======================================== */

.spwp-results-container {
    width: 100%;
    max-width: 600px;
    margin: 4px auto 0;
    /* Reduced top margin for better feel */
    background-color: #ffffff;
    border: 1px solid #e8e8e8;
    border-radius: 12px;
    overflow: hidden;
    display: none;
    /* Hidden by default */

    /* Absolute Positioning Fix */
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    /* Added shadow for better visibility */
}

.spwp-results-container.spwp-has-results {
    display: block;
}

.spwp-results-wrapper {
    max-height: 500px;
    overflow-y: auto;
    padding: 8px 0;
}

/* Custom scrollbar for modern look */
.spwp-results-wrapper::-webkit-scrollbar {
    width: 6px;
}

.spwp-results-wrapper::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.spwp-results-wrapper::-webkit-scrollbar-thumb {
    background: #d0d0d0;
    border-radius: 3px;
}

.spwp-results-wrapper::-webkit-scrollbar-thumb:hover {
    background: #b0b0b0;
}

/* ========================================
   Results Grouping and Headers
   ======================================== */

.spwp-result-group {
    margin-bottom: 4px;
}

.spwp-result-group:last-child {
    margin-bottom: 0;
}

.spwp-group-header {
    padding: 12px 20px 8px;
    font-size: 13px;
    font-weight: 600;
    color: #666666;
    text-transform: none;
    letter-spacing: 0;
    background-color: #fafafa;
    border-bottom: 1px solid #f0f0f0;
}

/* ========================================
   Individual Result Items
   ======================================== */

.spwp-result-item {
    padding: 12px 20px;
    border-bottom: 1px solid #f5f5f5;
    transition: background-color 0.15s ease;
}

.spwp-result-item:last-child {
    border-bottom: none;
}

.spwp-result-item:hover {
    background-color: #f9f9f9;
}

.spwp-result-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.spwp-result-title {
    font-size: 15px;
    font-weight: 500;
    color: #1a1a1a;
    margin: 0 0 4px 0;
    line-height: 1.4;
}

.spwp-result-price {
    font-size: 14px;
    font-weight: 600;
    color: #FF4D4D;
    margin: 4px 0 0 0;
}

/* ========================================
   "View More" Button
   ======================================== */

.spwp-view-more {
    display: block;
    width: 100%;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    color: #FF4D4D;
    background-color: #f8f9fa;
    border: none;
    border-top: 1px solid #f0f0f0;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.spwp-view-more:hover {
    background-color: #f0f2f5;
    color: #FF4D4D;
}

.spwp-view-more:active {
    background-color: #e8eaed;
}

/* ========================================
   Empty State and Messages
   ======================================== */

.spwp-no-results {
    padding: 32px 20px;
    text-align: center;
    color: #999999;
    font-size: 14px;
}

.spwp-loading {
    padding: 32px 20px;
    text-align: center;
    color: #999999;
    font-size: 14px;
}

.spwp-error {
    padding: 16px 20px;
    background-color: #fff5f5;
    color: #d32f2f;
    font-size: 14px;
    border-radius: 8px;
    margin: 12px 0;
}

/* ========================================
   Responsive Design - Mobile
   ======================================== */

@media screen and (max-width: 768px) {
    .spwp-search-container {
        max-width: 100%;
        padding: 0 16px;
    }

    .spwp-results-container {
        max-width: 100%;
        margin-left: 16px;
        margin-right: 16px;
        border-radius: 10px;
    }

    .spwp-search-field {
        width: 100%;
        padding: 12px 16px;
        font-size: 16px;
        /* Prevent zoom on iOS */
    }

    .spwp-results-wrapper {
        max-height: 400px;
    }

    .spwp-group-header {
        padding: 10px 16px 6px;
        font-size: 12px;
    }

    .spwp-result-item {
        padding: 10px 16px;
    }

    .spwp-result-title {
        font-size: 14px;
    }

    .spwp-result-price {
        font-size: 13px;
    }

    .spwp-view-more {
        padding: 10px 16px;
        font-size: 13px;
    }
}

@media screen and (max-width: 480px) {
    .spwp-search-container {
        padding: 0 12px;
    }

    .spwp-results-container {
        margin-left: 12px;
        margin-right: 12px;
        border-radius: 8px;
    }

    .spwp-search-field {
        padding: 10px 14px;
    }

    .spwp-results-wrapper {
        max-height: 350px;
    }

    .spwp-group-header {
        padding: 8px 14px 6px;
    }

    .spwp-result-item {
        padding: 8px 14px;
    }
}

/* ========================================
   RTL Support for Persian/Arabic
   ======================================== */

[dir="rtl"] .spwp-search-field,
[dir="rtl"] .spwp-results-container,
[dir="rtl"] .spwp-group-header,
[dir="rtl"] .spwp-result-item {
    text-align: right;
    direction: rtl;
}

/* ========================================
   Accessibility
   ======================================== */

.spwp-search-field:focus-visible {
    outline: 2px solid #111;
    outline-offset: 2px;
}

.spwp-result-link:focus-visible {
    outline: 2px solid #111;
    outline-offset: -2px;
}

.spwp-view-more:focus-visible {
    outline: 2px solid #111;
    outline-offset: -2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {

    .spwp-search-field,
    .spwp-result-item,
    .spwp-view-more {
        transition: none;
    }
}

/* ========================================
   Responsive Display Mode Styles
   ======================================== */

/* Base: Hide inline search and toggle by default */
.spwp-search-toggle {
    display: none;
    width: 43px;
    height: 43px;
    padding: 0;
    background-color: #ffffff;
    border: 0px solid #111;
    border-radius: 8px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s ease, background-color 0.2s ease;
    color: #111;
}

.spwp-search-toggle:hover {
    background: #F4F5EC;
}

.spwp-search-toggle:focus-visible {
    outline: 2px solid #111;
    outline-offset: 2px;
}

.spwp-inline-search {
    display: none;
}

/* ========================================
   Desktop Styles (>= 769px)
   ======================================== */

/* Desktop: Full mode - show inline search */
.spwp-desktop-full .spwp-inline-search {
    display: block;
}

.spwp-desktop-full .spwp-search-toggle {
    display: none;
}

/* Desktop: Icon mode - show toggle button */
.spwp-desktop-icon .spwp-search-toggle {
    display: flex;
}

.spwp-desktop-icon .spwp-inline-search {
    display: none;
}

/* ========================================
   Mobile Styles (<= 768px)
   ======================================== */

@media screen and (max-width: 768px) {

    /* Mobile: Full mode - show inline search, hide toggle */
    .spwp-mobile-full .spwp-inline-search {
        display: block;
    }

    .spwp-mobile-full .spwp-search-toggle {
        display: none;
    }

    /* Mobile: Icon mode - show toggle, hide inline */
    .spwp-mobile-icon .spwp-search-toggle {
        display: flex;
		background: #f1f1f1;
    }

    .spwp-mobile-icon .spwp-inline-search {
        display: none;
    }

    .spwp-search-toggle {
        width: 40px;
        height: 40px;
    }
}

@media screen and (max-width: 480px) {
    .spwp-search-toggle {
        width: 42px;
        height: 42px;
    }
}

/* ========================================
   Modal Overlay System
   ======================================== */

.spwp-search-modal {
    display: none !important;
    visibility: hidden;
    opacity: 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
}

.spwp-search-modal.spwp-modal-open {
    display: flex !important;
    visibility: visible;
    opacity: 1;
    align-items: center;
    justify-content: center;
}

/* Backdrop */
.spwp-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #000000d1;
    animation: spwp-fade-in 0.2s ease-out;
}

@keyframes spwp-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Modal Content - Desktop (Center Modal) */
.spwp-modal-content {
    position: relative;
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    background-color: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: spwp-scale-in 0.25s ease-out;
    z-index: 1;
}

@keyframes spwp-scale-in {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Modal Header */
.spwp-modal-header {
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
    direction: ltr;
}

.spwp-modal-title {
    font-size: 16px;
    font-weight: 600;
    color: #111;
}

.spwp-modal-close {
    width: 40px;
    height: 40px;
    padding: 0;
    background-color: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.spwp-modal-close:hover {
    background-color: #f5f5f5;
}

.spwp-modal-close:focus-visible {
    outline: 2px solid #111;
    outline-offset: -2px;
}

/* Modal Body */
.spwp-modal-body {
    padding: 16px 20px;
    flex: 1;
    overflow-y: auto;
}

/* Search Field in Modal */
.spwp-modal-body .spwp-search-field {
    margin-bottom: 12px;
}

/* Results in Modal */
.spwp-modal-body .spwp-results-container {
    position: static;
    margin: 0;
    max-width: 100%;
    box-shadow: none;
    border: 1px solid #e8e8e8;
}

/* ========================================
   Mobile - Bottom Sheet
   ======================================== */

/* Keyframe for slide up animation */
@keyframes spwp-slide-up {
    from {
        opacity: 0;
        transform: translateY(100%);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media screen and (max-width: 768px) {
    .spwp-search-modal.spwp-modal-open {
        align-items: flex-end !important;
        justify-content: center !important;
    }

    .spwp-modal-content {
        width: 100% !important;
        max-width: 100% !important;
        height: 90vh !important;
        border-radius: 20px 20px 0 0 !important;
        animation: spwp-slide-up 0.3s ease-out !important;
        margin: 0 !important;
    }

    .spwp-modal-header {
        padding: 12px 16px;
    }

    .spwp-modal-body {
        padding: 12px 16px 24px;
    }

    /* Drag Handle for Bottom Sheet */
    .spwp-modal-content::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background-color: #d0d0d0;
        border-radius: 2px;
        margin: 8px auto;
    }
}

@media screen and (max-width: 480px) {
    .spwp-modal-content {
        max-height: 70vh !important;
    }

    .spwp-modal-header {
        padding: 10px 14px;
    }

    .spwp-modal-body {
        padding: 10px 14px 20px;
    }
}

/* ========================================
   RTL Support for Modal
   ======================================== */

[dir="rtl"] .spwp-modal-header {
    flex-direction: row-reverse;
}