/* ============================================================
   MR SEDE — رابط مکالمات و حساب کاربری مشتری
   (chat threads / order cards / profile — customer-facing)
   ============================================================ */

/* ---------- نشان وضعیت رنگی ---------- */
.mr-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 13px;
  border-radius: 999px;
  white-space: nowrap;
  line-height: 1.6;
}

.mr-status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.mr-status-pending { background: rgba(255, 193, 7, .14); color: #e0ab1f; }
.mr-status-reviewing { background: rgba(99, 170, 255, .14); color: #5b9bf0; }
.mr-status-designing { background: rgba(168, 120, 255, .15); color: #a177f5; }
.mr-status-in_progress { background: var(--accent-soft); color: var(--accent); }
.mr-status-waiting_client { background: rgba(255, 140, 90, .15); color: #ea8a5a; }
.mr-status-completed { background: rgba(120, 190, 130, .16); color: #6fc07e; }
.mr-status-cancelled { background: var(--bg-soft); color: var(--text-muted); }

/* ---------- کارت پروفایل حساب کاربری ---------- */
.mr-profile-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
  background: linear-gradient(145deg, var(--bg-card), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 24px;
}

.mr-profile-identity { display: flex; align-items: center; gap: 16px; }

.mr-avatar {
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--border);
}

.mr-avatar-sm {
  width: 32px;
  height: 32px;
  font-size: 0.8rem;
}

.mr-profile-name { margin: 0 0 4px; font-size: 1.25rem; font-weight: 700; }

.mr-profile-phone {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mr-profile-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- فرم ویرایش پروفایل ---------- */
.mr-edit-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 24px;
  animation: mrFadeIn .18s ease;
}

@keyframes mrFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- لیست سفارش‌ها (کارت به‌جای جدول) ---------- */
.mr-order-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 8px; }

.mr-order-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  transition: border-color .15s ease, transform .15s ease;
}

.mr-order-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.mr-order-main { display: flex; flex-direction: column; gap: 6px; min-width: 200px; }

.mr-order-title { font-weight: 700; font-size: 0.98rem; }

.mr-order-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.mr-order-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--text-muted); }

.mr-order-side { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.mr-empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 16px;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  font-size: 0.92rem;
}

/* ---------- قاب گفتگو (سفارش / تیکت) ---------- */
.mr-chat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 16px;
}

.mr-chat-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.mr-chat-thread {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 400px;
  overflow-y: auto;
  padding: 16px;
  background: var(--bg-soft);
  border-radius: 14px;
  margin-bottom: 14px;
  scroll-behavior: smooth;
}

.mr-chat-thread::-webkit-scrollbar { width: 6px; }
.mr-chat-thread::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

.mr-msg-row { display: flex; gap: 10px; max-width: 86%; }
.mr-msg-row.is-admin { margin-right: auto; flex-direction: row-reverse; }

.mr-msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px 14px 14px 4px;
  padding: 10px 14px;
}

.mr-msg-row.is-admin .mr-msg-bubble {
  background: var(--accent-soft);
  border-color: transparent;
  border-radius: 14px 14px 4px 14px;
}

.mr-msg-from {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--accent);
  display: block;
  margin-bottom: 4px;
}

.mr-msg-row.is-admin .mr-msg-from { color: var(--accent); text-align: left; }

.mr-msg-text {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text, inherit);
}

.mr-msg-time {
  display: block;
  margin-top: 5px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.mr-chat-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  padding: 24px 10px;
}

.mr-chat-form {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 6px 6px 16px;
}

.mr-chat-form input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 4px;
  color: inherit;
  font-family: inherit;
  font-size: 0.92rem;
}

.mr-chat-form input:focus { outline: none; }

.mr-chat-form button {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
}

/* ---------- کارت‌های تیکت (overrides روی کلاس‌های قبلی) ---------- */
.ticket-card {
  transition: border-color .15s ease;
}
.ticket-card:hover { border-color: var(--accent); }

.ticket-msg {
  border-radius: 14px 14px 14px 4px;
  border: 1px solid var(--border);
}
.ticket-msg-admin {
  border-radius: 14px 14px 4px 14px;
  border-color: transparent;
}

@media (max-width: 640px) {
  .mr-profile-card { padding: 18px; }
  .mr-order-card { flex-direction: column; align-items: flex-start; }
  .mr-chat-thread { max-height: 320px; }
}

/* ============================================================
   پنل ادمین — سفارش‌ها / تیکت‌ها
   ============================================================ */
.mr-tabs-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.admin-tab {
  position: relative;
  transition: color .15s ease;
}

.admin-tab::after {
  content: '';
  position: absolute;
  right: 10px;
  left: 10px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform .18s ease;
}

.admin-tab.active::after { transform: scaleX(1); }

/* نوار جست‌وجو / فیلتر بالای لیست سفارش‌ها */
.mr-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  margin-bottom: 18px;
}

.mr-toolbar input[type="search"],
.mr-toolbar input[type="text"] {
  flex: 1;
  min-width: 160px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  border-radius: 999px;
  padding: 8px 16px;
  color: inherit;
  font-family: inherit;
  font-size: 0.88rem;
}

.mr-toolbar select {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  border-radius: 999px;
  padding: 8px 14px;
  color: inherit;
  font-family: inherit;
  font-size: 0.86rem;
}

.mr-toolbar-count {
  margin-right: auto;
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* کارت سفارش در پنل ادمین */
.mr-admin-order {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 14px;
  transition: border-color .15s ease;
}

.mr-admin-order:hover { border-color: var(--accent); }

.mr-admin-order-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.mr-admin-order-who { display: flex; align-items: center; gap: 10px; }

.mr-type-chip {
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-muted);
}

.mr-type-chip.is-custom { background: var(--accent-soft); color: var(--accent); }

.mr-admin-order-meta {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

/* سلکت وضعیت به‌شکل نشان رنگی */
.mr-status-select {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 30px 6px 13px;
  border-radius: 999px;
  background-color: var(--bg-soft);
  color: var(--text-muted);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%238fa894' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: left 12px center;
}

.mr-status-select.mr-status-pending { background-color: rgba(255, 193, 7, .14); color: #e0ab1f; }
.mr-status-select.mr-status-reviewing { background-color: rgba(99, 170, 255, .14); color: #5b9bf0; }
.mr-status-select.mr-status-designing { background-color: rgba(168, 120, 255, .15); color: #a177f5; }
.mr-status-select.mr-status-in_progress { background-color: var(--accent-soft); color: var(--accent); }
.mr-status-select.mr-status-waiting_client { background-color: rgba(255, 140, 90, .15); color: #ea8a5a; }
.mr-status-select.mr-status-completed { background-color: rgba(120, 190, 130, .16); color: #6fc07e; }
.mr-status-select.mr-status-cancelled { background-color: var(--bg-soft); color: var(--text-muted); }

.mr-toggle-thread {
  cursor: pointer;
  user-select: none;
  font-size: 0.86rem;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
}

.mr-toggle-thread svg { transition: transform .15s ease; }
.mr-admin-order[data-open="1"] .mr-toggle-thread svg { transform: rotate(180deg); }

.mr-admin-order-body {
  font-size: 0.88rem;
  line-height: 1.8;
  margin-bottom: 8px;
  color: var(--text-muted);
}
