/**
 * Yonis Search - Styles Mobile-First Premium
 */

:root {
    --ys-primary: #ff4a00;
    --ys-primary-hover: #e04100;
    --ys-text-main: #1e293b;
    --ys-text-muted: #64748b;
    --ys-bg-card: #ffffff;
    --ys-border: #e2e8f0;
    --ys-success: #10b981;
    --ys-radius: 12px;
    --ys-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --ys-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Layer Base */
.ys_layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    font-family: var(--ys-font);
    color: var(--ys-text-main);
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

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

/* Backdrop */
.ys_backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.ys_layer.ys_open .ys_backdrop {
    opacity: 1;
}

/* Modal Box */
.ys_modal_wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    opacity: 0;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
    overflow: hidden;
}

.ys_layer.ys_open .ys_modal_wrapper {
    transform: translateY(0);
    opacity: 1;
}

/* Header */
.ys_header {
    background: #ffffff;
    border-bottom: 1px solid var(--ys-border);
    padding: 12px 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    flex-shrink: 0;
}

.ys_header_inner {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ys_input_box {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    background: #f1f5f9;
    border: 2px solid transparent;
    border-radius: var(--ys-radius);
    padding: 0 14px;
    height: 48px;
    transition: all 0.2s ease;
}

.ys_input_box:focus-within {
    background: #ffffff;
    border-color: var(--ys-primary);
    box-shadow: 0 0 0 3px rgba(255, 74, 0, 0.15);
}

.ys_search_icon {
    display: flex;
    align-items: center;
    color: var(--ys-text-muted);
    margin-right: 10px;
}

.ys_input {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    font-size: 16px;
    color: var(--ys-text-main);
    outline: none;
    font-weight: 500;
}

.ys_input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.ys_clear_btn {
    border: none;
    background: #cbd5e1;
    color: #475569;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: background 0.15s ease;
}

.ys_clear_btn:hover {
    background: #94a3b8;
}

.ys_spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid #e2e8f0;
    border-top-color: var(--ys-primary);
    border-radius: 50%;
    animation: ys_spin 0.6s linear infinite;
    margin-left: 8px;
}

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

.ys_close_btn {
    border: none;
    background: #f1f5f9;
    color: #475569;
    width: 44px;
    height: 44px;
    border-radius: var(--ys-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.ys_close_btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

/* Suggestion Pills */
.ys_suggestions_scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 10px;
    padding-bottom: 2px;
    scrollbar-width: none;
}

.ys_suggestions_scroll::-webkit-scrollbar {
    display: none;
}

.ys_pills_container {
    display: flex;
    gap: 8px;
    white-space: nowrap;
}

.ys_pill {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ys_pill:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.ys_pill.ys_active {
    background: #ffede6;
    color: var(--ys-primary);
    border-color: rgba(255, 74, 0, 0.3);
    font-weight: 600;
}

/* Mobile Action Bar */
.ys_mobile_action_bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: #ffffff;
    border-bottom: 1px solid var(--ys-border);
}

.ys_mobile_btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #f1f5f9;
    border: 1px solid var(--ys-border);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
}

.ys_badge_count {
    background: var(--ys-primary);
    color: #ffffff;
    font-size: 11px;
    font-weight: bold;
    border-radius: 10px;
    padding: 2px 6px;
}

.ys_sort_select {
    padding: 8px 12px;
    border: 1px solid var(--ys-border);
    background: #ffffff;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #334155;
    outline: none;
    cursor: pointer;
}

/* Body Container */
.ys_body {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* Sidebar Drawer (Mobile First) */
.ys_sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 85%;
    max-width: 320px;
    height: 100%;
    background: #ffffff;
    z-index: 100;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.ys_sidebar.ys_sidebar_open {
    transform: translateX(0);
}

.ys_sidebar_header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--ys-border);
}

.ys_sidebar_header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.ys_sidebar_close_btn {
    border: none;
    background: none;
    font-size: 20px;
    color: var(--ys-text-muted);
    cursor: pointer;
}

.ys_sidebar_content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.ys_sidebar_footer {
    padding: 14px 20px calc(14px + env(safe-area-inset-bottom, 12px)) 20px;
    border-top: 1px solid var(--ys-border);
    background: #f8fafc;
    position: relative;
    z-index: 20;
}

.ys_apply_btn {
    width: 100%;
    padding: 12px;
    background: var(--ys-primary);
    color: #ffffff;
    border: none;
    border-radius: var(--ys-radius);
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(255, 74, 0, 0.25);
}

/* Facet Groups */
.ys_facet_group {
    margin-bottom: 24px;
}

.ys_facet_title {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #475569;
    margin-bottom: 12px;
}

.ys_facet_list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
}

.ys_facet_item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    color: #334155;
    cursor: pointer;
    padding: 4px 0;
}

.ys_facet_item label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    margin: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ys_facet_count {
    color: #94a3b8;
    font-size: 12px;
    font-weight: 500;
}

/* Toggle Switch (En stock) */
.ys_toggle_label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    margin: 0;
}

.ys_toggle_label input {
    display: none;
}

.ys_toggle_switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: #cbd5e1;
    border-radius: 12px;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.ys_toggle_switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #ffffff;
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.ys_toggle_label input:checked + .ys_toggle_switch {
    background: var(--ys-success);
}

.ys_toggle_label input:checked + .ys_toggle_switch::after {
    transform: translateX(20px);
}

.ys_toggle_text {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
}

/* Price Range Inputs */
.ys_price_range_inputs {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ys_price_box {
    flex: 1;
    position: relative;
}

.ys_price_box span {
    position: absolute;
    top: 2px;
    left: 8px;
    font-size: 10px;
    color: #94a3b8;
    text-transform: uppercase;
}

.ys_price_box input {
    width: 100%;
    padding: 16px 8px 4px 8px;
    border: 1px solid var(--ys-border);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #0f172a;
    outline: none;
}

.ys_price_apply_btn {
    padding: 10px 14px;
    background: #0f172a;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.ys_reset_btn {
    width: 100%;
    padding: 8px;
    background: #f1f5f9;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    color: #ef4444;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

/* Results Container */
.ys_results_container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.ys_meta_bar {
    display: none; /* Desktop only */
}

/* Product Grid (Mobile First: 2 columns) */
.ys_products_grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

/* Product Card */
.ys_card {
    background: #ffffff;
    border: 1px solid var(--ys-border);
    border-radius: var(--ys-radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.ys_card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
    border-color: #cbd5e1;
}

.ys_card_img_wrap {
    position: relative;
    width: 100%;
    padding-top: 100%; /* 1:1 Aspect Ratio */
    background: #f8fafc;
    overflow: hidden;
}

.ys_card_img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px;
    transition: transform 0.3s ease;
}

.ys_card:hover .ys_card_img {
    transform: scale(1.05);
}

.ys_stock_badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.ys_stock_in {
    background: rgba(16, 185, 129, 0.9);
    color: #ffffff;
}

.ys_stock_out {
    background: rgba(148, 163, 184, 0.9);
    color: #ffffff;
}

.ys_card_details {
    padding: 10px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.ys_card_cat {
    font-size: 11px;
    color: var(--ys-text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ys_card_title {
    font-size: 13px;
    line-height: 1.35;
    font-weight: 600;
    color: #0f172a;
    margin: 0 0 8px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 35px;
}

.ys_card_bottom {
    margin-top: auto;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}

.ys_card_price {
    font-size: 16px;
    font-weight: 800;
    color: #0f172a;
}

/* Empty State */
.ys_empty_state {
    text-align: center;
    padding: 40px 20px;
    margin: auto;
    max-width: 480px;
}

.ys_empty_icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.ys_empty_title {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 8px;
}

.ys_empty_sub {
    font-size: 14px;
    color: var(--ys-text-muted);
    margin-bottom: 24px;
}

.ys_empty_pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.ys_empty_pill {
    padding: 8px 16px;
    background: #ffffff;
    border: 1px solid var(--ys-border);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ys_empty_pill:hover {
    border-color: var(--ys-primary);
    color: var(--ys-primary);
    background: #fff6f2;
}

/* Load More */
.ys_load_more_wrapper {
    text-align: center;
    padding: 24px 0;
}

.ys_load_more_btn {
    padding: 12px 28px;
    background: #ffffff;
    border: 2px solid var(--ys-primary);
    color: var(--ys-primary);
    border-radius: var(--ys-radius);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ys_load_more_btn:hover {
    background: var(--ys-primary);
    color: #ffffff;
}

/* ==========================================================================
   DESKTOP ADAPTATION (>= 992px)
   ========================================================================== */
@media (min-width: 992px) {
    .ys_modal_wrapper {
        margin: 30px auto;
        width: 94%;
        max-width: 1400px;
        height: calc(100vh - 60px);
        border-radius: 16px;
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
    }

    .ys_mobile_action_bar {
        display: none;
    }

    .ys_sidebar {
        position: static;
        width: 280px;
        height: 100%;
        box-shadow: none;
        border-right: 1px solid var(--ys-border);
        transform: none;
        flex-shrink: 0;
    }

    .ys_sidebar_header, .ys_sidebar_footer {
        display: none;
    }

    .ys_meta_bar {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-bottom: 16px;
        margin-bottom: 16px;
        border-bottom: 1px solid var(--ys-border);
    }

    .ys_total_text {
        font-size: 15px;
        font-weight: 700;
        color: #334155;
    }

    .ys_desktop_sort {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .ys_products_grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }

    .ys_card_title {
        font-size: 14px;
        height: 38px;
    }

    .ys_card_price {
        font-size: 18px;
    }
}

@media (min-width: 1280px) {
    .ys_products_grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }
}
