/* ==========================================================================
   SANMARG PRAKASHAN - FULL-SCREEN SEARCH MODAL & PRODUCT RESULTS
   Fully Mobile Responsive, Clean Proportions, Zero Viewport Breakout
   File: search-modal.css
   ========================================================================== */

:root {
    --sm-primary: var(--theme-color-1, #b42231);
    --sm-primary-hover: var(--theme-color-7, #c9262d);
    --sm-primary-light: rgba(180, 34, 49, 0.08);
    --sm-gold: #f4801f;
    --sm-dark: #0f172a;
    --sm-text: #1e293b;
    --sm-text-muted: #64748b;
    --sm-border: #e2e8f0;
    --sm-bg: #ffffff;
}

/* 1. Full-Screen Container */
.sanmarg-fullscreen-search {
    position: fixed;
    inset: 0;
    width: 100%;
    width: 100vw;
    height: 100%;
    height: 100vh;
    height: 100dvh;
    z-index: 100000;
    display: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.sanmarg-fullscreen-search.active {
    display: flex;
    flex-direction: column;
    opacity: 1;
    visibility: visible;
}

/* 2. Semi-transparent Backdrop Blur */
.search-fullscreen-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

/* 3. Inner Fullscreen Scrollable Wrapper */
.search-fullscreen-wrapper {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.search-fullscreen-wrapper::-webkit-scrollbar {
    width: 5px;
}

.search-fullscreen-wrapper::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}

/* 4. Top Search Row (Search Input + Close Icon) */
.search-fullscreen-header-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: max(14px, env(safe-area-inset-top)) 20px 14px;
    background: #ffffff;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.02);
}

.search-input-container {
    flex: 1;
    max-width: 820px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
    transition: all 0.2s ease;
}

.search-input-container:focus-within {
    background: #ffffff;
    border-color: var(--sm-primary);
    box-shadow: 0 0 0 3px rgba(180, 34, 49, 0.1), 0 4px 14px rgba(180, 34, 49, 0.06);
}

.search-hero-icon {
    font-size: 20px;
    color: var(--sm-primary);
    flex-shrink: 0;
}

.search-hero-input {
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    font-size: 15px;
    font-weight: 550;
    color: var(--sm-dark);
    line-height: 1.4;
}

.search-hero-input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.search-hero-clear {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: #e2e8f0;
    color: #64748b;
    font-size: 14px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.search-hero-clear:hover,
.search-hero-clear:active {
    background: var(--sm-primary);
    color: #ffffff;
}

.search-hero-clear.visible {
    display: inline-flex;
}

.search-fullscreen-close {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #475569;
    font-size: 22px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.search-fullscreen-close:hover,
.search-fullscreen-close:active {
    background: var(--sm-primary-light);
    color: var(--sm-primary);
    border-color: rgba(180, 34, 49, 0.2);
    transform: rotate(90deg);
}

/* 5. Content Area */
.search-fullscreen-content {
    flex: 1;
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 18px 20px 40px;
}

/* Loading State */
.search-modal-loading {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px 0;
    color: #64748b;
    font-size: 13.5px;
    font-weight: 600;
}

.search-modal-loading.active {
    display: flex;
}

.search-spinner {
    width: 26px;
    height: 26px;
    border: 3px solid #e2e8f0;
    border-top: 3px solid var(--sm-primary);
    border-radius: 50%;
    animation: searchFullSpin 0.7s linear infinite;
}

@keyframes searchFullSpin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* 6. Trending Searches Bar */
.search-tags-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f1f5f9;
}

.search-tags-heading {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 750;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
}

.search-tags-heading iconify-icon {
    color: #ea580c;
    font-size: 15px;
}

.search-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.search-quick-tag {
    padding: 6px 14px;
    border-radius: 999px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #334155;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
}

.search-quick-tag:hover,
.search-quick-tag:active {
    background: var(--sm-primary-light);
    border-color: var(--sm-primary);
    color: var(--sm-primary);
    transform: translateY(-1px);
}

/* 7. Popular Categories Section */
.search-category-section {
    margin-top: 10px;
}

.search-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.head-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.head-icon-chip {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(180, 34, 49, 0.1), rgba(244, 128, 31, 0.12));
    color: var(--sm-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.head-main-title {
    font-size: 15px;
    font-weight: 750;
    color: #0f172a;
    margin: 0;
    line-height: 1.25;
}

.head-subtitle {
    font-size: 12px;
    color: #64748b;
    margin: 2px 0 0;
}

.head-see-all-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 650;
    color: var(--sm-primary);
    text-decoration: none !important;
    padding: 5px 10px;
    border-radius: 8px;
    background: var(--sm-primary-light);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.head-see-all-btn:hover,
.head-see-all-btn:active {
    background: var(--sm-primary);
    color: #ffffff;
}

.search-category-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.search-cat-card {
    position: relative;
    display: block;
    background: #ffffff;
    border: 1px solid #e8ecf2;
    border-radius: 12px;
    padding: 12px 14px;
    text-decoration: none !important;
    overflow: hidden;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.02);
}

.search-cat-card .cat-card-accent {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--sm-primary), var(--sm-gold));
    opacity: 0;
    transform: scaleX(0);
    transform-origin: left center;
    transition: all 0.25s ease;
}

.search-cat-card:hover .cat-card-accent {
    opacity: 1;
    transform: scaleX(1);
}

.search-cat-card:hover,
.search-cat-card:active {
    border-color: rgba(180, 34, 49, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(180, 34, 49, 0.08);
}

.cat-card-body {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cat-icon-bubble {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #fdf4f5 0%, #fff7ed 100%);
    border: 1px solid rgba(180, 34, 49, 0.12);
    color: var(--sm-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.search-cat-card:hover .cat-icon-bubble {
    background: var(--sm-primary);
    color: #ffffff;
    transform: scale(1.05);
}

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

.cat-title {
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.search-cat-card:hover .cat-title {
    color: var(--sm-primary);
}

.cat-meta-action {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
}

.search-cat-card:hover .cat-meta-action {
    color: var(--sm-gold);
}

/* 8. Live Results Section */
.search-fullscreen-results-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f1f5f9;
}

.results-count-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.results-count-badge .count-num {
    background: var(--sm-primary);
    color: #ffffff;
    font-size: 11.5px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
}

.results-count-badge .count-label {
    font-size: 13px;
    font-weight: 750;
    color: #334155;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.results-all-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12.5px;
    font-weight: 650;
    color: var(--sm-primary);
    text-decoration: none !important;
}

.results-all-link:hover,
.results-all-link:active {
    color: var(--sm-primary-hover);
    transform: translateX(2px);
}

.search-fullscreen-products-row {
    margin-left: -8px;
    margin-right: -8px;
}

.search-fullscreen-products-row > [class*="col-"] {
    padding-left: 8px;
    padding-right: 8px;
}

.search-fullscreen-products-row .single-product {
    margin-bottom: 20px;
    height: 100%;
}

/* 9. Empty State */
.search-modal-empty {
    text-align: center;
    padding: 40px 16px;
    margin: 0 auto;
}

.empty-icon-wrap {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    margin: 0 auto 12px auto;
}

.empty-title {
    font-size: 15px;
    font-weight: 750;
    color: #1e293b;
    margin-bottom: 6px;
}

.empty-desc {
    font-size: 12.5px;
    color: #64748b;
    max-width: 440px;
    margin: 0 auto 16px auto;
    line-height: 1.5;
}

.empty-browse-btn {
    display: inline-flex;
    align-items: center;
    background: var(--sm-primary);
    color: #ffffff;
    font-size: 12.5px;
    font-weight: 700;
    padding: 8px 18px;
    border-radius: 999px;
    text-decoration: none !important;
    box-shadow: 0 4px 12px rgba(180, 34, 49, 0.22);
    transition: all 0.2s ease;
}

.empty-browse-btn:hover,
.empty-browse-btn:active {
    background: var(--sm-primary-hover);
    color: #ffffff;
    transform: translateY(-1px);
}

/* 10. Fullscreen Footer Bar */
.search-fullscreen-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px max(14px, env(safe-area-inset-bottom));
    background: #f8fafc;
    border-top: 1px solid #f1f5f9;
    flex-shrink: 0;
}

.search-footer-info {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 12px;
    color: #64748b;
}

.search-footer-info kbd {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    color: #334155;
    font-size: 10.5px;
    font-weight: 700;
    padding: 2px 6px;
    margin-right: 3px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
}

.search-footer-catalog-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 650;
    color: var(--sm-primary);
    text-decoration: none !important;
    transition: transform 0.18s ease;
}

.search-footer-catalog-link:hover,
.search-footer-catalog-link:active {
    color: var(--sm-primary-hover);
    transform: translateX(2px);
}

/* ==========================================================================
   RESPONSIVE OPTIMIZATIONS (TABLET & MOBILE)
   ========================================================================== */

@media (max-width: 991px) {
    .search-category-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    .search-fullscreen-content {
        padding: 14px 16px 30px;
    }
}

@media (max-width: 768px) {
    .search-fullscreen-header-row {
        padding: max(10px, env(safe-area-inset-top)) 12px 10px;
        gap: 8px;
    }

    .search-input-container {
        padding: 8px 12px;
        border-radius: 12px;
    }

    .search-hero-icon {
        font-size: 18px;
    }

    .search-hero-input {
        font-size: 16px; /* Crucial: Prevents iOS Safari from auto-zooming! */
    }

    .search-hero-input::placeholder {
        font-size: 13.5px;
    }

    .search-fullscreen-close {
        width: 38px;
        height: 38px;
        font-size: 20px;
    }

    .search-fullscreen-content {
        padding: 12px 12px 30px;
    }

    /* 2 Columns on Mobile for Popular Categories */
    .search-category-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .search-cat-card {
        padding: 9px 10px;
        border-radius: 10px;
    }

    .cat-icon-bubble {
        width: 32px;
        height: 32px;
        font-size: 16px;
        border-radius: 8px;
    }

    .cat-title {
        font-size: 12px;
    }

    .cat-meta-action {
        font-size: 10px;
    }

    .head-main-title {
        font-size: 13.5px;
    }

    .head-subtitle {
        display: none; /* Hide subtitle on mobile to save vertical space */
    }

    .head-icon-chip {
        width: 30px;
        height: 30px;
        font-size: 16px;
        border-radius: 8px;
    }

    .head-see-all-btn {
        padding: 4px 8px;
        font-size: 11px;
    }

    .search-tags-heading {
        font-size: 10.5px;
    }

    .search-quick-tag {
        padding: 5px 12px;
        font-size: 12px;
    }

    /* Hide keyboard shortcuts on touch devices */
    .search-footer-info {
        display: none;
    }

    .search-fullscreen-footer {
        padding: 10px 14px max(12px, env(safe-area-inset-bottom));
        justify-content: center;
    }

    .search-footer-catalog-link {
        width: 100%;
        justify-content: center;
        padding: 9px 14px;
        background: #ffffff;
        border: 1px solid #e2e8f0;
        border-radius: 8px;
        font-size: 12.5px;
        font-weight: 650;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
    }
}

@media (max-width: 480px) {
    .search-fullscreen-header-row {
        padding: max(8px, env(safe-area-inset-top)) 10px 8px;
    }

    .search-input-container {
        padding: 7px 10px;
    }

    .search-fullscreen-close {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    .search-fullscreen-content {
        padding: 10px 8px 24px;
    }

    .search-category-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .search-cat-card {
        padding: 8px;
        border-radius: 8px;
    }

    .cat-card-body {
        gap: 8px;
    }

    .cat-icon-bubble {
        width: 28px;
        height: 28px;
        font-size: 15px;
        border-radius: 6px;
    }

    .cat-title {
        font-size: 11.5px;
    }

    .search-fullscreen-products-row {
        margin-left: -5px;
        margin-right: -5px;
    }

    .search-fullscreen-products-row > [class*="col-"] {
        padding-left: 5px;
        padding-right: 5px;
    }
}
