:root {
    --primary-color: #3498db;
    --secondary-color: #2c3e50;
    --accent-color: #e67e22;
    --bg-body: #f4f7f6;
    --bg-card: #fff;
    --text-main: #333;
    --text-muted: #666;
    --border-color: #eee;
    --bg-hover: #f0f0f0;
    --shadow-sm: 0 2px 5px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 10px rgba(0,0,0,0.15);
}
body.dark-mode {
    --bg-body: #121212; --bg-card: #1e1e1e; --text-main: #e0e0e0; --text-muted: #bbb; --border-color: #333; --bg-hover: #2c2c2c; --primary-color: #5dade2;
}
* { box-sizing: border-box; }
body { font-family: 'Vazir', sans-serif; background-color: var(--bg-body); color: var(--text-main); margin: 0; padding: 20px 0 0 0; line-height: 1.6; transition: background-color 0.3s, color 0.3s; display: flex; flex-direction: column; min-height: 100vh; }
.container { width: 95%; max-width: 1200px; margin: 0 auto; }
a { text-decoration: none; }
h1, h2, h3 { color: var(--secondary-color); }
body.dark-mode h1, body.dark-mode h2, body.dark-mode h3 { color: var(--primary-color); }

/* ================= Header & Nav ================= */
header.main-header { margin-bottom: 30px; }
.header-content {
    display: flex; justify-content: center; align-items: center; position: relative; margin-bottom: 20px;
}
header h1 { font-size: 2.5rem; margin: 0; color: var(--primary-color); text-align: center; }

/* دکمه همبرگری (پیش‌فرض مخفی در دسکتاپ) */
.hamburger-btn {
    display: none; /* در دسکتاپ مخفی */
    position: absolute; right: 0; top: 50%; transform: translateY(-50%);
    background: none; border: none; color: var(--text-main); cursor: pointer; padding: 5px; z-index: 10;
}

/* منوی افقی (فقط دسکتاپ) */
.category-nav.desktop-view-only {
    display: flex; gap: 15px; overflow-x: auto; padding: 20px 5px; margin-bottom: 20px; scrollbar-width: none; justify-content: center;
}
.category-nav a {
    display: inline-flex; align-items: center; justify-content: center; padding: 12px 24px;
    background-color: var(--bg-card); color: var(--text-muted); border-radius: 30px;
    font-size: 0.95rem; font-weight: 700; border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px rgba(0,0,0,0.04); transition: all 0.3s ease;
}
.category-nav a:hover { background-color: var(--bg-hover); color: var(--primary-color); border-color: var(--primary-color); transform: translateY(-2px); box-shadow: 0 6px 12px rgba(52, 152, 219, 0.15); }
.category-nav a.active { background-color: var(--primary-color); color: white; border-color: transparent; box-shadow: 0 8px 15px rgba(52, 152, 219, 0.3); transform: translateY(-2px); }
body.dark-mode .category-nav a { background-color: var(--bg-hover); color: #ccc; border-color: var(--border-color); box-shadow: none; }
body.dark-mode .category-nav a.active { background-color: var(--primary-color); color: #fff; box-shadow: 0 8px 15px rgba(52, 152, 219, 0.2); }


/* ================= Mobile Off-canvas Menu (منوی کشویی) ================= */
.mobile-menu-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 998;
    opacity: 0; visibility: hidden; transition: all 0.3s; backdrop-filter: blur(2px);
}
.mobile-menu-overlay.active { opacity: 1; visibility: visible; }

.mobile-side-menu {
    position: fixed; top: 0; right: 0; width: 280px; height: 100vh;
    background: var(--bg-card); z-index: 999;
    transform: translateX(100%); /* خارج از صفحه در سمت راست */
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -5px 0 15px rgba(0,0,0,0.1); display: flex; flex-direction: column;
}
.mobile-side-menu.open { transform: translateX(0); /* ورود به صفحه */ }

.mobile-menu-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px; border-bottom: 1px solid var(--border-color);
}
.mobile-menu-header h3 { margin: 0; font-size: 1.2rem; }
.close-menu-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 5px; }

.mobile-menu-list { list-style: none; padding: 0; margin: 0; overflow-y: auto; }
.mobile-menu-list li a {
    display: block; padding: 15px 20px; color: var(--text-main); font-weight: 600;
    border-bottom: 1px solid var(--border-color); transition: all 0.2s;
}
.mobile-menu-list li a:hover { background: var(--bg-hover); color: var(--primary-color); padding-right: 25px; }
.mobile-menu-list li a.active { background: var(--bg-hover); color: var(--primary-color); border-right: 4px solid var(--primary-color); }

/* ================= Forms & Search ================= */
.search-form, .ingredient-form { background: var(--bg-card); padding: 25px; border-radius: 16px; box-shadow: var(--shadow-md); margin-bottom: 30px; border: 1px solid var(--border-color); }
.search-form { display: flex; gap: 10px; }
input[type="text"] { flex-grow: 1; padding: 14px; border: 2px solid var(--border-color); border-radius: 12px; font-family: 'Vazir'; font-size: 1rem; background: var(--bg-body); color: var(--text-main); transition: border-color 0.3s; }
input[type="text"]:focus { border-color: var(--primary-color); outline: none; }
button { padding: 14px 28px; background-color: var(--primary-color); color: white; border: none; border-radius: 12px; cursor: pointer; font-family: 'Vazir'; font-size: 1rem; font-weight: bold; transition: background-color 0.3s, transform 0.2s; }
button:hover { background-color: #2980b9; transform: translateY(-2px); }
.submit-btn { width: 100%; margin-top: 20px; font-size: 1.1rem; background-color: var(--accent-color); }
.submit-btn:hover { background-color: #d35400; }
.divider-or { text-align: center; margin: 25px 0; position: relative; }
.divider-or::before { content: ''; position: absolute; top: 50%; left: 0; right: 0; border-top: 2px dashed var(--border-color); z-index: 0; }
.divider-or span { background: var(--bg-body); padding: 0 15px; position: relative; z-index: 1; color: var(--text-muted); font-weight: bold; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; max-height: 220px; overflow-y: auto; padding-right: 5px; }
.checkbox-label { display: flex; align-items: center; background: var(--bg-body); padding: 10px 12px; border-radius: 10px; cursor: pointer; transition: all 0.2s; border: 1px solid var(--border-color); }
.checkbox-label:hover { background: var(--bg-hover); border-color: var(--primary-color); }
.checkbox-label input { margin-left: 10px; accent-color: var(--primary-color); transform: scale(1.1); }
.separator { border: 0; border-top: 2px solid var(--border-color); margin: 40px 0; }

/* ================= Recipe Cards & Archive ================= */
.random-list { display: flex; flex-wrap: wrap; gap: 25px; justify-content: center; margin-bottom: 40px; }
.random-recipe-card { background: var(--bg-card); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow-sm); width: 100%; max-width: 320px; transition: transform 0.3s, box-shadow 0.3s; border: 1px solid var(--border-color); display: flex; flex-direction: column; }
.random-recipe-card:hover { transform: translateY(-8px); box-shadow: var(--shadow-md); }
.random-recipe-card img { width: 100%; height: 200px; object-fit: cover; }
.card-content { padding: 20px; flex-grow: 1; display: flex; flex-direction: column; }
.card-content h3 { margin: 0 0 15px 0; font-size: 1.25rem; color: var(--secondary-color); }
body.dark-mode .card-content h3 { color: var(--primary-color); }
.mini-info { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 20px; display: flex; gap: 15px; }
.card-link { display: block; text-align: center; background: var(--bg-hover); color: var(--primary-color); padding: 10px; border-radius: 10px; font-weight: bold; transition: all 0.3s; margin-top: auto; }
.card-link:hover { background: var(--primary-color); color: white; }
.archive-box { background: var(--bg-card); padding: 30px; border-radius: 20px; box-shadow: var(--shadow-md); border: 1px solid var(--border-color); }
.archive-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; flex-wrap: wrap; gap: 15px; }
.archive-header h2 { margin: 0; font-size: 1.8rem; }
.archive-filter-form { display: flex; gap: 10px; }
.archive-filter-form select { padding: 10px 15px; border-radius: 10px; border: 2px solid var(--border-color); font-family: 'Vazir'; background: var(--bg-body); color: var(--text-main); cursor: pointer; }
.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 25px; }
.recipe-card { background: var(--bg-card); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow-sm); transition: all 0.3s; border: 1px solid var(--border-color); display: flex; flex-direction: column; }
.recipe-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-md); border-color: var(--primary-color); }
.recipe-card img { width: 100%; height: 180px; object-fit: cover; }
.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 40px; flex-wrap: wrap; }
.page-btn { display: inline-block; padding: 10px 16px; background: var(--bg-hover); color: var(--text-main); border-radius: 10px; transition: all 0.3s; border: 1px solid var(--border-color); }
.page-btn:hover { background: var(--primary-color); color: white; border-color: var(--primary-color); }
.page-btn.active { background: var(--primary-color); color: white; font-weight: bold; box-shadow: 0 4px 10px rgba(52, 152, 219, 0.3); border-color: var(--primary-color); }

/* ================= Recipe Detail ================= */
.recipe-detail { max-width: 900px; }
.recipe-image-full { width: 100%; height: auto; max-height: 500px; object-fit: cover; border-radius: 20px; margin-bottom: 30px; box-shadow: var(--shadow-md); }
.recipe-infographic { display: flex; flex-wrap: wrap; gap: 15px; justify-content: space-around; background: var(--bg-card); padding: 25px; border-radius: 16px; box-shadow: var(--shadow-sm); margin-bottom: 35px; border: 1px solid var(--border-color); }
.info-item { text-align: center; display: flex; flex-direction: column; align-items: center; min-width: 90px; }
.info-icon { font-size: 2.5rem; margin-bottom: 10px; }
.info-label { font-size: 0.9rem; color: var(--text-muted); }
.info-value { font-weight: bold; color: var(--secondary-color); font-size: 1.1rem; }
body.dark-mode .info-value { color: var(--primary-color); }
.recipe-content { background: var(--bg-card); padding: 35px; border-radius: 20px; box-shadow: var(--shadow-md); border: 1px solid var(--border-color); }
.recipe-content h3 { color: var(--secondary-color); font-size: 1.6rem; margin-bottom: 25px; border-bottom: 3px solid var(--primary-color); display: inline-block; padding-bottom: 10px; }
body.dark-mode .recipe-content h3 { color: var(--primary-color); }
.ingredient-list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 15px; }
.ingredient-list li { padding: 12px 15px; background: var(--bg-hover); border-radius: 10px; display: flex; align-items: center; font-weight: 500; border: 1px solid transparent; }
.ingredient-list li::before { content: '🥄'; margin-left: 10px; }
body.dark-mode .ingredient-list li { border-color: var(--border-color); }
.instructions { line-height: 2; font-size: 1.05rem; white-space: pre-line; color: var(--text-main); }
.back-link { display: inline-block; margin-top: 30px; padding: 12px 25px; background: var(--secondary-color); color: white; border-radius: 12px; transition: background 0.3s; font-weight: bold; }
.back-link:hover { background: var(--primary-color); }
.instructions h2 { color: var(--secondary-color); font-size: 1.4rem; border-bottom: 2px solid var(--primary-color); padding-bottom: 8px; margin-top: 35px; margin-bottom: 15px; display: inline-block; }
.instructions h3 { color: var(--accent-color); font-size: 1.2rem; margin-top: 25px; margin-bottom: 10px; font-weight: 800; }
.instructions h4.step-title { color: #444; font-size: 1.1rem; font-weight: 800; margin-top: 20px; margin-bottom: 8px; padding-right: 10px; border-right: 3px solid #2ecc71; background-color: rgba(46, 204, 113, 0.1); padding: 8px 10px; border-radius: 4px; display: block; }
.instructions strong { color: #333; font-weight: 900; }
body.dark-mode .instructions h2 { color: var(--primary-color); border-bottom-color: var(--primary-color); }
body.dark-mode .instructions h3 { color: var(--accent-color); }
body.dark-mode .instructions h4.step-title { color: #e0e0e0; background-color: rgba(46, 204, 113, 0.2); border-right-color: #27ae60; }
body.dark-mode .instructions strong { color: #fff; }
.breadcrumbs { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 15px; display: flex; align-items: center; gap: 5px; }
.breadcrumbs a { color: var(--primary-color); transition: color 0.2s; }
.breadcrumbs a:hover { color: var(--accent-color); text-decoration: underline; }
.breadcrumbs .current { color: var(--text-muted); font-weight: bold; }
.breadcrumbs span { color: #ccc; }

/* ================= Footer & Theme Toggle ================= */
.main-footer { margin-top: auto; background: var(--bg-card); padding: 40px 20px; text-align: center; border-top: 1px solid var(--border-color); box-shadow: 0 -4px 15px rgba(0,0,0,0.03); }
.footer-links { display: flex; justify-content: center; gap: 25px; margin-bottom: 25px; flex-wrap: wrap; }
.footer-links a { color: var(--text-muted); font-weight: 600; font-size: 1rem; transition: all 0.3s ease; padding-bottom: 5px; border-bottom: 2px solid transparent; }
.footer-links a:hover { color: var(--primary-color); border-bottom-color: var(--primary-color); }
.copyright { font-size: 0.9rem; color: var(--text-muted); margin: 0; }
.creator-link { color: var(--primary-color); font-weight: bold; }
.creator-link:hover { text-decoration: underline; }
.theme-toggle-btn { position: fixed; bottom: 25px; left: 25px; background: var(--secondary-color); color: white; border: none; border-radius: 50%; width: 55px; height: 55px; font-size: 1.5rem; cursor: pointer; box-shadow: var(--shadow-md); transition: all 0.3s; z-index: 100; display: flex; align-items: center; justify-content: center; }
.theme-toggle-btn:hover { transform: rotate(15deg) scale(1.1); background: var(--primary-color); }
body.dark-mode .theme-toggle-btn { background: var(--primary-color); }
body.dark-mode .theme-toggle-btn:hover { background: var(--accent-color); }

/* ================= Ads ================= */
.top-ads-container, .bottom-ads-container { display: flex; justify-content: center; gap: 15px; margin: 25px 0; width: 100%; }
.banner-horizontal { flex: 1; max-width: 50%; border-radius: 16px; overflow: hidden; box-shadow: var(--shadow-sm); transition: transform 0.3s, box-shadow 0.3s; display: block; border: 1px solid var(--border-color); }
.banner-horizontal:hover { transform: translateY(-5px); box-shadow: var(--shadow-md); }
.banner-horizontal img { width: 100%; height: 100%; min-height: 120px; object-fit: cover; display: block; }
.sticky-ads { position: fixed; top: 120px; width: 160px; display: flex; flex-direction: column; gap: 15px; z-index: 90; }
.right-ads { right: 15px; }
.left-ads { left: 15px; }
.ad-box.side-banner { width: 100%; height: 160px; border-radius: 16px; overflow: hidden; box-shadow: var(--shadow-sm); transition: transform 0.3s, box-shadow 0.3s; background: var(--bg-card); display: block; border: 1px solid var(--border-color); }
.ad-box:hover { transform: translateX(-8px); box-shadow: var(--shadow-md); }
.left-ads .ad-box:hover { transform: translateX(8px); }
.ad-box img { width: 100%; height: 100%; display: block; object-fit: cover; }

/* ================= RESPONSIVE (مدیریت نمایش موبایل) ================= */
@media (max-width: 1350px) { .sticky-ads { display: none !important; } }

@media (max-width: 768px) {
    /* نمایش دکمه همبرگری */
    .hamburger-btn { display: block; z-index: 10; }
    /* مخفی کردن منوی افقی */
    .category-nav.desktop-view-only { display: none; }
    /* تنظیمات هدر در موبایل (اصلاح شده برای جلوگیری از تداخل) */
    .header-content { justify-content: center; padding-right: 50px; }
    header h1 { font-size: 1.8rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    
    .search-form { flex-direction: column; }
    button { width: 100%; }
    .archive-header { flex-direction: column; align-items: flex-start; }
    .archive-filter-form { width: 100%; justify-content: space-between; }
    .archive-filter-form select { flex: 1; }
    .recipe-infographic { gap: 10px; }
    .info-item { min-width: 70px; }
    .info-icon { font-size: 2rem; }
}

@media (max-width: 600px) {
    .top-ads-container, .bottom-ads-container { flex-direction: column; }
    .banner-horizontal { max-width: 100%; }
    .main-footer { padding: 30px 15px; }
    .footer-links { flex-direction: column; gap: 15px; }
}
