/* تعریف متغیرهای رنگی با پشتیبانی قطعی از حالت تاریک از طریق data-theme */
    :root {
        --primary-color: #b91c1c;
        --secondary-color: #f59e0b;
        --accent-color: #701a75;
        --text-dark: #333333;
        --text-muted: #6b7280;
        --bg-light: #f9fafb;
        --card-bg: #ffffff;
        --border-color: #e5e7eb;
        --hover-bg: #f3f4f6;
    }

    [data-theme="dark"] {
        --primary-color: #ef4444;
        --secondary-color: #fbbf24;
        --accent-color: #d946ef;
        --text-dark: #f3f4f6;
        --text-muted: #9ca3af;
        --bg-light: #111827;
        --card-bg: #1f2937;
        --border-color: #374151;
        --hover-bg: #374151;
    }

    body {
        background-color: var(--bg-light);
        font-family: 'Vazirmatn', 'Vazir', sans-serif;
        color: var(--text-dark);
        transition: background-color 0.3s ease, color 0.3s ease;
    }

    body.popup-open {
        overflow: hidden;
    }

    /* --- دکمه تغییر تم --- */
    .theme-toggle-btn {
        background-color: var(--card-bg);
        border: 1px solid var(--border-color);
        color: var(--text-dark);
        width: 45px;
        height: 45px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.3s ease;
        box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    }
    .theme-toggle-btn:hover {
        background-color: var(--hover-bg);
    }

    /* --- عناصر پایه --- */
    .base-card {
        background-color: var(--card-bg);
        border: 1px solid var(--border-color);
        border-radius: 1.5rem;
        box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    }

    /* --- استایل اختصاصی بنر برای تضمین ۱۶:۹ واقعی --- */
    .banner-wrapper {
        width: 100%;
        overflow: hidden;
    }
    .custom-banner-image {
        width: 100%;
        aspect-ratio: 16 / 9;
        object-fit: cover;
        display: block;
    }

    /* --- گرید اختصاصی برای محصولات (تنظیم برای ۴ محصول همزمان بدون پرش) --- */
    .custom-grid-articles, .custom-grid-products {
        display: grid;
        grid-template-columns: 1fr;
        gap: 1.5rem;
        align-items: stretch;
    }

    @media (min-width: 640px) {
        .custom-grid-articles { grid-template-columns: repeat(2, 1fr); }
        .custom-grid-products { grid-template-columns: repeat(2, 1fr); }
    }

    @media (min-width: 1024px) {
        .custom-grid-articles { grid-template-columns: repeat(4, 1fr); }
        .custom-grid-products { grid-template-columns: repeat(4, 1fr); } /* دقیقاً 4 ستون */
    }

    /* --- پاپ‌آپ --- */
    #popup-overlay {
        display: none;
        position: fixed;
        top: 0; left: 0; width: 100%; height: 100%;
        background: rgba(0, 0, 0, 0.6);
        z-index: 2000;
        backdrop-filter: blur(4px);
    }

    #entry-popup {
        display: none;
        position: fixed;
        top: 50%; left: 50%;
        transform: translate(-50%, -50%) scale(0.95);
        background: var(--card-bg);
        padding: 2rem;
        z-index: 2001;
        border-radius: 2rem;
        max-width: 90%;
        width: 450px;
        opacity: 0;
        transition: all 0.3s ease;
        box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    }

    #entry-popup.show {
        display: block;
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    #entry-popup img {
        max-width: 100%;
        border-radius: 1.5rem;
        margin-bottom: 1.5rem;
    }

    /* --- محتوای مقاله (Typography) --- */
    .article-content h1 {
        font-size: 2.5rem;
        line-height: 1.2;
        font-weight: 900;
        color: var(--text-dark);
        text-align: center;
        margin-bottom: 1.5rem;
    }

    .article-content h2 {
        color: var(--accent-color);
        border-right: 4px solid var(--secondary-color);
        padding-right: 15px;
        margin-top: 40px;
        margin-bottom: 20px;
        font-size: 1.75rem;
        font-weight: 800;
    }

    .article-content h3 {
        color: var(--primary-color);
        margin-top: 30px;
        margin-bottom: 15px;
        font-size: 1.4rem;
        font-weight: 700;
    }

    .article-content p, .article-content .prose {
        font-size: 1.05rem;
        line-height: 1.9;
        margin-bottom: 20px;
        text-align: justify;
        color: var(--text-dark);
    }

    .article-content ul {
        list-style-type: disc;
        padding-right: 25px;
        margin-bottom: 20px;
        line-height: 1.8;
    }

    /* --- کارت محصول داخل متن --- */
    .product-rectangular {
        background: var(--card-bg);
        border-radius: 1.5rem;
        overflow: hidden;
        border: 1px solid var(--border-color);
        display: flex;
        flex-direction: row;
        margin: 2rem auto;
        max-width: 800px;
        box-shadow: 0 4px 6px rgba(0,0,0,0.02);
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    .product-rectangular:hover {
        transform: translateY(-3px);
        box-shadow: 0 8px 15px rgba(0,0,0,0.08);
    }

    .product-rectangular .image-gallery {
        width: 35%;
        background-color: var(--hover-bg);
        padding: 1rem;
        position: relative;
    }

    .product-rectangular .image-gallery img {
        width: 100%; height: 100%;
        object-fit: cover;
        border-radius: 1rem;
    }

    .product-rectangular .details {
        width: 65%;
        padding: 1.5rem;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }

    /* --- کارت‌های محصول فوق‌حرفه‌ای (High CTR) --- */
    .ctr-product-card {
        background: var(--card-bg);
        border-radius: 1.5rem;
        border: 1px solid var(--border-color);
        overflow: hidden;
        position: relative;
        display: flex;
        flex-direction: column;
        transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        box-shadow: 0 4px 15px rgba(0,0,0,0.02);
        text-decoration: none !important;
        height: 100%;
    }
    .ctr-product-card:hover {
        transform: translateY(-8px);
        box-shadow: 0 15px 35px rgba(239, 68, 68, 0.12); /* هاله محو همرنگ برند */
        border-color: var(--primary-color);
    }
    .ctr-product-card .image-wrapper {
        position: relative;
        width: 100%;
        padding-top: 100%; /* ساختار مربع کامل 1:1 برای تصاویر فروشگاهی */
        overflow: hidden;
        background-color: var(--hover-bg);
    }
    .ctr-product-card .image-wrapper img {
        position: absolute;
        top: 0; left: 0; width: 100%; height: 100%;
        object-fit: cover;
        transition: transform 0.6s ease;
    }
    .ctr-product-card:hover .image-wrapper img {
        transform: scale(1.08); /* زوم ملایم روی تصویر در زمان هاور */
    }
    .ctr-badge {
        position: absolute;
        top: 12px; right: 12px;
        background: linear-gradient(135deg, #ef4444, #b91c1c);
        color: white !important;
        padding: 4px 12px;
        border-radius: 12px;
        font-size: 0.75rem;
        font-weight: 900;
        box-shadow: 0 4px 10px rgba(239, 68, 68, 0.3);
        z-index: 2;
    }
    .ctr-badge-special {
        right: auto; left: 12px;
        background: linear-gradient(135deg, #f59e0b, #d97706);
        box-shadow: 0 4px 10px rgba(245, 158, 11, 0.3);
    }
    .ctr-details {
        padding: 1.25rem;
        display: flex;
        flex-direction: column;
        flex-grow: 1;
        justify-content: space-between;
        gap: 1rem;
    }
    .ctr-title {
        font-size: 1.05rem;
        font-weight: 800;
        color: var(--text-dark) !important;
        line-height: 1.6;
        margin: 0;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        transition: color 0.3s;
    }
    .ctr-product-card:hover .ctr-title {
        color: var(--primary-color) !important;
    }
    .ctr-price-box {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
    }
    .ctr-old-price {
        font-size: 0.85rem;
        color: var(--text-muted);
        text-decoration: line-through;
        margin-bottom: -2px;
    }
    .ctr-new-price {
        font-size: 1.2rem;
        font-weight: 900;
        color: var(--primary-color);
    }
    .ctr-buy-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
        padding: 10px;
        border-radius: 1rem;
        background-color: var(--hover-bg);
        color: var(--primary-color) !important;
        font-weight: 900;
        font-size: 0.9rem;
        transition: all 0.3s ease;
    }
    .ctr-product-card:hover .ctr-buy-btn {
        background-color: var(--primary-color);
        color: #ffffff !important;
        box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
    }

    .btn-buy {
        background-color: var(--primary-color);
        color: #ffffff !important;
        border-radius: 9999px;
        padding: 0.6rem 1.5rem;
        font-weight: bold;
        text-align: center;
        transition: opacity 0.3s;
        display: inline-block;
        border: none;
        cursor: pointer;
    }
    .btn-buy:hover { opacity: 0.9; }

    .badge {
        position: absolute; top: 1rem; right: 1rem;
        font-size: 0.75rem; font-weight: bold;
        padding: 0.3rem 0.8rem; border-radius: 9999px; color: #ffffff;
    }
    .discount-badge { background-color: var(--primary-color); }
    .featured-badge { background-color: #10b981; right: auto; left: 1rem; }
    .special-badge { background-color: #8b5cf6; right: 6rem; }

    /* --- سوالات متداول --- */
    .faq-section details {
        background-color: var(--card-bg);
        padding: 1.2rem 1.5rem;
        margin-bottom: 1rem;
        border-radius: 1.5rem;
        border: 1px solid var(--border-color);
        cursor: pointer;
        transition: background 0.3s;
    }
    .faq-section details:hover { background-color: var(--hover-bg); }
    .faq-section summary {
        font-weight: bold;
        color: var(--text-dark);
        font-size: 1.1rem;
        outline: none;
        list-style: none;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .faq-section summary::-webkit-details-marker { display: none; }
    .faq-section summary::after {
        content: '\25BC';
        font-size: 0.8rem;
        color: var(--secondary-color);
        transition: transform 0.3s;
    }
    .faq-section details[open] summary::after { transform: rotate(180deg); }
    .faq-section details p {
        margin-top: 1rem;
        margin-bottom: 0;
        color: var(--text-muted);
        line-height: 1.8;
        border-top: 1px solid var(--border-color);
        padding-top: 1rem;
    }

    /* --- ریسپانسیو موبایل --- */
    @media (max-width: 768px) {
        .product-rectangular { flex-direction: column; max-width: 100%;}
        .product-rectangular .image-gallery { width: 100%; aspect-ratio: 4/3; }
        .product-rectangular .details { width: 100%; padding: 1.25rem; }
        .article-content h2 { font-size: 1.4rem; margin-top: 30px; }
        .article-content h3 { font-size: 1.2rem; }
        .faq-section details { padding: 1rem; border-radius: 1rem; }
        .faq-section summary { font-size: 1rem; line-height: 1.5;}
    }