:root {
    --afm-primary: #0052cc;
    --afm-primary-hover: #003d99;
    --afm-bg: #f8fafc;
    --afm-surface: #ffffff;
    --afm-text: #1e293b;
    --afm-text-light: #64748b;
    --afm-border: #e2e8f0;
    --afm-radius: 16px;
    --afm-shadow: 0 10px 40px -10px rgba(0,0,0,0.1);
    --afm-shadow-hover: 0 20px 40px -10px rgba(0,82,204,0.15);
}

/* اعمال قطعی فونت پیش‌فرض سایت روی تمام اجزای سرچ باکس */
.afm-modal, .afm-modal * {
    font-family: inherit !important;
}

/* دکمه باز کننده */
.afm-open-search-btn {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--afm-surface); color: var(--afm-text);
    border: 1px solid var(--afm-border); padding: 12px 24px;
    border-radius: 50px; font-size: 15px; font-weight: 500;
    cursor: pointer; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    font-family: inherit; /* ارث‌بری فونت */
}
.afm-open-search-btn:hover {
    border-color: var(--afm-primary); color: var(--afm-primary);
    transform: translateY(-2px); box-shadow: var(--afm-shadow);
}

/* مُدال تمام صفحه (Glassmorphism) */
.afm-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.6); z-index: 999999;
    display: flex; justify-content: center; align-items: flex-start;
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    opacity: 0; animation: afmFadeIn 0.3s forwards;
    font-family: inherit; /* ارث‌بری فونت */
}
@keyframes afmFadeIn { to { opacity: 1; } }

/* --- ارتقای ظاهر کلی مدال (شیشه‌ای و پریمیوم) --- */
.afm-modal-content {
    width: 95%; 
    max-width: 1100px; 
    background: rgba(255, 255, 255, 0.98); /* بک‌گراند کمی شفاف */
    backdrop-filter: blur(20px); 
    -webkit-backdrop-filter: blur(20px);
    margin-top: 5vh; 
    border-radius: 24px; /* گوشه‌های نرم‌تر */
    overflow: hidden; 
    display: flex; 
    flex-direction: column; 
    max-height: 85vh;
    box-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.5) inset;
    border: 1px solid rgba(226, 232, 240, 0.8);
    transform: translateY(-30px) scale(0.98); 
    animation: afmSlideDownPremium 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    font-family: inherit; /* ارث‌بری فونت */
}

@keyframes afmSlideDownPremium { 
    to { transform: translateY(0) scale(1); opacity: 1; } 
}

/* --- بهبود هدر جستجو --- */
.afm-search-header {
    display: flex; 
    align-items: center; 
    padding: 20px 30px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.6); 
    background: transparent; 
    gap: 15px;
    font-family: inherit; /* ارث‌بری فونت */
}

/* کنترل ابعاد دقیق ذره‌بین */
.afm-search-icon {
    width: 24px !important; 
    height: 24px !important;
    min-width: 24px;
    flex-shrink: 0; /* جلوگیری از تغییر سایز ناخواسته */
    color: #94a3b8;
}

/* --- ارتقای ظاهر فیلد ورودی --- */
#afm-search-input {
    flex-grow: 1; 
    border: none; 
    background: transparent; 
    font-size: 22px; /* فونت بزرگ‌تر و خواناتر */
    padding: 15px 0; 
    outline: none; 
    color: var(--afm-text); 
    font-weight: 600;
    width: 100%; 
    transition: all 0.3s ease;
    font-family: inherit; /* ارث‌بری فونت */
}
#afm-search-input::placeholder { 
    color: #94a3b8; 
    font-weight: 400; 
    font-size: 18px; 
    font-family: inherit; /* ارث‌بری فونت */
}

#afm-clear-btn {
    background: #f1f5f9; border: none; width: 32px; height: 32px; border-radius: 50%;
    font-size: 18px; color: var(--afm-text-light); cursor: pointer;
    flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    font-family: inherit; /* ارث‌بری فونت */
}

/* --- دکمه بستن مینیمال با افکت چرخشی جذاب --- */
#afm-close-modal {
    background: var(--afm-surface); 
    border: 1px solid var(--afm-border);
    width: 44px; 
    height: 44px; 
    border-radius: 50%; /* دایره‌ای شدن کامل دکمه */
    display: flex; 
    align-items: center; 
    justify-content: center;
    color: var(--afm-text-light); 
    cursor: pointer; 
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1); /* ترانزیشن نرم‌تر */
    flex-shrink: 0; 
    padding: 0; 
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

#afm-close-modal:hover { 
    background: #fee2e2; 
    color: #ef4444; 
    border-color: #fca5a5; 
    transform: rotate(90deg) scale(1.05); /* افکت چرخش هنگام قرار گرفتن موس */
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.2);
}

/* استاتوس هوش مصنوعی */
.afm-status-message {
    padding: 12px 25px; font-size: 14px; font-weight: 500; border-bottom: 1px solid var(--afm-border);
    font-family: inherit; /* ارث‌بری فونت */
}
.ai-processing { background: #f0fdf4; color: #166534; display: flex; align-items: center; gap: 8px; font-family: inherit; }
.ai-success { background: #eff6ff; color: #1e40af; font-family: inherit; }
.pulse { display: inline-block; width: 8px; height: 8px; background: #22c55e; border-radius: 50%; box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); animation: afmPulse 1.5s infinite; }
@keyframes afmPulse { 70% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); } }

/* گرید نتایج */
.afm-results-grid { display: flex; flex-direction: row; overflow-y: auto; flex-grow: 1; background: var(--afm-bg); font-family: inherit; }
.afm-sidebar { width: 28%; background: var(--afm-surface); padding: 25px; border-left: 1px solid var(--afm-border); font-family: inherit; }
.afm-main-content { width: 72%; padding: 25px; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; align-content: start; font-family: inherit; }

/* سایدبار (تاکسونومی‌ها) */
.afm-sidebar h3 { font-size: 13px; color: var(--afm-text-light); text-transform: uppercase; margin: 0 0 12px 0; font-family: inherit; }
.afm-tax-list { list-style: none; padding: 0; margin: 0 0 25px 0; font-family: inherit; }
.afm-tax-list li a {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 15px; background: var(--afm-bg); color: var(--afm-text);
    border-radius: 8px; margin-bottom: 8px; text-decoration: none; font-size: 14px;
    font-weight: 500; transition: 0.2s; border: 1px solid transparent;
    font-family: inherit; /* ارث‌بری فونت */
}
.afm-tax-list li a:hover { background: #eff6ff; color: var(--afm-primary); border-color: #bfdbfe; transform: translateX(-4px); }

/* کارت محصول (سه‌بعدی مدرن) */
.afm-product-card {
    background: var(--afm-surface); border: 1px solid var(--afm-border);
    border-radius: var(--afm-radius); padding: 12px; text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); display: flex; flex-direction: column;
    font-family: inherit; /* ارث‌بری فونت */
}
.afm-product-card:hover { border-color: #cbd5e1; transform: translateY(-5px); box-shadow: var(--afm-shadow-hover); }
.afm-img-wrapper { position: relative; width: 100%; height: 180px; background: var(--afm-bg); border-radius: 12px; overflow: hidden; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.afm-product-card img { width: 100%; height: 100%; object-fit: contain; padding: 10px; mix-blend-mode: multiply; }
.afm-badge { position: absolute; top: 10px; right: 10px; padding: 4px 10px; border-radius: 50px; font-size: 11px; font-weight: bold; font-family: inherit; }
.afm-badge.in-stock { background: #dcfce7; color: #166534; }
.afm-badge.out-stock { background: #fee2e2; color: #991b1b; }
.afm-prod-info h4 { font-size: 14px; margin: 0 0 8px; line-height: 1.6; color: var(--afm-text); font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-family: inherit; }
.afm-price { font-weight: 700; color: var(--afm-primary); font-size: 16px; margin-top: auto; font-family: inherit; }

/* باکس محصول پیدا نشد + دکمه اسنپ پی */
.afm-no-res-box { grid-column: 1 / -1; text-align: center; padding: 50px 20px; background: var(--afm-surface); border-radius: var(--afm-radius); border: 1px dashed #cbd5e1; font-family: inherit; }
.afm-no-res-box h3 { font-size: 20px; color: var(--afm-text); margin: 15px 0 10px; font-weight:bold; font-family: inherit;}
.afm-no-res-box p { color: var(--afm-text-light); font-size: 15px; margin-bottom: 25px; line-height: 1.8; font-family: inherit; }
.afm-snapp-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    background: #17e885; color: #1e293b; font-weight: bold; font-size: 16px;
    padding: 15px 30px; border-radius: 50px; text-decoration: none;
    box-shadow: 0 10px 20px rgba(23, 232, 133, 0.2); transition: 0.3s;
    font-family: inherit; /* ارث‌بری فونت */
}
.afm-snapp-btn:hover { background: #13d677; transform: translateY(-2px); box-shadow: 0 15px 25px rgba(23, 232, 133, 0.3); }

/* اسکلتون لودینگ (Skeleton) */
.afm-skeleton-loader { display: flex; padding: 25px; gap: 20px; flex-grow: 1; background: var(--afm-bg); font-family: inherit; }
.afm-sk-sidebar { width: 28%; border-left: 1px solid var(--afm-border); padding-left: 20px; }
.afm-sk-main { width: 72%; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
.sk-line, .sk-card { background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%); background-size: 200% 100%; animation: afmShimmer 1.5s infinite; border-radius: 8px; }
.sk-line { height: 40px; margin-bottom: 10px; }
.sk-card { height: 280px; border-radius: var(--afm-radius); }
@keyframes afmShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ریسپانسیو موبایل */
@media(max-width: 768px) {
    .afm-results-grid { flex-direction: column; }
    .afm-skeleton-loader { flex-direction: column; }
    .afm-sidebar, .afm-main-content, .afm-sk-sidebar, .afm-sk-main { width: 100%; border-left: none; }
    .afm-sidebar { border-bottom: 1px solid var(--afm-border); padding: 15px 20px; }
    .afm-main-content { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); padding: 15px 20px; gap: 15px; }
    .afm-modal-content { width: 100%; height: 100vh; max-height: 100vh; margin-top: 0; border-radius: 0; }
    #afm-search-input { font-size: 16px; }
    .afm-search-header { padding: 15px; gap: 10px; }
    .afm-product-card { padding: 10px; }
    .afm-img-wrapper { height: 140px; }
}
