/*
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;
    }
}
