/* Search Modal Styles */
/* New Search Modal Styles */
.search-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4); 
    backdrop-filter: blur(3px);
    z-index: 999999;
    display: flex;
    align-items: center; /* Centered as requested */
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

.search-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.search-modal-content {
    background: #fff;
    width: 95%;
    max-width: 580px;
    border-radius: 8px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.15);
    overflow: hidden;
    opacity: 0; /* Star hidden */
    transform: scale(0.95) translateY(10px); /* Start slightly down and scaled */
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease; /* Smooth spring-like effect */
}

.search-modal-overlay.active .search-modal-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.search-modal-header {
    display: flex;
    align-items: center;
    padding: 5px 10px; /* Reduced padding as requested */
    border-bottom: 1px solid #f2f2f2;
    gap: 5px;
}

.search-modal-input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 5px; /* Minimal padding */
}

#search-modal-input {
    width: 100%;
    height: 36px; /* Slightly more compact */
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 500;
    color: #444;
    outline: none !important;
}

#search-modal-input::placeholder {
    color: #c0c0c0;
}

.search-modal-header .close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #d0d0d0;
    padding: 4px;
    display: flex;
    transition: none !important;
}

.search-modal-body {
    max-height: 60vh;
    overflow-y: auto;
    padding: 12px 15px;
}

.search-results-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Category Stories Style */
.search-modal-categories-wrap {
    margin-bottom: 20px;
    padding-bottom: 5px;
    border-bottom: 1px solid #f8f8f8;
    overflow-x: auto;
    scrollbar-width: none; /* Hide scrollbar Firefox */
    -ms-overflow-style: none;  /* Hide scrollbar IE/Edge */
}

.search-modal-categories-wrap::-webkit-scrollbar {
    display: none; /* Hide scrollbar Chrome/Safari */
}

.search-modal-categories-list {
    display: flex;
    gap: 12px;
    padding: 5px 2px;
    flex-wrap: nowrap;
}

.search-cat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: calc(25% - 9px); /* Shows exactly 4 per row with 12px gap */
    width: calc(25% - 9px);
    text-decoration: none !important;
    transition: none !important;
    flex-shrink: 0;
}

.search-cat-img-inner {
    width: 100%;
    aspect-ratio: 1/1;
    border-radius: 12px;
    padding: 3px;
    border: 1.5px solid rgba(0, 0, 0, 0.08);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: none !important;
    overflow: hidden;
}

.search-cat-img-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
    transition: none !important;
}

.search-cat-name {
    font-size: 11px;
    font-weight: 700;
    color: #444;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Remove hover effects for categories */
.search-cat-item:hover .search-cat-img-inner,
.search-cat-item:hover img {
    transform: none !important;
}

.search-result-item {
    display: flex;
    align-items: center;
    text-decoration: none !important;
    color: inherit;
    padding: 6px 0; /* Reduced padding */
    border-bottom: 1px solid #f0f0f0;
    transition: none !important;
    direction: inherit;
}

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

.result-item-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1; /* This takes up available space, but we need to control where text starts */
}

.result-image {
    width: 45px;
    height: 45px;
    min-width: 45px;
    border-radius: 8px;
    overflow: hidden;
    background: #fdfdfd;
}

.result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: none !important;
}

.result-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* In RTL adjacent to image this is 'start' of the remaining space */
    text-align: left;
}

.result-title {
    font-size: 13px;
    font-weight: 600;
    margin: 0 0 2px 0;
    line-height: 1.3;
    color: #2c2c2c;
}

.result-item-right {
    margin-left: auto;
    padding-left: 5px;
}

.result-price {
    display: flex;
    align-items: center;
    gap: 8px;
    direction: inherit;
}

.regular-price {
    font-size: 10px;
    color: #ff0000 !important;
    text-decoration: line-through !important;
    font-weight: 500;
}

.sale-price {
    font-size: 12.5px;
    font-weight: 800;
    color: #000 !important;
    text-decoration: none !important;
    font-family: Arial, sans-serif !important;
}

.result-cart-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #dddddd;
}

.result-cart-icon svg {
    width: 17px;
    height: 17px;
}

.search-modal-footer {
    text-align: center;
    padding: 8px 0;
}

.search-show-more-btn {
    background: #fbfbfb;
    border: none;
    color: #999;
    font-size: 10.5px;
    font-weight: 600;
    padding: 7px 16px;
    border-radius: 20px;
    cursor: pointer;
}

.search-show-more-btn:hover {
    background: #f2f2f2;
}

.search-loader {
    display: flex;
    justify-content: center;
    padding: 15px;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(0,0,0,0.05);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.search-no-results {
    text-align: center;
    padding: 30px 15px;
    color: #888;
    font-size: 13px;
}

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

body.search-modal-open {
    overflow: hidden;
}

@media (max-width: 768px) {
    .search-modal-overlay {
        padding: 5px !important; /* Crucial: Reduce overlay padding */
        padding-top: 10px !important;
    }
    .search-modal-content {
        width: 100% !important; 
        max-width: 100% !important;
        margin: 0 !important;
        max-height: 92vh;
        border-radius: 8px !important;
    }
    .result-image {
        width: 42px;
        height: 42px;
        min-width: 42px;
    }
    .result-info {
        gap: 2px;
    }
    .search-modal-header {
        padding: 5px 8px;
    }
    #search-modal-input {
        font-size: 13px;
    }
}
