/* 1. تعریف فونت IRANSans */
@font-face {
    font-family: 'IRANSans';
    src: url('../webfonts/IRANSansWeb.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* 2. تنظیمات پایه و ریست */
body {
    margin: 0;
    font-family: 'IRANSans', system-ui, -apple-system, sans-serif;
    background-color: #f3f4f6;
    direction: rtl;
    /* تنظیم جهت متن برای فارسی */
}

#app {
    padding: 0;
    /* مدیریت پدینگ توسط SPA */
}

/* اعمال فونت به کل ریشه SPA و تمام عناصر زیرمجموعه */
.acc-spa-root,
.acc-spa-root *,
.modal-window,
.tabulator {
    font-family: 'IRANSans', sans-serif !important;
}

.acc-spa-root {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 3. باکس ورود (Login) */
.login-box {
    max-width: 320px;
    margin: 80px auto;
    padding: 24px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
}

.login-box h2 {
    margin-top: 0;
}

.field {
    margin-bottom: 12px;
}

.field label {
    display: block;
    margin-bottom: 4px;
}

.field input {
    width: 100%;
    padding: 6px 8px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.error {
    margin-top: 10px;
    color: red;
    font-size: 0.85rem;
}

/* 4. هدر (Header) */
.acc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #1f2937;
    color: #f9fafb;
    padding: 0 1rem;
    height: 56px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.acc-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.acc-sidebar-toggle {
    background: transparent;
    border: none;
    color: inherit;
    font-size: 1.25rem;
    cursor: pointer;
}

.acc-brand {
    display: flex;
    flex-direction: column;
}

.acc-brand-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.acc-brand-subtitle {
    font-size: 0.75rem;
    color: #9ca3af;
}

.acc-user-info {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.acc-user-name {
    font-weight: 500;
    font-size: 0.9rem;
}

.acc-user-role {
    font-size: 0.75rem;
    color: #9ca3af;
}

.acc-logout-btn {
    border: 1px solid #ef4444;
    color: #fca5a5;
    background: transparent;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: 0.2s;
}

.acc-logout-btn:hover {
    background: rgba(239, 68, 68, 0.12);
}

/* 5. چیدمان اصلی و سایدبار */
.acc-main-layout {
    flex: 1;
    display: flex;
    min-height: 0;
}

.acc-sidebar {
    width: 240px;
    background: #111827;
    color: #e5e7eb;
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease;
    overflow: hidden;
}

.acc-sidebar.collapsed {
    width: 56px;
}

.acc-sidebar.collapsed .acc-menu-item-label,
.acc-sidebar.collapsed .acc-menu-section-title {
    display: none;
}

@media (max-width: 768px) {
    .acc-sidebar {
        position: absolute;
        z-index: 40;
        top: 56px;
        bottom: 0;
    }

    .acc-sidebar.closed-mobile {
        transform: translateX(100%);
    }

    /* برای RTL از 100% استفاده شد */
}

/* 6. منو (Menu) */
.acc-menu {
    padding: 0.75rem 0.5rem;
    flex: 1;
    overflow-y: auto;
}

.acc-menu-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: #6b7280;
    padding: 0.5rem 0.75rem;
}

.acc-menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    border-radius: 0.375rem;
    cursor: pointer;
    color: #e5e7eb;
    font-size: 0.85rem;
    transition: 0.2s;
}

.acc-menu-item:hover {
    background: rgba(55, 65, 81, 0.9);
}

.acc-menu-item.active {
    background: #111827;
    border: 1px solid #4b5563;
    color: #fff;
}

/* 7. فضای کاری و تب‌ها (Workspace & Tabs) */
.acc-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f3f4f6;
    min-width: 0;
}

.tab-title {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* 7. فضای کاری و تب‌ها - اصلاح شده برای مطابقت با نوار ادمین وردپرس */
.acc-tabbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 4px;
    background: #1d2327;
    /* رنگ دقیق نوار ادمین وردپرس */
    border-bottom: 1px solid #000;
    overflow-x: auto;
    white-space: nowrap;
    height: 32px;
    /* ارتفاع استاندارد WP Admin Bar */
    box-sizing: border-box;
}

.acc-tab {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    height: 26px;
    /* کمی کوتاه‌تر از نوار اصلی برای ایجاد فاصله */
    padding: 0 4px;
    border-radius: 4px 4px 0 0;
    background: #2c3338;
    /* رنگ تب‌های غیرفعال */
    color: #c3c4c7;
    font-size: 12px;
    /* سایز فونت مشابه منوهای وردپرس */
    cursor: pointer;
    border: none;
    transition: 0.2s;
    margin-top: 6px;
    /* چسبیدن به پایین نوار */
}

.acc-tab:hover {
    background: #353c42;
    color: #72aee6;
    /* رنگ آبی وردپرس هنگام هاور */
}

.acc-tab.active {
    background: #f0f0f1;
    /* رنگ روشن برای تب فعال (مطابق با پس‌زمینه محتوا) */
    color: #1d2327;
    font-weight: 600;
    border-bottom: none;
}

/* تنظیم آیکون ضربدر برای هماهنگی با سایز جدید */
.tab-actions button {
    color: inherit;
    opacity: 0.6;
    font-size: 10px;
}

.tab-actions button:hover {
    opacity: 1;
    color: #d63638;
}

.tab-context {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #6b7280;
}

.tab-avatar {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #3b82f6;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
}

.tab-actions button {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 12px;
    color: #9ca3af;
}

.tab-actions button:hover {
    color: #ef4444;
}

/* 8. محتوا و ویوها (Content & Views) */
.acc-tab-content {
    flex: 1;
    padding: 1rem;
    overflow: auto;
}

.acc-view {
    background: #ffffff;
    border-radius: 0.5rem;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    min-height: 100%;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.75rem;
}

/* 9. مدال‌ها (Modals) */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5000;
}

.modal-window {
    background: #fff;
    border-radius: 12px;
    width: 400px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid #eee;
    background: #f9fafb;
}

.modal-body {
    padding: 1rem;
    overflow-y: auto;
}

.user-row {
    padding: 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    transition: 0.2s;
    border-radius: 6px;
}

.user-row:hover {
    background: #eff6ff;
    color: #2563eb;
}

/* 10. گرید کارت‌ها (Menu Grid) */
.acc-menu-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 2rem 0;
}

.acc-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
    width: 90%;
    max-width: 1200px;
}

.acc-card-item {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    transition: 0.3s;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.acc-card-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    border-color: #3b82f6;
}

.acc-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.acc-card-icon {
    font-size: 1.5rem;
    color: #4b5563;
}

.acc-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
}

/* بخش اصلاح شده در شماره 10 */
.acc-card-desc {
    font-size: 0.85rem;
    line-height: 1.6;
    color: #991b1b;
    /* رنگ زرشکی (Crimson/Deep Red) */
    font-weight: 500;
    /* کمی ضخیم‌تر برای جلوه بهتر رنگ */
}


.acc-card-meta {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: auto;
}

/* 11. اصلاحات Tabulator */
.tabulator {
    border: 1px solid #e5e7eb !important;
    border-radius: 8px !important;
}

.tabulator .tabulator-header {
    background-color: #f9fafb !important;
    color: #374151 !important;
    font-weight: 600 !important;
}

.tabulator .tabulator-row {
    background-color: #fff !important;
    border-bottom: 1px solid #f3f4f6 !important;
}

.tabulator .tabulator-row:hover {
    background-color: #f9fafb !important;
}

.tabulator .tabulator-cell {
    padding: 12px !important;
    border-right: 1px solid #f3f4f6 !important;
}


/* ----------------------- */

.acc-permission-manager {
    max-width: 1280px;
    margin: auto;
    padding: 16px;
}

.acc-pm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.acc-pm-title h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
}

.acc-pm-title p {
    margin: 4px 0 0;
    color: #6b7280;
    font-size: 13px;
}

.acc-pm-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.acc-btn {
    border: 1px solid #d1d5db;
    background: #fff;
    color: #111827;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
}

.acc-btn:hover {
    background: #f9fafb;
}

.acc-btn.primary {
    background: #111827;
    color: #fff;
    border-color: #111827;
}

.acc-btn.primary:hover {
    background: #1f2937;
}

.acc-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 16px;
}

.acc-sidebar,
.acc-main {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}

.acc-sidebar {
    padding: 14px;
}

.acc-main {
    padding: 16px;
}

.acc-user-search {
    margin-bottom: 12px;
}

.acc-user-search input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
}

.acc-user-list {
    max-height: 560px;
    overflow: auto;
}

.acc-user-item {
    padding: 10px 12px;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 10px;
    margin-bottom: 6px;
    transition: all .15s ease;
}

.acc-user-item:hover {
    background: #f9fafb;
    border-color: #e5e7eb;
}

.acc-user-item.active {
    background: #eff6ff;
    border-color: #bfdbfe;
}

.acc-user-name {
    font-weight: 600;
    font-size: 14px;
    color: #111827;
}

.acc-user-meta {
    font-size: 12px;
    color: #6b7280;
    margin-top: 3px;
}

.acc-selected-user {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 14px;
    margin-bottom: 16px;
}

.acc-selected-user h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
}

.acc-selected-user p {
    margin: 4px 0 0;
    color: #6b7280;
    font-size: 13px;
}

.acc-summary {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.acc-summary-card {
    min-width: 120px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 12px;
}

.acc-summary-card strong {
    display: block;
    font-size: 18px;
    color: #111827;
}

.acc-summary-card span {
    display: block;
    font-size: 12px;
    color: #6b7280;
    margin-top: 4px;
}

.acc-module {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
}

.acc-module-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: #fbfbfc;
    cursor: pointer;
}

.acc-module-title {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.acc-module-title strong {
    font-size: 15px;
}

.acc-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    background: #e5e7eb;
    color: #374151;
    font-size: 12px;
    font-weight: 600;
}

.acc-badge.green {
    background: #dcfce7;
    color: #166534;
}

.acc-module-tools {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.acc-mini-btn {
    border: 1px solid #d1d5db;
    background: #fff;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
}

.acc-mini-btn:hover {
    background: #f9fafb;
}

.acc-module-body {
    padding: 14px 16px 16px;
    border-top: 1px solid #eef2f7;
}

.acc-permission-row {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 12px;
    align-items: start;
    padding: 12px 0;
    border-bottom: 1px dashed #edf2f7;
}

.acc-permission-row:last-child {
    border-bottom: none;
}

.acc-permission-info strong {
    display: block;
    font-size: 14px;
    color: #111827;
}

.acc-permission-info small {
    display: block;
    color: #6b7280;
    font-size: 12px;
    margin-top: 4px;
    line-height: 1.5;
}

.acc-perm-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.acc-perm-actions label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    background: #f3f4f6;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
}

.acc-perm-actions label.is-on {
    background: #dbeafe;
    color: #1d4ed8;
}

.acc-empty,
.acc-loading,
.acc-error,
.acc-save-state {
    font-size: 13px;
    color: #6b7280;
    padding: 12px 0;
}

.acc-save-state {
    color: #2563eb;
}

.acc-save-state.error {
    color: #dc2626;
}

@media (max-width: 960px) {
    .acc-layout {
        grid-template-columns: 1fr;
    }

    .acc-permission-row {
        grid-template-columns: 1fr;
    }
}