/*
Theme Name: MesterGravity Theme
Theme URI: https://mestergravity.com
Author: MesterGravity
Author URI: https://mestergravity.com
Description: قالب اختصاصی، سبک و حرفه‌ای برای سیستم حسابداری و فروشگاه
Version: 1.0.0
Text Domain: mestergravity
*/

/* ========================================================
   1. معرفی فونت‌ها (آفلاین)
======================================================== */
@font-face {
    font-family: 'Vazirmatn';
    src: url('assets/fonts/Vazirmatn-Regular.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Vazirmatn';
    src: url('assets/fonts/Vazirmatn-Bold.woff2') format('woff2');
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}

/* ========================================================
   2. متغیرهای پیش‌فرض (Fallback)
======================================================== */
:root {
    --primary-color: #3b82f6;
    --bg-color: #f3f4f6;
    --global-font: 'Vazirmatn', Tahoma, Arial, sans-serif;
    --base-font-size: 14px;
    
    --sidebar-bg: #1f2937;
    --sidebar-text: #f9fafb;
    --sidebar-width: 250px;
    --sidebar-radius: 0px;
    --sidebar-shadow: none;
    
    --header-bg: #ffffff;
    --header-text: #1f2937;
    --header-height: 70px;
    --header-radius: 0px;
    --header-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ========================================================
   3. تنظیمات پایه (Body & Base)
======================================================== */
body {
    font-family: var(--global-font);
    font-size: var(--base-font-size);
    background-color: var(--bg-color);
    color: #374151;
    margin: 0;
    padding: 0;
    direction: rtl;
}

a {
    color: var(--primary-color);
    text-decoration: none;
}

/* ========================================================
   4. ساختار گرید داشبورد (Layout)
======================================================== */
.mg-wrapper {
    display: flex;
    min-height: 100vh;
}

.mg-sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    border-radius: var(--sidebar-radius);
    box-shadow: var(--sidebar-shadow);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.mg-main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.mg-content-area {
    padding: 30px;
    flex-grow: 1;
}

/* ========================================================
   5. استایل‌های سایدبار
======================================================== */
.mg-sidebar-logo {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.mg-sidebar-logo h3 {
    margin: 0;
    font-size: 18px;
    color: var(--sidebar-text);
}

.mg-sidebar-logo img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

.mg-sidebar-nav {
    padding: 15px 0;
    flex-grow: 1;
    overflow-y: auto;
}

.mg-menu-title {
    display: block;
    font-size: 12px;
    color: var(--sidebar-text);
    opacity: 0.5;
    margin: 15px 20px 5px;
    font-weight: bold;
}

.mg-menu-list {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.mg-menu-list li a {
    display: block;
    padding: 12px 20px;
    color: var(--sidebar-text);
    opacity: 0.8;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.3s ease;
}

.mg-menu-list li a:hover,
.mg-menu-list li.current-menu-item > a {
    background-color: rgba(255, 255, 255, 0.05);
    opacity: 1;
    border-right: 3px solid var(--primary-color);
}

.mg-sidebar-divider {
    height: 1px;
    background-color: rgba(255, 255, 255, 0.05);
    margin: 15px 20px;
}

/* ========================================================
   6. استایل‌های هدر
======================================================== */
.mg-header {
    background-color: var(--header-bg);
    color: var(--header-text);
    min-height: var(--header-height);
    border-radius: var(--header-radius);
    box-shadow: var(--header-shadow);
    padding: 0 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mg-header-title h2 {
    margin: 0;
    font-size: 18px;
    color: var(--header-text);
}

.mg-header-menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 10px;
}

.mg-header-menu-list li a {
    background-color: var(--primary-color);
    color: #ffffff;
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
}

.mg-header-menu-list li a:hover {
    opacity: 0.85;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* ========================================================
   7. دکمه‌ها و المان‌های رابط کاربری
======================================================== */
.mg-card {
    background-color: var(--header-bg);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 20px;
}

.mg-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    display: inline-block;
    transition: all 0.3s ease;
}

.mg-btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.mg-btn-primary:hover {
    opacity: 0.9;
}

/* ========================================================
   8. فوتر
======================================================== */
.mg-footer {
    background-color: var(--header-bg);
    padding: 15px 30px;
    text-align: center;
    font-size: 13px;
    color: #6b7280;
    border-top: 1px solid #e5e7eb;
}


/* ========================================================
   9. استایل‌های مشترک (دسکتاپ و موبایل) برای منوها
======================================================== */

/* حذف کامل منوی همبرگری/گزینه‌ها که تکراری بود */
.mg-mobile-toggle,
.menu-options-toggle {
    display: none !important;
}

/* مخفی کردن زیرمنوها در حالت پیش‌فرض */
ul.mg-menu-list ul.sub-menu {
    display: none;
    padding-right: 15px;
    margin-top: 5px;
}

/* باز شدن زیرمنو با کلاس open */
ul.mg-menu-list li.open > ul.sub-menu,
ul.mg-menu-list li.mg-open > ul.sub-menu {
    display: block;
}

/* فلش کنار آیتم‌های دارای زیرمجموعه */
ul.mg-menu-list li.menu-item-has-children > a {
    cursor: pointer;
}
ul.mg-menu-list li.menu-item-has-children > a::after {
    content: " ▼"; 
    font-size: 10px;
    float: left;
    margin-top: 5px;
}
ul.mg-menu-list li.menu-item-has-children.open > a::after,
ul.mg-menu-list li.menu-item-has-children.mg-open > a::after {
    content: " ▲"; 
}

/* منوی پایینی (عملیات پایه) - پیش‌فرض بسته در همه حالت‌ها */
.mg-collapsible-menu .mg-menu-list {
    display: none;
}
.mg-collapsible-menu.open .mg-menu-list {
    display: block;
    margin-top: 10px;
}
.mg-collapsible-trigger {
    position: relative;
    cursor: pointer;
}
.mg-collapsible-trigger::after {
    content: " ▼"; 
    font-size: 12px;
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
}
.mg-collapsible-menu.open .mg-collapsible-trigger::after {
    content: " ▲";
}


/* ========================================================
   10. گراویتی فرم (Gravity Forms)
======================================================== */
.gform_wrapper .gform_body {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
}
.gform_wrapper.gravity-theme .gform_fields {
    row-gap: 10px !important; 
}
.gform_wrapper.gravity-theme .gfield {
    margin-bottom: 5px !important;
    padding-top: 5px !important;
    padding-bottom: 5px !important;
}
.gform_wrapper.gravity-theme .gfield_label {
    margin-bottom: 4px !important;
}


/* ========================================================
   11. تنظیمات ریسپانسیو (موبایل و تبلت - زیر 992px)
======================================================== */
@media screen and (max-width: 992px) {
    /* انتقال سایدبار به بالا */
    .mg-wrapper {
        flex-direction: column !important; 
    }
    
    /* تنظیمات سایدبار در موبایل */
    .mg-sidebar {
        width: 100% !important;
        position: relative !important;
        height: auto !important;
        min-height: unset !important;
        border-bottom: 2px solid #eee;
        padding-bottom: 10px !important; /* کاهش ارتفاع سایدبار */
    }
    
    .mg-sidebar-nav {
        display: flex;
        flex-direction: column;
        margin-bottom: 10px !important;
    }

    /* تبدیل عناوین منوها (عملیات روزانه/پایه) به دکمه‌های آکاردئونی */
    .mg-menu-title {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        background-color: #2c3e50;
        color: #ffffff !important;
        padding: 10px 15px !important;
        margin: 5px 20px !important; /* کاهش فاصله بین منوها */
        border-radius: 8px;
        cursor: pointer;
        font-size: 14px;
        opacity: 1;
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    }

    /* اضافه کردن فلش به عناوین برای موبایل */
    .mg-menu-title::after {
        content: '\f107'; /* کد آیکون FontAwesome برای فلش */
        font-family: 'Font Awesome 5 Free';
        font-weight: 900;
        transition: transform 0.3s ease;
    }
    .mg-menu-title.active-toggle::after {
        transform: rotate(180deg);
    }

    /* مخفی کردن منوی بالا در موبایل در حالت پیش‌فرض */
    .mg-sidebar-nav > ul.mg-menu-list {
        display: none; 
        background-color: transparent !important; 
        padding: 5px 0 !important; 
        margin: 0 20px 10px 20px !important; 
    }

    /* استایل آیتم‌های داخل منو در موبایل */
    .mg-menu-list a {
        color: var(--sidebar-text) !important;
        padding: 10px 15px !important;
    }
    .mg-menu-list a:hover {
        background-color: rgba(255,255,255,0.05) !important;
    }
}
/* === بهبود کارت‌های آرشیو (هم‌تراز کردن) === */
.mg-archive-loop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.mg-archive-item {
    display: flex !important;
    flex-direction: column;
    height: 100% !important;           /* ارتفاع کامل */
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.mg-archive-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* تصویر شاخص فیکس و هم‌اندازه */
.mg-archive-item .mg-post-thumbnail {
    height: 220px;                    /* ارتفاع دلخواه تصویر */
    overflow: hidden;
}

.mg-archive-item .mg-post-thumbnail img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block;
}

/* محتوای متغیر (عنوان + خلاصه) */
.mg-archive-item .mg-post-title,
.mg-archive-item .mg-post-excerpt {
    padding: 16px 20px;
}

.mg-archive-item .mg-post-excerpt {
    flex-grow: 1;                     /* پر کردن فضای خالی */
    min-height: 80px;                 /* حداقل ارتفاع برای هم‌ترازی */
}

/* دکمه ادامه مطلب */
.mg-archive-item .mg-read-more,
.mg-archive-item a.mg-btn {
    margin-top: auto !important;      /* چسباندن به پایین */
    width: 100% !important;           /* ۱۰۰٪ عرض */
    padding: 14px 20px !important;
    text-align: center;
    border-radius: 0 0 12px 12px !important;
}

/* پشتیبانی از عرض ۵۰٪ (کلاس کمکی) */
.mg-read-more.half-width {
    width: 50% !important;
    margin: 20px auto 0 !important;
    display: block;
}

/* اگر تصویر نداشت */
.mg-archive-item .mg-post-thumbnail:empty {
    display: none;
}
.mg-read-more.width-100 { width: 100% !important; }
.mg-read-more.width-50  { width: 50% !important; margin: 20px auto 0 !important; }
.mg-read-more.width-25  { width: 25% !important; margin: 20px auto 0 !important; }
/* استایل‌های نگه‌دارنده سایدبار اختصاصی گوتنبرگ */
.mg-custom-gutenberg-sidebar {
    /* حذف هرگونه پس‌زمینه، حاشیه و فاصله پیش‌فرض */
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    box-shadow: none !important;
    
    /* تنظیم ارتفاع برای Full Height بودن */
    height: 100%;
    min-height: 100vh;
    
    /* استفاده از فلکس برای پر کردن محتوای داخلی */
    display: flex;
    flex-direction: column;
}

/* اطمینان از اینکه اولین گروه گوتنبرگ داخل این سایدبار تمام ارتفاع را پر می‌کند */
.mg-custom-gutenberg-sidebar > .wp-block-group {
    flex-grow: 1;
    width: 100%;
}

/* کانتینر کل صفحه: چیدمان ستونی برای قرارگیری هدر در بالا */
.mg-page-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* کانتینر بدنه (سایدبار + محتوا): چیدمان افقی برای قرارگیری در کنار هم */
.mg-content-wrapper {
    display: flex;
    flex-direction: row;
    flex-grow: 1; /* پر کردن فضای باقی مانده از ارتفاع */
    width: 100%;
}

/* اصلاح محتوای اصلی */
.mg-main-content {
    flex-grow: 1;
    width: 100%;
}
.site-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-content-area {
    display: flex;
    flex: 1; /* باعث می‌شود این بخش کل فضای باقی‌مانده را بگیرد */
}

.sidebar-area {
    height: auto; /* ارتفاع به صورت خودکار با والد تنظیم می‌شود */
    align-self: stretch;
}
/* نمایش بر اساس دستگاه */
@media (max-width: 768px) {
    .mg-show-desktop { display: none !important; }
}
@media (min-width: 769px) {
    .mg-show-mobile { display: none !important; }
}
/* ---------- نمایش مبتنی بر دستگاه ---------- */
@media (max-width: 782px) {
    .mg-show-desktop { display: none !important; }

    /* رفتار سایدبار در موبایل */
    .mg-mobile-sidebar-hide { display: none !important; }

    /* جابه‌جایی سایدبار به بالا/پایین محتوا (نیازمند flex در کانتینر) */
    .mg-content-wrapper { display: flex; flex-direction: column; }
    .mg-content-wrapper .mg-main-content { order: 2; }
    .mg-mobile-sidebar-top    { order: 1; }
    .mg-mobile-sidebar-bottom { order: 3; }
}

@media (min-width: 783px) {
    .mg-show-mobile { display: none !important; }
}
/* رفع مشکل تصویر و عنوان در موبایل */
.mg-fix-mobile-columns {
    gap: 20px;
}

@media (max-width: 768px) {
    .mg-fix-mobile-columns,
    .mg-fix-mobile-columns .wp-block-columns {
        flex-direction: column !important;
        gap: 25px !important;
    }
    
    /* هدف قرار دادن بلوک تصویر سفارشی شما */
    .mg-fix-mobile-columns .wp-block-image,
    .mg-fix-mobile-columns img,
    .mg-fix-mobile-columns .custom-image-block {   /* اگر نام کلاس بلوک سفارشی رو می‌دونی اینجا بنویس */
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        max-height: 280px !important;     /* می‌تونی تغییر بدی */
        object-fit: cover;
        border-radius: 12px;
    }
    
    /* عنوان */
    .mg-fix-mobile-columns .wp-block-heading {
        font-size: 26px !important;
        line-height: 1.35 !important;
    }
}

/* دسکتاپ */
@media (min-width: 769px) {
    .mg-fix-mobile-columns .wp-block-image img,
    .mg-fix-mobile-columns img {
        max-height: 420px;
    }
}
/* ── اسلایدر MG ── */
.mg-slider {
    box-sizing: border-box;
    max-width: 100%;
}
.mg-slider * {
    box-sizing: border-box;
}
@media (max-width: 781px) {
  .wp-block-columns {
    flex-direction: column;
  }

  /* ستون چپ (دومی در HTML) بره بالا */
  .wp-block-columns .wp-block-column:nth-child(2) {
    order: -1;
  }
}
