@font-face {
	font-family: IRANSansX;
	font-style: normal;
	font-weight: 100;
	src: url('/assets/IRANSansXFaNum-Thin.woff') format('woff'),
	url('/assets/IRANSansXFaNum-Thin.woff2') format('woff2');
}

@font-face {
	font-family: IRANSansX;
	font-style: normal;
	font-weight: 200;
	src: url('/assets/IRANSansXFaNum-UltraLight.woff') format('woff'),
	url('/assets/IRANSansXFaNum-UltraLight.woff2') format('woff2');
}

@font-face {
	font-family: IRANSansX;
	font-style: normal;
	font-weight: 300;
	src: url('/assets/IRANSansXFaNum-Light.woff') format('woff'),
	url('/assets/IRANSansXFaNum-Light.woff2') format('woff2');
}

@font-face {
	font-family: IRANSansX;
	font-style: normal;
	font-weight: 500;
	src: url('/assets/IRANSansXFaNum-Medium.woff') format('woff'),
	url('/assets/IRANSansXFaNum-Medium.woff2') format('woff2');
}

@font-face {
	font-family: IRANSansX;
	font-style: normal;
	font-weight: 600;
	src: url('/assets/IRANSansXFaNum-DemiBold.woff') format('woff'),
	url('/assets/IRANSansXFaNum-DemiBold.woff2') format('woff2');
}

@font-face {
	font-family: IRANSansX;
	font-style: normal;
	font-weight: 800;
	src: url('/assets/IRANSansXFaNum-ExtraBold.woff') format('woff'),
	url('/assets/IRANSansXFaNum-ExtraBold.woff2') format('woff2');
}

@font-face {
	font-family: IRANSansX;
	font-style: normal;
	font-weight: 900;
	src: url('/assets/IRANSansXFaNum-Black.woff') format('woff'),
	url('/assets/IRANSansXFaNum-Black.woff2') format('woff2');
}

@font-face {
	font-family: IRANSansX;
	font-style: normal;
	font-weight: 950;
	src: url('/assets/IRANSansXFaNum-ExtraBlack.woff') format('woff'),
	url('/assets/IRANSansXFaNum-ExtraBlack.woff2') format('woff2');
}

@font-face {
	font-family: IRANSansX;
	font-style: normal;
	font-weight: 1000;
	src: url('/assets/IRANSansXFaNum-Heavy.woff') format('woff'),
	url('/assets/IRANSansXFaNum-Heavy.woff2') format('woff2');
}

@font-face {
	font-family: IRANSansX;
	font-style: normal;
	font-weight: bold;
	src: url('/assets/IRANSansXFaNum-Bold.woff') format('woff'),
	url('/assets/IRANSansXFaNum-Bold.woff2') format('woff2');
}

@font-face {
	font-family: IRANSansX;
	font-style: normal;
	font-weight: normal;
	src: url('/assets/IRANSansXFaNum-Regular.woff') format('woff'),
	url('/assets/IRANSansXFaNum-Regular.woff2') format('woff2');
}

:root {
  --bg: #f5f6fa;
  --sidebar-bg: #161c2d;
  --sidebar-hover: #232b42;
  --sidebar-active: #3b6fed;
  --text: #1c2333;
  --muted: #8a90a2;
  --border: #e7e9f0;
  --card-bg: #ffffff;
  --primary: #3b6fed;
  --primary-dark: #2c56c4;
  --success: #17a768;
  --danger: #e5484d;
  --warning: #d9a406;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20,24,40,.04), 0 2px 8px rgba(20,24,40,.04);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: IRANSansX, Tahoma, sans-serif;
  background: var(--bg);
  margin: 0;
  direction: rtl;
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* ---------- ساختار کلی: سایدبار + محتوا ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  color: #cfd3e0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .brand {
  padding: 22px 20px 16px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .brand small { display: block; font-weight: 400; font-size: 11px; color: #8b93ab; margin-top: 4px; }
.sidebar nav { flex: 1; padding: 10px 0; }
.sidebar .nav-section-label {
  padding: 14px 20px 6px; font-size: 11px; color: #5f6785; text-transform: uppercase; letter-spacing: .04em;
}
.sidebar a.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; color: #b7bdd1; font-size: 13.5px;
  border-right: 3px solid transparent;
  transition: background .12s, color .12s;
}
.sidebar a.nav-link .ico { width: 18px; text-align: center; opacity: .85; }
.sidebar a.nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar a.nav-link.active {
  background: var(--sidebar-hover); color: #fff; border-right-color: var(--sidebar-active);
}
.sidebar .logout-link { margin-top: auto; padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar .logout-link a { color: #ff8f8f; font-size: 13px; }

.content-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 60px; flex-shrink: 0;
  background: var(--card-bg); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 16px; margin: 0; font-weight: 700; }
.topbar .topbar-right { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--muted); }
.topbar .store-chip {
  background: #eef2ff; color: var(--primary-dark); padding: 5px 12px; border-radius: 20px; font-size: 12.5px;
}

.main { flex: 1; padding: 24px; max-width: 1180px; width: 100%; margin: 0 auto; }

/* ---------- کارت‌ها ---------- */
.card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 14px; font-size: 15px; font-weight: 700; }
.card h4 { margin: 16px 0 8px; font-size: 13.5px; font-weight: 700; color: var(--text); }
.card-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-header-row h3 { margin: 0; }

/* ---------- فرم‌ها ---------- */
label { font-size: 12.5px; color: #5b6072; display: block; margin: 0 0 5px; font-weight: 500; }
input, select, textarea {
  font-family: inherit; width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 16px; background: #fbfbfd; margin-bottom: 12px;
  transition: border-color .12s, background .12s;
  -webkit-appearance: none;
  appearance: none;
  -webkit-text-size-adjust: 100%;
}
/* دسکتاپ می‌تواند کمی کوچک‌تر باشد؛ روی موبایل/آیفون حداقل ۱۶px تا زوم نشود */
@media (min-width: 768px) {
  input, select, textarea { font-size: 14px; }
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); background: #fff;
}
/* جلوگیری از استایل پیش‌فرض عجیب iOS روی دکمه‌ها و select */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236B7390' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 32px;
}
input[type="file"] { font-size: 14px; }

/* رادیو و چک‌باکس باید ظاهر پیش‌فرض مرورگر (نقطه/تیک) داشته باشند */
input[type="radio"],
input[type="checkbox"] {
  -webkit-appearance: auto !important;
  appearance: auto !important;
  width: auto !important;
  min-width: 16px !important;
  height: auto !important;
  min-height: 16px !important;
  margin: 0 0 0 0 !important;
  margin-inline-end: 6px !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  flex-shrink: 0;
  vertical-align: middle;
  accent-color: var(--primary, #3b6fed);
}
label:has(> input[type="radio"]),
label:has(> input[type="checkbox"]) {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  margin-bottom: 0;
  font-weight: 500;
}

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 16px; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }

/* ---------- ادیتور متن غنی ---------- */
.rich-editor-wrapper {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfbfd;
  margin-bottom: 12px;
  overflow: hidden;
}
.rich-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: #f4f5f8;
}
.rich-editor-toolbar select,
.rich-editor-toolbar input,
.rich-editor-toolbar button {
  width: auto;
  margin: 0;
  flex: 0 0 auto;
}
.rich-editor-toolbar select.re-format {
  min-width: 110px;
  padding: 5px 8px;
  font-size: 12.5px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
}
.rich-editor-toolbar button {
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 600;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 32px;
  justify-content: center;
}
.rich-editor-toolbar button:hover {
  background: #eef0f5;
}
.rich-editor-toolbar input.re-color {
  width: 32px;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}
.rich-editor-content {
  min-height: 140px;
  padding: 12px 14px;
  outline: none;
  font-size: 13.5px;
  line-height: 1.9;
  background: #fff;
  direction: rtl;
  text-align: right;
}
.rich-editor-content:focus {
  background: #fff;
}
.rich-editor-content img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

/* ---------- دکمه‌ها ---------- */
button, .btn {
  font-family: inherit; border: none; cursor: pointer; border-radius: 8px;
  padding: 9px 18px; font-size: 13.5px; font-weight: 600; display: inline-flex;
  align-items: center; gap: 6px; transition: transform .05s, opacity .12s, background .12s;
}
button.btn, a.btn { background: var(--primary); color: #fff; }
button.btn:hover, a.btn:hover { background: var(--primary-dark); }
button.btn:active { transform: translateY(1px); }
button.btn.secondary { background: #eef0f5; color: var(--text); }
button.btn.secondary:hover { background: #e2e5ee; }
button.btn.danger { background: #fdeceb; color: var(--danger); }
button.btn.danger:hover { background: var(--danger); color: #fff; }
button.btn.success { background: #e7f8ef; color: var(--success); }
button.btn.success:hover { background: var(--success); color: #fff; }
button.btn.sm { padding: 5px 11px; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- جدول‌ها ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .02em; }
tbody tr:hover { background: #fafbff; }
td.empty-row { text-align: center; color: var(--muted); padding: 26px; }

/* ---------- بج / نشان وضعیت ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.badge.green { background: #e7f8ef; color: var(--success); }
.badge.red { background: #fdeceb; color: var(--danger); }
.badge.gray { background: #eef0f5; color: #626a80; }
.badge.yellow { background: #fdf6df; color: var(--warning); }

/* ---------- صفحه ورود ---------- */
.login-wrap {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: linear-gradient(160deg, #161c2d, #263257 60%, #3b6fed);
  padding: 20px;
}
.login-box {
  background: #fff; padding: 34px 30px; border-radius: 16px; width: 100%; max-width: 380px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.login-box .login-title { text-align: center; margin-bottom: 4px; font-size: 19px; font-weight: 800; }
.login-box .login-sub { text-align: center; color: var(--muted); font-size: 12.5px; margin-bottom: 22px; }
.tabs { display: flex; gap: 6px; margin-bottom: 18px; background: #f2f3f8; padding: 4px; border-radius: 10px; }
.tabs button {
  flex: 1; padding: 8px; border: none; background: transparent; border-radius: 7px;
  cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--muted);
}
.tabs button.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); }

/* ---------- حالت خالی/بارگذاری ---------- */
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state .ico { font-size: 30px; margin-bottom: 10px; }
.skeleton { color: var(--muted); font-size: 13px; padding: 10px 0; }

/* ---------- نوار خطای اتصال ---------- */
#connectionBanner {
  display: none; background: #fff4e5; border: 1px solid #f3c980; color: #8a5a00;
  padding: 12px 18px; border-radius: 10px; margin-bottom: 18px; font-size: 13px; line-height: 1.9;
}
#connectionBanner.show { display: block; }
#connectionBanner code { background: #fff; padding: 1px 6px; border-radius: 4px; }

.muted { color: var(--muted); font-size: 12.5px; }
.hidden { display: none !important; }
.grid-images { display: flex; gap: 10px; flex-wrap: wrap; }
.grid-images .img-box { position: relative; }
.grid-images img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.grid-images .img-box button {
  position: absolute; top: 4px; left: 4px; padding: 2px 8px; font-size: 10.5px;
}




/* ===== Desktop RTL placement ===== */
@media (min-width: 901px) {
  .app-shell {
    display: flex !important;
    flex-direction: row !important;
    direction: rtl !important;
    width: 100%;
  }

  .sidebar {
    order: 1 !important;
    position: sticky !important;
    top: 0 !important;
    right: auto !important;
    left: auto !important;
    flex: 0 0 260px !important;
  }

  .content-area {
    order: 2 !important;
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 0 !important;
  }

  .sidebar-overlay {
    display: none !important;
  }
}

/* ===== Responsive dashboard — clean unified layout ===== */
.app-shell{
  min-height:100vh;
  display:flex;
  flex-direction:row;
  width:100%;
  direction:rtl;
}
.sidebar{
  width:260px;
  min-width:260px;
  height:100vh;
  position:sticky;
  top:0;
  right:0;
  z-index:1000;
  overflow-y:auto;
  overflow-x:hidden;
  background:var(--sidebar-bg);
}
.content-area{
  flex:1 1 auto;
  min-width:0;
  width:calc(100% - 260px);
}
.topbar{
  min-height:64px;
  height:auto;
  padding:10px 22px;
  gap:12px;
  position:sticky;
  top:0;
  z-index:900;
}
.topbar h1{flex:0 0 auto;white-space:nowrap}
.topbar-right{min-width:0;display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.main{width:100%;max-width:1280px;padding:22px;margin:0 auto}
.card{min-width:0;overflow:hidden}
.form-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
.form-grid>div{min-width:0}
input,select,textarea,button{max-width:100%}
textarea{resize:vertical}
.table-wrap{width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
table{min-width:620px}
.seo-help{
  margin:0 0 16px;
  padding:12px 14px;
  border-right:3px solid #E8B23A;
  background:linear-gradient(135deg,#FFFBF0 0%,#F7F9FC 100%);
  border-radius:10px;
  font-size:12.5px;
  line-height:1.9;
  color:#0B1A4A;
  border:1px solid #F0E0B0;
  border-right-width:3px;
  border-right-color:#E8B23A;
}
.seo-help b{color:#0B1A4A;font-weight:800}
.mobile-menu-btn{
  display:none;
  flex:0 0 42px;
  width:42px;
  height:42px;
  padding:0;
  justify-content:center;
  align-items:center;
  background:#eef2ff!important;
  color:var(--primary)!important;
  border:1px solid var(--border)!important;
  font-size:20px;
  border-radius:9px;
}
.sidebar-close{display:none}
.sidebar-overlay{display:none}

@media (max-width:1100px){
  .sidebar{width:230px;min-width:230px}
  .content-area{width:calc(100% - 230px)}
  .main{padding:18px}
}

@media (max-width:900px){
  body{overflow-x:hidden}
  .app-shell{display:block;min-height:100vh}
  .content-area{width:100%;min-width:0}
  .sidebar{
    position:fixed;
    top:0;
    right:0;
    bottom:0;
    width:290px;
    max-width:86vw;
    min-width:0;
    height:100dvh;
    transform:translateX(105%);
    transition:transform .22s ease;
    box-shadow:-12px 0 35px rgba(0,0,0,.20);
    z-index:1100;
  }
  .sidebar.open{transform:translateX(0)}
  .sidebar .brand{
    display:block;
    padding:20px 18px 14px;
  }
  .sidebar .nav-section-label{display:block;padding:13px 18px 6px}
  .sidebar nav{display:block;padding:7px 0 80px}
  .sidebar a.nav-link{
    display:flex;
    width:100%;
    min-height:44px;
    padding:10px 18px;
    border-right:3px solid transparent;
    border-bottom:0;
    white-space:normal;
  }
  .sidebar a.nav-link.active{border-right-color:var(--sidebar-active)}
  .sidebar .logout-link{display:block;position:relative;flex:0 0 auto;background:var(--sidebar-bg)}
  .sidebar-close{
    display:flex!important;
    position:absolute;
    top:13px;
    left:12px;
    width:36px;
    height:36px;
    padding:0;
    justify-content:center;
    align-items:center;
    background:rgba(255,255,255,.08)!important;
    color:#fff!important;
    border:1px solid rgba(255,255,255,.12)!important;
  }
  .sidebar-overlay{
    display:block;
    position:fixed;
    inset:0;
    background:rgba(8,12,25,.48);
    opacity:0;
    visibility:hidden;
    pointer-events:none;
    transition:.22s ease;
    z-index:1050;
  }
  .sidebar-overlay.open{opacity:1;visibility:visible;pointer-events:auto}
  .topbar{
    min-height:60px;
    padding:9px 12px;
    gap:9px;
  }
  .mobile-menu-btn{display:inline-flex!important}
  .topbar h1{font-size:15px;flex:1;overflow:hidden;text-overflow:ellipsis}
  .topbar-right{font-size:11px;justify-content:flex-start}
  .topbar-right .store-chip{display:none}
  .topbar-right #viewStoreBtn{display:inline-flex;align-items:center;font-size:11px;padding:5px 10px;white-space:nowrap}
  .main{padding:12px}
  .card{padding:15px 13px;margin-bottom:12px;border-radius:10px}
  .card-header-row{align-items:flex-start;gap:10px;flex-wrap:wrap}
  .form-grid{grid-template-columns:1fr!important;gap:0}
  .seo-help{font-size:12px;padding:9px 10px;margin-bottom:12px}
  .table-wrap{margin:0;width:100%;overflow:visible}
  .grid-images img{width:78px;height:78px}
  .rich-editor-toolbar{max-height:none}
  .rich-editor-content{min-height:150px}
}

@media (max-width:480px){
  .topbar h1{font-size:14px}
  .main{padding:9px}
  .card{padding:13px 10px}
  button,.btn{font-size:12.5px;padding:9px 13px}
  input,select,textarea{font-size:13px}
  .login-box{padding:25px 18px}
}


/* ---------- فارسی و راهنمای اختصاصی سئو ---------- */
html[lang^="fa"], html[lang^="fa"] body { direction: rtl; text-align: right; }
html[lang^="fa"] body, html[lang^="fa"] input, html[lang^="fa"] select, html[lang^="fa"] textarea, html[lang^="fa"] button { font-family:IRANSansX,Tahoma,Arial,sans-serif; }
html[lang^="fa"] input:not([dir="ltr"]), html[lang^="fa"] select:not([dir="ltr"]), html[lang^="fa"] textarea:not([dir="ltr"]) { direction:rtl; text-align:right; }
html[lang^="fa"] .sidebar { order:0; }
html[lang^="fa"] .content-area { direction:rtl; }
html[lang^="fa"] .nav-section-label { text-transform:none; letter-spacing:0; text-align:right; }
html[lang^="fa"] th { text-transform:none; letter-spacing:0; }
.seo-field-label { margin:0 0 6px; }
.seo-label-row { display:flex; align-items:center; justify-content:flex-start; gap:7px; width:100%; min-width:0; }
.seo-label-text { min-width:0; line-height:1.8; }
.seo-field-tip {
  position:relative;
  flex:0 0 auto;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:auto;
  height:auto;
  padding:4px 9px;
  border-radius:8px;
  background: linear-gradient(135deg, #ffffff 0%, #ffaf00 100%);
  color:#0B1A4A;
  font-size:11px;
  font-weight:800;
  white-space:nowrap;
  cursor:help;
  user-select:none;
  box-shadow:0 2px 6px rgba(201,146,26,.35);
  transition:transform .15s ease, box-shadow .15s ease;
}
.seo-field-tip:hover,
.seo-field-tip:focus {
  transform:translateY(-1px);
  box-shadow:0 4px 12px rgba(201,146,26,.45);
  outline:none;
}
.seo-field-tip::after { content:none; }
.seo-field-bubble {
  position:absolute;
  z-index:2000;
  top:calc(100% + 10px);
  right:0;
  width:min(360px,calc(100vw - 36px));
  padding:14px 16px;
  border:1.5px solid #E8B23A;
  border-radius:12px;
  background:linear-gradient(180deg,#FFFDF7 0%,#FFFFFF 40%);
  color:#0B1A4A;
  box-shadow:0 12px 32px rgba(11,26,74,.18), 0 0 0 4px rgba(232,178,58,.12);
  font-size:13px;
  font-weight:500;
  line-height:1.95;
  text-align:right;
  white-space:pre-line;
  opacity:0;
  visibility:hidden;
  transform:translateY(-6px);
  transition:.18s ease;
  pointer-events:none;
}
.seo-field-bubble::before {
  content:'';
  position:absolute;
  top:-7px;
  right:14px;
  width:12px;
  height:12px;
  background:#FFFDF7;
  border-top:1.5px solid #E8B23A;
  border-right:1.5px solid #E8B23A;
  transform:rotate(-45deg);
}
.seo-field-tip:hover .seo-field-bubble,
.seo-field-tip:focus .seo-field-bubble,
.seo-field-tip.is-open .seo-field-bubble {
  opacity:1;
  visibility:visible;
  transform:translateY(0);
  pointer-events:auto;
}
@media (max-width:720px){
  /* حباب داخل کارت روی موبایل استفاده نمی‌شود؛ پنل body باز می‌شود */
  .seo-field-bubble{
    display:none !important;
  }
  .seo-label-row{gap:6px; flex-wrap:wrap;}
  .seo-field-tip{
    min-width:auto;
    height:auto;
    padding:4px 8px;
    font-size:10.5px;
  }
}

/* پنل آموزش سئو — فیکس پایین صفحه (موبایل) */
#seoHintSheet{
  display:none;
  position:fixed;
  inset:0;
  z-index:5000;
  pointer-events:none;
}
#seoHintSheet.open{
  display:block;
  pointer-events:auto;
}
.seo-sheet-backdrop{
  position:absolute;
  inset:0;
  background:rgba(11,26,74,.45);
}
.seo-sheet-panel{
  position:absolute;
  left:0;
  right:0;
  bottom:0;
  max-height:min(55vh, 420px);
  overflow:auto;
  -webkit-overflow-scrolling:touch;
  background:#FFFDF7;
  border-radius:18px 18px 0 0;
  border-top:2px solid #E8B23A;
  box-shadow:0 -12px 40px rgba(11,26,74,.22);
  padding:0 0 max(16px, env(safe-area-inset-bottom));
  color:#0B1A4A;
}
.seo-sheet-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:14px 16px 10px;
  border-bottom:1px solid #F0E0B0;
  position:sticky;
  top:0;
  background:#FFFDF7;
  z-index:1;
}
.seo-sheet-head strong{
  font-size:15px;
  font-weight:800;
  color:#0B1A4A;
}
.seo-sheet-close{
  width:36px;
  height:36px;
  border:0;
  border-radius:10px;
  background:#F5E6C0;
  color:#0B1A4A;
  font-size:22px;
  line-height:1;
  cursor:pointer;
  flex-shrink:0;
}
.seo-sheet-body{
  padding:14px 18px 8px;
  font-size:14.5px;
  font-weight:500;
  line-height:2;
  text-align:right;
  word-wrap:break-word;
  overflow-wrap:anywhere;
  white-space:pre-line;
}
body.seo-sheet-open{
  overflow:hidden;
}


/* =========================================================
   RTL FINAL OVERRIDE — پنل فارسی
   این بخش عمداً در انتهای فایل قرار گرفته تا هیچ استایل قبلی
   نتواند جهت پنل را به LTR برگرداند.
   ========================================================= */

html,
html[dir="rtl"] {
  direction: rtl !important;
  text-align: right;
}

body,
body * {
  direction: inherit;
}

body {
  direction: rtl !important;
  text-align: right !important;
  font-family: IRANSansX, Tahoma, Arial, sans-serif !important;
}

/* ساختار اصلی: سایدبار همیشه سمت راست */
.app-shell {
  direction: rtl !important;
  display: flex !important;
  flex-direction: row !important;
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  order: 2 !important;
  direction: rtl !important;
  text-align: right !important;
  right: 0;
  left: auto;
}

.content-area {
  order: 1 !important;
  direction: rtl !important;
  text-align: right !important;
  min-width: 0;
}

/* هدر */
.topbar {
  direction: rtl !important;
  text-align: right !important;
  flex-direction: row !important;
}

.topbar h1 {
  text-align: right !important;
}

.topbar-right {
  direction: rtl !important;
  text-align: right !important;
}

/* محتوای اصلی */
.main,
.card,
.card-header-row,
.form-grid,
.form-row,
.form-actions {
  direction: rtl !important;
  text-align: right !important;
}

/* فرم‌ها */
label {
  direction: rtl !important;
  text-align: right !important;
}

input,
select,
textarea {
  direction: rtl;
  text-align: right;
}

/* فقط ورودی‌های کد، URL و مواردی که عمداً LTR هستند
   با dir="ltr" خود HTML قابل override شدن نیستند. */
input[dir="ltr"],
textarea[dir="ltr"],
code,
pre,
.ltr,
[dir="ltr"] {
  direction: ltr;
  text-align: left;
}

/* جدول‌ها */
table,
thead,
tbody,
tr,
th,
td {
  direction: rtl !important;
}

th,
td {
  text-align: right !important;
}

/* دکمه‌ها و کنترل‌ها */
button,
.btn {
  direction: rtl;
}

button,
.btn,
a {
  unicode-bidi: plaintext;
}

/* منوی سایدبار */
.sidebar nav,
.sidebar .nav-section-label,
.sidebar a.nav-link,
.sidebar .logout-link {
  direction: rtl !important;
  text-align: right !important;
}

.sidebar a.nav-link {
  flex-direction: row !important;
  justify-content: flex-start;
}

.sidebar a.nav-link .ico {
  flex: 0 0 18px;
}

/* لیست‌ها و متن‌ها */
ul,
ol,
li,
p,
h1,
h2,
h3,
h4,
h5,
h6 {
  direction: rtl;
  text-align: right;
}

/* عناصر عددی/سیستمی که نباید برعکس شوند */
input[type="number"],
input[type="tel"],
input[type="email"],
input[type="url"] {
  direction: ltr;
  text-align: left;
}

/* موبایل */
@media (max-width: 900px) {
  .app-shell {
    flex-direction: row !important;
  }

  .content-area {
    width: 100%;
  }

  .topbar {
    padding: 0 14px;
  }

  .main {
    padding: 14px;
  }

  .card {
    padding: 16px;
  }

  .form-grid {
    grid-template-columns: 1fr !important;
  }
}


/* ===== FINAL DESKTOP RTL SIDEBAR FIX ===== */
@media (min-width: 901px) {
  html, body {
    direction: rtl !important;
  }

  .app-shell {
    display: block !important;
    width: 100% !important;
    min-height: 100vh !important;
    direction: rtl !important;
  }

  .sidebar {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    left: auto !important;
    bottom: 0 !important;
    width: 260px !important;
    min-width: 260px !important;
    height: 100vh !important;
    z-index: 1100 !important;
    transform: none !important;
    order: initial !important;
  }

  .content-area {
    display: flex !important;
    width: auto !important;
    min-width: 0 !important;
    margin-right: 260px !important;
    margin-left: 0 !important;
    direction: rtl !important;
  }

  .sidebar-overlay {
    display: none !important;
  }
}

@media (min-width: 901px) and (max-width: 1100px) {
  .sidebar {
    width: 230px !important;
    min-width: 230px !important;
  }

  .content-area {
    margin-right: 230px !important;
  }
}


/* ===== FINAL MOBILE SIDEBAR BEHAVIOR ===== */
@media (max-width: 900px) {
  .app-shell {
    display: block !important;
    width: 100% !important;
    direction: rtl !important;
  }

  .content-area {
    width: 100% !important;
    margin-right: 0 !important;
    margin-left: 0 !important;
  }

  .sidebar {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    left: auto !important;
    bottom: 0 !important;
    width: 290px !important;
    max-width: 86vw !important;
    min-width: 0 !important;
    height: 100dvh !important;
    transform: translateX(105%) !important;
  }

  .sidebar.open {
    transform: translateX(0) !important;
  }
}


/* حباب سئو دسکتاپ — روی body تا overflow کارت آن را نبرد */
.seo-desktop-bubble{
  position:fixed;
  z-index:5000;
  max-width:min(380px, calc(100vw - 24px));
  box-sizing:border-box;
  padding:0;
  pointer-events:auto;
}
.seo-desktop-bubble-inner{
  box-sizing:border-box;
  width:100%;
  max-width:100%;
  padding:14px 16px;
  border:1.5px solid #E8B23A;
  border-radius:12px;
  background:linear-gradient(180deg,#FFFDF7 0%,#FFFFFF 45%);
  color:#0B1A4A;
  box-shadow:0 12px 32px rgba(11,26,74,.18), 0 0 0 4px rgba(232,178,58,.12);
  white-space:pre-line;
  line-height:1.95;
  font-size:13px;
  text-align:right;
  font-size:13.5px;
  font-weight:500;
  line-height:1.95;
  text-align:right;
  white-space:normal;
  word-wrap:break-word;
  overflow-wrap:anywhere;
  hyphens:auto;
}
/* حباب داخل‌کارت روی دسکتاپ دیگر نمایش داده نمی‌شود (از portal استفاده می‌شود) */
@media (min-width:721px){
  .seo-field-tip .seo-field-bubble{
    display:none !important;
  }
}


/* =========================================================
   mobile-table-cards — جداول داشبورد به کارت در موبایل
   ========================================================= */
@media (max-width: 720px) {
  .table-wrap {
    overflow: visible !important;
    width: 100% !important;
    margin: 0 !important;
  }

  .card table,
  .table-wrap table,
  table {
    min-width: 0 !important;
    width: 100% !important;
    border: 0 !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
  }

  table thead {
    display: none !important;
  }

  table tbody {
    display: block;
    width: 100%;
  }

  table tbody tr {
    display: block;
    width: 100%;
    box-sizing: border-box;
    background: linear-gradient(145deg, #FFFDF8 0%, #F5F7FC 55%, #EEF2FA 100%);
    border: 1px solid #E8D9A8;
    border-radius: 14px;
    padding: 12px 14px 10px;
    margin: 0 0 12px;
    box-shadow: 0 2px 10px rgba(11, 26, 74, 0.05);
  }

  table tbody tr:last-child {
    margin-bottom: 0;
  }

  table tbody td {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    border: 0 !important;
    padding: 8px 0 !important;
    text-align: right !important;
    white-space: normal !important;
    word-break: break-word;
    overflow-wrap: anywhere;
    font-size: 14px;
    color: #0B1A4A;
    background: transparent !important;
    line-height: 1.7;
  }

  table tbody td[data-label]::before {
    content: attr(data-label) ": ";
    display: inline;
    font-weight: 800;
    color: #132560;
    font-size: 12.5px;
    margin-left: 4px;
  }

  /* سلول عملیات — بدون برچسب «عملیات» اجباری روی هر دکمه */
  table tbody td.row-actions[data-label]::before,
  table tbody td:last-child[data-label]::before {
    content: none;
  }

  table tbody td.row-actions,
  table tbody td:last-child {
    display: flex !important;
    flex-wrap: wrap;
    gap: 10px;
    align-items: stretch;
    margin-top: 10px;
    padding-top: 14px !important;
    border-top: 1px solid #F0E0B0 !important;
  }

  table tbody td.row-actions .btn,
  table tbody td.row-actions button,
  table tbody td.row-actions a.btn,
  table tbody td:last-child .btn,
  table tbody td:last-child button,
  table tbody td:last-child a.btn {
    flex: 1 1 calc(50% - 10px);
    min-width: 130px;
    min-height: 44px;
    padding: 11px 14px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    text-align: center;
    justify-content: center;
    align-items: center;
    display: inline-flex !important;
    margin: 0 !important;
    border-radius: 10px !important;
  }

  table tbody td:last-child .btn:only-child,
  table tbody td.row-actions .btn:only-child {
    flex: 1 1 100%;
    min-width: 100%;
  }

  .view-page-btn,
  a.view-page-btn {
    background: var(--primary, #3b6fed) !important;
    color: #fff !important;
    border: 0 !important;
  }
  .view-page-btn:hover,
  a.view-page-btn:hover {
    background: var(--primary-dark, #2c56c4) !important;
    color: #fff !important;
  }

  /* تصاویر داخل جدول کارت */
  table tbody td img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
  }

  /* صفحه‌بندی سرجایش بماند */
  .pagination,
  nav.pagination,
  .pager,
  [class*="pagination"] {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
  }
}


/* خطای اعتبارسنجی فیلد اجباری */
input.field-error,
textarea.field-error,
select.field-error {
  border-color: #d9363e !important;
  box-shadow: 0 0 0 3px rgba(217, 54, 62, 0.15) !important;
  background: #fff8f8 !important;
}
.req { color: #d9363e; font-weight: 700; }


/* Badge تعداد کنار لینک‌های سایدبار (کامنت‌های جدید / فاکتورهای جدید) */
.sidebar a.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar a.nav-link .nav-label {
  flex: 1;
  min-width: 0;
}
.sidebar a.nav-link .nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #e74c3c;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}
.comment-pending-row td {
  background: #fff8f0;
}
.comment-reply-preview {
  margin-top: 6px;
  padding: 6px 8px;
  background: #f4f6fb;
  border-radius: 6px;
  font-size: 12.5px;
  color: #445;
}


/* صفحه‌بندی کامنت‌ها و لینک عنوان */
.comments-pager-wrap { margin-top: 12px; }
.comments-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
}
.comments-pager-info { color: #626a80; }
.comment-item-link {
  color: var(--primary, #3b6ef5);
  text-decoration: none;
  font-weight: 600;
}
.comment-item-link:hover { text-decoration: underline; }

.invoice-cancelled-row td { opacity: .65; }

.invoice-unpaid-row td { background: #fff8f0; }



/* =========================================================
   MOBILE SIDEBAR — ترتیب لینک‌ها دقیقاً مثل دسکتاپ (DOM order)
   ساختار: brand (ثابت) → nav (اسکرول) → logout (ثابت پایین)
   هیچ order روی لینک‌های منو اعمال نمی‌شود.
   ========================================================= */
@media (max-width: 900px) {
  .sidebar {
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    overflow: hidden !important;
    -webkit-overflow-scrolling: auto;
  }

  .sidebar .brand {
    flex: 0 0 auto !important;
    position: relative !important;
    z-index: 2;
  }

  .sidebar .sidebar-close {
    position: absolute !important;
    top: 13px !important;
    left: 12px !important;
    z-index: 5 !important;
  }

  /* فقط لیست لینک‌ها اسکرول می‌شود — ترتیب DOM حفظ می‌شود */
  .sidebar nav#sidebarNav,
  .sidebar nav {
    display: block !important;          /* block = ترتیب سند، بدون flex reorder */
    flex: 1 1 auto !important;
    min-height: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 8px 0 12px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    float: none !important;
    column-count: 1 !important;
    columns: auto !important;
  }

  .sidebar .nav-section-label {
    display: block !important;
    width: 100% !important;
    float: none !important;
    clear: both !important;
  }

  .sidebar a.nav-link {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: 44px !important;
    margin: 0 !important;
    float: none !important;
    clear: both !important;
    position: relative !important;
    box-sizing: border-box !important;
    order: unset !important;
  }

  .sidebar a.nav-link .ico {
    flex: 0 0 22px !important;
    text-align: center !important;
  }

  .sidebar a.nav-link .nav-label {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    white-space: normal !important;
    text-align: right !important;
  }

  .sidebar a.nav-link .nav-badge {
    flex: 0 0 auto !important;
  }

  /* خروج: پایین ثابت، بدون absolute تا روی لینک‌ها نیفتد */
  .sidebar .logout-link {
    display: block !important;
    position: relative !important;
    bottom: auto !important;
    right: auto !important;
    left: auto !important;
    flex: 0 0 auto !important;
    margin-top: 0 !important;
    padding: 14px 18px !important;
    border-top: 1px solid rgba(255,255,255,.08) !important;
    background: var(--sidebar-bg, #161c2d) !important;
    z-index: 2;
  }
}
