/* =====================================================================
   داشبورد سئو 90 روزه — استایل‌ها (RTL)
   ===================================================================== */

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Tahoma', 'Segoe UI', sans-serif;
  background: #f6f8fb;
  color: #2c3345;
  line-height: 1.7;
  direction: rtl;
}

[hidden] { display: none !important; }

/* =====================================================================
   ورود / ثبت‌نام
   ===================================================================== */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #eef3fa, #e3ebf7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.auth-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(20, 50, 100, .12);
  padding: 28px 26px;
  width: 100%;
  max-width: 380px;
}
.auth-card h2 { color: #1d4ed8; text-align: center; margin-bottom: 6px; font-size: 1.3rem; }
.auth-sub { text-align: center; color: #64748b; margin-bottom: 18px; font-size: .9rem; }

.auth-form label { display: block; margin: 12px 0 6px; font-size: .85rem; color: #334155; }
.auth-form input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid #d7dee8;
  border-radius: 10px;
  font-family: inherit;
  font-size: .95rem;
  background: #fff;
}
.auth-form input:focus { border-color: #1d4ed8; box-shadow: 0 0 0 3px rgba(29, 78, 216, .12); outline: none; }
.auth-form button {
  width: 100%;
  margin-top: 18px;
  background: #1d4ed8;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-family: inherit;
  font-size: .95rem;
  cursor: pointer;
  transition: background .15s ease;
}
.auth-form button:hover { background: #1e40af; }
.auth-err { color: #dc2626; font-size: .82rem; margin-top: 10px; min-height: 1.2em; text-align: center; }
.auth-note {
  background: #eef6ff;
  border: 1px solid #cfe3fb;
  border-radius: 10px;
  padding: 10px 14px;
  color: #1e40af;
  font-size: .85rem;
  margin-bottom: 4px;
}

/* ---------- هدر ---------- */
header {
  position: relative;
  background: linear-gradient(135deg, #ffffff, #eef3fa);
  border-bottom: 1px solid #dfe6ef;
  padding: 26px 20px 20px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(30, 60, 120, .06);
}
header h1 { color: #1d4ed8; font-size: 1.6rem; margin-bottom: 8px; }
#statusSummary { color: #64748b; font-size: .95rem; }

/* ---------- تب‌ها ---------- */
.tabs {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  background: rgba(246, 248, 251, .95);
  backdrop-filter: blur(6px);
  padding: 14px;
  z-index: 50;
  border-bottom: 1px solid #e2e8f0;
}
.tab-btn {
  background: #fff;
  border: 1px solid #dbe3ee;
  border-radius: 12px;
  padding: 10px 22px;
  font-family: inherit;
  font-size: .95rem;
  cursor: pointer;
  color: #334155;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .05);
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.tab-btn:hover { background: #eff6ff; color: #1d4ed8; }
.tab-btn.active { background: #1d4ed8; color: #fff; border-color: #1d4ed8; }

main { max-width: 1300px; margin: 0 auto; padding: 24px 16px 60px; }

.tab-panel { display: none; animation: fade .3s ease; }
.tab-panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- جستجو و شمارنده ---------- */
.search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 12px;
  flex-wrap: wrap;
}
.search-wrap input {
  flex: 1;
  min-width: 220px;
  max-width: 460px;
  padding: 11px 16px;
  border: 1px solid #d7dee8;
  border-radius: 10px;
  font-family: inherit;
  font-size: .95rem;
  background: #fff;
  outline: none;
  transition: .2s;
}
.search-wrap input:focus { border-color: #1d4ed8; box-shadow: 0 0 0 3px rgba(29, 78, 216, .12); }
.count { color: #64748b; font-size: .85rem; }

.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  color: #475569;
  font-size: .85rem;
  margin: 0 0 14px;
}
.legend span { white-space: nowrap; }

/* ---------- جدول ---------- */
.tbl-wrap {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(20, 50, 100, .05);
  overflow: auto;
}
table { width: 100%; border-collapse: collapse; font-size: .86rem; }

thead th {
  position: sticky;
  top: 0;
  background: #f0f5fc;
  color: #1e3a8a;
  padding: 12px 10px;
  text-align: right;
  border-bottom: 2px solid #d6e2f3;
  z-index: 5;
  font-weight: 700;
  white-space: nowrap;
}

tbody td {
  padding: 9px 10px;
  border-bottom: 1px solid #eef2f7;
  vertical-align: middle;
  white-space: nowrap;           /* همه ردیف‌ها تک‌خطی */
}
tbody tr:hover { background: #f4f8ff; }
tbody tr:nth-child(even) { background: #fafcff; }
tbody tr:nth-child(even):hover { background: #f4f8ff; }

/* ستون وضعیت — چسبان به لبه راست */
th.status-cell, td.status-cell { position: sticky; right: 0; z-index: 3; }
thead th.status-cell { background: #f0f5fc; z-index: 7; }
tbody td.status-cell {
  background: #fff;
  box-shadow: -8px 0 10px -8px rgba(15, 40, 90, .18);
}
tbody tr:nth-child(even) td.status-cell { background: #fafcff; }
tbody tr:hover td.status-cell,
tbody tr:nth-child(even):hover td.status-cell { background: #f4f8ff; }

/* ---------- دکمه وضعیت ---------- */
.status-btn {
  border: none;
  background: transparent;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  line-height: 1;
  transition: background .15s ease, transform .1s ease;
}
.status-btn:hover { background: #eef2ff; transform: scale(1.15); }
.status-icon {
  font-size: 1.3rem;
  line-height: 1;
  padding: 4px 8px;
  display: inline-block;
}

/* ---------- لینک پیشنهادی ---------- */
.link-cell { max-width: 260px; }
.link-cell a {
  display: inline-block;
  max-width: 230px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

/* ---------- ویرایش لینک (مدیر) ---------- */
.link-edit-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: .9rem;
  padding: 2px 6px;
  border-radius: 6px;
  line-height: 1;
  vertical-align: middle;
  transition: background .15s ease, transform .1s ease;
}
.link-edit-btn:hover { background: #eef2ff; transform: scale(1.15); }

.link-editor {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.link-editor input {
  width: 180px;
  padding: 5px 8px;
  border: 1px solid #d7dee8;
  border-radius: 7px;
  font-family: inherit;
  font-size: .82rem;
  direction: ltr;
  text-align: left;
}
.link-editor input:focus { border-color: #1d4ed8; box-shadow: 0 0 0 3px rgba(29, 78, 216, .12); outline: none; }
.link-edit-save {
  border: none;
  background: #16a34a;
  color: #fff;
  border-radius: 7px;
  padding: 5px 10px;
  font-family: inherit;
  font-size: .78rem;
  cursor: pointer;
}
.link-edit-save:hover { background: #15803d; }
.link-edit-cancel {
  border: 1px solid #d7dee8;
  background: #fff;
  color: #475569;
  border-radius: 7px;
  padding: 5px 10px;
  font-family: inherit;
  font-size: .78rem;
  cursor: pointer;
}
.link-edit-cancel:hover { background: #f1f5f9; }

a { color: #1d4ed8; text-decoration: none; border-bottom: 1px dashed #93b4f5; }
a:hover { color: #1e40af; }

/* ---------- راهنمای اجرا ---------- */
.guide-table td:first-child { font-weight: 700; color: #1e3a8a; white-space: nowrap; }

.note {
  background: #eef6ff;
  border: 1px solid #cfe3fb;
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 18px;
  color: #1e40af;
  font-size: .9rem;
}

/* ---------- پرامپت‌ها ---------- */
.prompt-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  margin-bottom: 22px;
  box-shadow: 0 2px 8px rgba(20, 50, 100, .05);
  overflow: hidden;
}
.prompt-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: #f7fafd;
  border-bottom: 1px solid #e8eef6;
}
.prompt-head h3 { font-size: .95rem; color: #334155; flex: 1; min-width: 220px; }
.phase-badge {
  background: #1d4ed8;
  color: #fff;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: .82rem;
  white-space: nowrap;
}
.copy-btn {
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 8px 16px;
  font-family: inherit;
  cursor: pointer;
  transition: background .2s ease;
  font-size: .85rem;
}
.copy-btn:hover { background: #15803d; }

.prompt-body {
  background: #fbfcfe;
  padding: 16px 18px;
  font-family: 'Tahoma', 'Segoe UI', monospace;
  font-size: .82rem;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 340px;
  overflow-y: auto;
  border-top: 1px solid #eef2f7;
  direction: rtl;
  text-align: right;
}

/* جدول مرجع فازها */
.ref-table { min-width: 520px; font-size: .88rem; }
.ref-table td { white-space: nowrap; }

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #16a34a;
  color: #fff;
  padding: 12px 22px;
  border-radius: 12px;
  font-family: inherit;
  font-size: .9rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 300;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
#toast.error { background: #dc2626; }

/* ---------- واکنش‌گرایی ---------- */
@media (max-width: 640px) {
  header h1 { font-size: 1.2rem; }
  .tab-btn { padding: 8px 14px; font-size: .85rem; }
}

/* ---------- دکمه کاربر (پایین چپ) ---------- */
.user-btn {
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 150;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid #dbe3ee;
  border-radius: 999px;
  padding: 9px 18px;
  font-family: inherit;
  font-size: .9rem;
  cursor: pointer;
  color: #1e3a8a;
  box-shadow: 0 4px 14px rgba(20, 50, 100, .14);
  transition: background .15s ease, box-shadow .15s ease;
}
.user-btn:hover { background: #eff6ff; box-shadow: 0 6px 18px rgba(20, 50, 100, .2); }
.user-btn-icon { font-size: 1.1rem; line-height: 1; }

/* ---------- مودال کاربر (سمت چپ) ---------- */
.user-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .28);
  z-index: 250;
}
.user-modal {
  position: absolute;
  bottom: 76px;
  left: 16px;
  width: 320px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(20, 50, 100, .25);
  display: flex;
  flex-direction: column;
}
.um-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 14px;
  background: #f7fafd;
  border-bottom: 1px solid #e8eef6;
}
.um-top-info { flex: 1; min-width: 0; }
.um-role { font-weight: 700; color: #1e3a8a; font-size: .95rem; }
.um-name { color: #64748b; font-size: .82rem; margin-top: 2px; word-break: break-word; }
.um-close {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: #94a3b8;
  padding: 4px 8px;
  border-radius: 8px;
  line-height: 1;
}
.um-close:hover { background: #eef2f7; color: #334155; }

.um-body { padding: 14px 16px; }
.add-client-btn {
  width: 100%;
  background: #1d4ed8;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px;
  font-family: inherit;
  font-size: .9rem;
  cursor: pointer;
  transition: background .15s ease;
}
.add-client-btn:hover { background: #1e40af; }

.client-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.client-empty { color: #94a3b8; font-size: .85rem; text-align: center; padding: 8px 0; }
.client-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
}
.client-name { font-weight: 700; color: #334155; font-size: .88rem; }
.client-mail { color: #64748b; font-size: .8rem; direction: ltr; text-align: right; word-break: break-all; }

.client-form label { display: block; margin: 10px 0 5px; font-size: .8rem; color: #334155; }
.client-form input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d7dee8;
  border-radius: 9px;
  font-family: inherit;
  font-size: .88rem;
  background: #fff;
}
.client-form input:focus { border-color: #1d4ed8; box-shadow: 0 0 0 3px rgba(29, 78, 216, .12); outline: none; }
.cf-actions { display: flex; gap: 8px; margin-top: 14px; }
.cf-save {
  flex: 1;
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 9px;
  font-family: inherit;
  font-size: .88rem;
  cursor: pointer;
}
.cf-save:hover { background: #15803d; }
.cf-cancel {
  flex: 1;
  background: #fff;
  color: #475569;
  border: 1px solid #d7dee8;
  border-radius: 9px;
  padding: 9px;
  font-family: inherit;
  font-size: .88rem;
  cursor: pointer;
}
.cf-cancel:hover { background: #f1f5f9; }

.um-foot { padding: 10px 16px; border-top: 1px solid #e8eef6; }
.um-logout-btn {
  width: 100%;
  background: #fff;
  color: #dc2626;
  border: 1px solid #fca5a5;
  border-radius: 9px;
  padding: 9px;
  font-family: inherit;
  font-size: .88rem;
  cursor: pointer;
  transition: background .15s ease;
}
.um-logout-btn:hover { background: #fef2f2; }
