/* ============================================================
   توکن‌های تم — روشن (پیش‌فرض)
   ============================================================ */
:root {
  --brand-red: #c41e3a;
  --brand-red-dark: #9e1730;
  --brand-red-soft: #fdecef;
  --brand-red-border: #f0d5da;
  --brand-contrast: #ffffff;

  --page-bg: #faf7f7;
  --surface: #ffffff;
  --surface-2: #fffafb;
  --border-soft: #f0d5da;
  --text-strong: #1f1f1f;
  --text-body: #333333;
  --text-muted-2: #666666;
  --sidebar-bg: #ffffff;
  --sidebar-link: #333333;
  --sidebar-link-hover-bg: #fdecef;
  --sidebar-group: #a2848b;
  --card-shadow: 0 0.35rem 0.8rem rgba(196, 30, 58, 0.06);
  --card-shadow-hover: 0 0.55rem 1.1rem rgba(196, 30, 58, 0.12);
  --table-head-bg: #fdecef;
  --table-head-color: var(--brand-red);
  --focus-ring: rgba(196, 30, 58, 0.2);
  --scrollbar-thumb: #e3c6cc;

  --pill-warn-bg: #fff4e5;
  --pill-warn-fg: #9a5b00;
  --pill-ok-bg: #e8f6ee;
  --pill-ok-fg: #1e7a46;
  --pill-info-bg: #e8f1fb;
  --pill-info-fg: #1d4f91;
  --pill-danger-bg: #fdecef;
  --pill-danger-fg: #c41e3a;
}

/* ============================================================
   توکن‌های تم — تاریک
   ============================================================ */
[data-bs-theme="dark"] {
  --brand-red: #e35d74;
  --brand-red-dark: #ef8496;
  --brand-red-soft: rgba(227, 93, 116, 0.14);
  --brand-red-border: #4a2e35;
  --brand-contrast: #ffffff;

  --page-bg: #16181d;
  --surface: #1f222a;
  --surface-2: #262a33;
  --border-soft: #363a45;
  --text-strong: #f1f2f4;
  --text-body: #d7d9de;
  --text-muted-2: #9aa0ab;
  --sidebar-bg: #1b1e24;
  --sidebar-link: #cfd2d8;
  --sidebar-link-hover-bg: rgba(227, 93, 116, 0.14);
  --sidebar-group: #8a8f99;
  --card-shadow: 0 0.35rem 0.8rem rgba(0, 0, 0, 0.35);
  --card-shadow-hover: 0 0.55rem 1.1rem rgba(0, 0, 0, 0.5);
  --table-head-bg: rgba(227, 93, 116, 0.12);
  --table-head-color: var(--brand-red);
  --focus-ring: rgba(227, 93, 116, 0.3);
  --scrollbar-thumb: #3d414c;

  --pill-warn-bg: rgba(255, 176, 82, 0.16);
  --pill-warn-fg: #f2b46b;
  --pill-ok-bg: rgba(60, 190, 120, 0.16);
  --pill-ok-fg: #63cf93;
  --pill-info-bg: rgba(90, 150, 235, 0.16);
  --pill-info-fg: #86b2ef;
  --pill-danger-bg: rgba(227, 93, 116, 0.16);
  --pill-danger-fg: #ef8496;
}

/* ============================================================
   حالت تاریک: فرم‌ها، جدول‌ها، منوهای کشویی و مودال‌ها
   (صریح تعریف شده تا مستقل از استایل پیش‌فرض Bootstrap،
   همهٔ اجزا در تم تاریک خوانا و تیره باشند)
   ============================================================ */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  background-color: var(--surface-2);
  border-color: var(--border-soft);
  color: var(--text-body);
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
  background-color: var(--surface-2);
  color: var(--text-strong);
}

[data-bs-theme="dark"] .form-control::placeholder {
  color: var(--text-muted-2);
}

[data-bs-theme="dark"] .form-control:disabled,
[data-bs-theme="dark"] .form-control[readonly],
[data-bs-theme="dark"] .form-select:disabled {
  background-color: var(--surface);
  color: var(--text-muted-2);
}

[data-bs-theme="dark"] .form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23adb5bd' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}

[data-bs-theme="dark"] .form-check-input:not(:checked) {
  background-color: var(--surface-2);
  border-color: var(--border-soft);
}

[data-bs-theme="dark"] .input-group-text {
  background-color: var(--surface-2);
  border-color: var(--border-soft);
  color: var(--text-body);
}

[data-bs-theme="dark"] .table {
  --bs-table-bg: var(--surface);
  --bs-table-color: var(--text-body);
  color: var(--text-body);
  border-color: var(--border-soft);
}

[data-bs-theme="dark"] .table > :not(caption) > * > * {
  background-color: var(--surface);
  color: var(--text-body);
  border-color: var(--border-soft);
}

[data-bs-theme="dark"] .admin-table thead th {
  background: var(--table-head-bg);
  color: var(--table-head-color);
}

[data-bs-theme="dark"] .admin-table tr.order-item-bundle-component td {
  background: var(--surface-2);
  color: var(--text-muted-2);
}

[data-bs-theme="dark"] .dropdown-menu {
  background-color: var(--surface-2);
  border-color: var(--border-soft);
}

[data-bs-theme="dark"] .dropdown-item {
  color: var(--text-body);
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
  background-color: rgba(255, 255, 255, 0.06);
  color: var(--text-strong);
}

[data-bs-theme="dark"] .dropdown-header {
  color: var(--text-muted-2);
}

[data-bs-theme="dark"] .dropdown-divider {
  border-color: var(--border-soft);
}

[data-bs-theme="dark"] .modal-content {
  background-color: var(--surface);
  border-color: var(--border-soft);
  color: var(--text-body);
}

[data-bs-theme="dark"] .modal-header,
[data-bs-theme="dark"] .modal-footer {
  border-color: var(--border-soft);
}

[data-bs-theme="dark"] .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

[data-bs-theme="dark"] .text-muted {
  color: var(--text-muted-2) !important;
}

[data-bs-theme="dark"] .form-label,
[data-bs-theme="dark"] .col-form-label {
  color: var(--text-body);
}

/* ============================================================
   پایه
   ============================================================ */
html {
  font-size: 14px;
  position: relative;
  min-height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  font-family: "Vazirmatn", Tahoma, sans-serif;
  background: var(--page-bg);
  color: var(--text-strong);
  min-height: 100vh;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
}

/* دکمه‌های برند */
.btn-brand {
  color: var(--brand-contrast);
  background-color: var(--brand-red);
  border-color: var(--brand-red);
}

.btn-brand:hover,
.btn-brand:focus {
  color: var(--brand-contrast);
  background-color: var(--brand-red-dark);
  border-color: var(--brand-red-dark);
}

.btn-outline-brand {
  color: var(--brand-red);
  border-color: var(--brand-red);
  background: transparent;
}

.btn-outline-brand:hover {
  color: var(--brand-contrast);
  background-color: var(--brand-red);
  border-color: var(--brand-red);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--brand-red);
  box-shadow: 0 0 0 0.2rem var(--focus-ring);
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--brand-red);
}

.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-body);
}

.role-badge {
  display: inline-block;
  background: var(--surface);
  color: var(--brand-red);
  border: 1px solid var(--brand-red);
  border-radius: 999px;
  padding: 0.25rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 500;
}

/* ============================================================
   پوستهٔ پنل: سایدبار + نوار بالا
   ============================================================ */
.admin-body {
  display: flex;
  min-height: 100vh;
  margin: 0;
}

.admin-sidebar {
  width: 264px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-inline-end: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 1040;
}

.sidebar-brand {
  background: var(--brand-red);
  color: #fff;
  padding: 1rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.05rem;
  flex-shrink: 0;
}

[data-bs-theme="dark"] .sidebar-brand {
  background: #7d2033;
}

.sidebar-brand .bi {
  font-size: 1.25rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 0.6rem 0.6rem 1.25rem;
}

.sidebar-group-label {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--sidebar-group);
  letter-spacing: 0.02em;
  padding: 0.9rem 0.85rem 0.3rem;
  text-transform: uppercase;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--sidebar-link);
  text-decoration: none;
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  font-size: 0.92rem;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.sidebar-link .bi {
  font-size: 1rem;
  opacity: 0.75;
  flex-shrink: 0;
}

.sidebar-link:hover {
  color: var(--brand-red);
  background: var(--sidebar-link-hover-bg);
}

.sidebar-link.active {
  color: var(--brand-red);
  background: var(--sidebar-link-hover-bg);
  font-weight: 600;
}

.sidebar-link.active .bi,
.sidebar-link:hover .bi {
  opacity: 1;
}

.admin-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.admin-navbar {
  background-color: var(--brand-red);
  position: sticky;
  top: 0;
  z-index: 1030;
}

[data-bs-theme="dark"] .admin-navbar {
  background-color: #23262e;
  border-bottom: 1px solid var(--border-soft);
}

.navbar-brand {
  font-weight: 700;
}

.admin-content {
  padding: 1.5rem;
}

/* آیکون دکمهٔ تم: در حالت روشن ماه، در حالت تاریک خورشید */
html:not([data-bs-theme="dark"]) .theme-icon-light {
  display: none;
}

[data-bs-theme="dark"] .theme-icon-dark {
  display: none;
}

/* دکمهٔ تغییر تم و دکمه‌های نوار بالا */
.navbar-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: transparent;
  color: #fff;
  font-size: 1.05rem;
  transition: background-color 0.12s ease;
}

.navbar-icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.navbar-user-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: transparent;
  color: #fff;
  border-radius: 999px;
  padding-block: 0.2rem;
  padding-inline-start: 0.25rem;
  padding-inline-end: 0.7rem;
  font-size: 0.92rem;
}

.navbar-user-avatar {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.18);
}

.navbar-user-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
}

.navbar-user-btn:hover,
.navbar-user-btn:focus {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.navbar-user-menu {
  min-width: 230px;
}

.navbar-user-menu .dropdown-header {
  font-size: 0.85rem;
}

/* ============================================================
   کارت‌ها
   ============================================================ */
.module-card {
  display: block;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 1.15rem 1.2rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--card-shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.module-card:hover {
  color: inherit;
  transform: translateY(-2px);
  border-color: var(--brand-red);
  box-shadow: var(--card-shadow-hover);
}

.module-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--brand-red);
  margin-bottom: 0.35rem;
}

.module-card-desc {
  margin: 0;
  color: var(--text-muted-2);
  font-size: 0.9rem;
}

/* کارت‌های آمار داشبورد */
.stat-card {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  height: 100%;
  box-shadow: var(--card-shadow);
}

.stat-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.9rem;
  height: 2.9rem;
  border-radius: 12px;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.stat-card-icon.tone-warn {
  background: var(--pill-warn-bg);
  color: var(--pill-warn-fg);
}

.stat-card-icon.tone-ok {
  background: var(--pill-ok-bg);
  color: var(--pill-ok-fg);
}

.stat-card-icon.tone-info {
  background: var(--pill-info-bg);
  color: var(--pill-info-fg);
}

.stat-card-icon.tone-brand {
  background: var(--brand-red-soft);
  color: var(--brand-red);
}

.stat-card-value {
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-strong);
}

.stat-card-label {
  font-size: 0.85rem;
  color: var(--text-muted-2);
}

/* نمودارها */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  overflow: hidden;
}

.chart-card-title,
.chart-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--brand-red);
  margin-bottom: 0.75rem;
}

.chart-wrap {
  position: relative;
  height: 240px;
}

.chart-wrap canvas {
  display: block;
  max-height: 240px;
}

.range-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.range-btn {
  border: 1px solid var(--brand-red);
  color: var(--brand-red);
  background: transparent;
}

.range-btn.active,
.range-btn:hover {
  background: var(--brand-red);
  border-color: var(--brand-red);
  color: var(--brand-contrast);
}

.range-toggle .btn.active {
  color: var(--brand-contrast);
  background: var(--brand-red);
  border-color: var(--brand-red);
}

/* میانبرها */
.shortcut-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  text-decoration: none;
  color: inherit;
  height: 100%;
  min-height: 88px;
  box-shadow: var(--card-shadow);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.shortcut-card:hover {
  color: inherit;
  border-color: var(--brand-red);
  transform: translateY(-2px);
}

.shortcut-badge {
  min-width: 2.2rem;
  height: 2.2rem;
  border-radius: 999px;
  background: var(--brand-red);
  color: var(--brand-contrast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  padding: 0 0.55rem;
  flex-shrink: 0;
}

.shortcut-title {
  font-weight: 600;
  line-height: 1.4;
}

/* کارت‌های فیلتر / فرم / جدول */
.filter-card,
.form-card,
.table-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
}

.filter-card,
.form-card {
  padding: 1rem 1.1rem;
}

.table-card {
  padding: 0;
  overflow: hidden;
}

.table-card .table-responsive {
  padding: 0;
}

.table-card .admin-table {
  margin-bottom: 0;
}

.table-card-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1.1rem;
  border-top: 1px solid var(--border-soft);
  background: var(--surface-2);
}

/* ============================================================
   جدول‌ها
   ============================================================ */
.admin-table {
  --bs-table-bg: var(--surface);
  --bs-table-color: var(--text-body);
}

.admin-table thead th {
  background: var(--table-head-bg);
  color: var(--table-head-color);
  font-weight: 600;
  border-bottom-color: var(--border-soft);
  white-space: nowrap;
}

.admin-table td,
.admin-table th {
  border-color: var(--border-soft);
}

.admin-table tr.order-item-bundle-component td {
  background: var(--surface-2);
  color: var(--text-muted-2);
  border-top-color: var(--border-soft);
}

.admin-table .order-item-bundle-component-title {
  display: inline-flex;
  align-items: center;
  padding-right: 1.25rem;
}

.admin-table .order-item-bundle-component-title::before {
  content: "";
  width: 0.7rem;
  height: 0.7rem;
  margin-left: 0.45rem;
  border-bottom: 1.5px solid var(--border-soft);
  border-right: 1.5px solid var(--border-soft);
}

.order-item-type-component {
  background: var(--brand-red-soft);
  color: var(--brand-red);
}

/* حالت خالی جدول‌ها */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 2.5rem 1rem;
  color: var(--text-muted-2);
  text-align: center;
}

.empty-state .bi {
  font-size: 2.2rem;
  opacity: 0.45;
}

/* ============================================================
   نشان‌های وضعیت
   ============================================================ */
.status-pill {
  display: inline-block;
  border-radius: 999px;
  padding: 0.15rem 0.7rem;
  font-size: 0.85rem;
  white-space: nowrap;
}

.status-PENDING_VERIFICATION,
.status-PENDING_INVENTORY_APPROVAL,
.status-PENDING_PAYMENT,
.status-PENDING_PAYMENT_APPROVAL {
  background: var(--pill-warn-bg);
  color: var(--pill-warn-fg);
}

.status-VERIFIED,
.status-DELIVERED {
  background: var(--pill-ok-bg);
  color: var(--pill-ok-fg);
}

.status-PROCESSING,
.status-READY_TO_SHIP,
.status-SHIPPED {
  background: var(--pill-info-bg);
  color: var(--pill-info-fg);
}

.status-REJECTED,
.status-CANCELLED {
  background: var(--pill-danger-bg);
  color: var(--pill-danger-fg);
}

/* ============================================================
   صفحات ورود
   ============================================================ */
.auth-body {
  min-height: 100vh;
  margin: 0;
  background: linear-gradient(180deg, var(--brand-red) 0 42%, var(--page-bg) 42%);
}

[data-bs-theme="dark"] .auth-body {
  background: linear-gradient(180deg, #7d2033 0 42%, var(--page-bg) 42%);
}

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: 16px;
  padding: 2rem 1.75rem;
  box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.12);
}

[data-bs-theme="dark"] .auth-card {
  border: 1px solid var(--border-soft);
  box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.45);
}

.auth-brand {
  color: var(--brand-red);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.auth-subtitle,
.auth-countdown {
  color: var(--text-muted-2);
  font-size: 0.95rem;
}

.auth-theme-toggle {
  position: fixed;
  top: 1rem;
  inset-inline-start: 1rem;
  z-index: 10;
}

/* ============================================================
   جزئیات و مدارک
   ============================================================ */
.doc-image {
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--surface);
}

.brand-thumb {
  width: 96px;
  height: 40px;
  object-fit: contain;
  object-position: center;
  border-radius: 6px;
  background: var(--surface);
}

.brand-image {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 180px;
  object-fit: contain;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--surface);
}

.doc-label {
  font-size: 0.85rem;
  color: var(--text-muted-2);
  margin-bottom: 0.35rem;
}

.detail-list dt {
  color: var(--text-muted-2);
}

/* ============================================================
   توست‌ها و بازگشت به بالا
   ============================================================ */
.app-toast-container {
  position: fixed;
  bottom: 1rem;
  inset-inline-start: 1rem;
  z-index: 1090;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(420px, calc(100vw - 2rem));
}

.back-to-top {
  position: fixed;
  bottom: 1.25rem;
  inset-inline-end: 1.25rem;
  z-index: 1080;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 999px;
  border: none;
  background: var(--brand-red);
  color: var(--brand-contrast);
  font-size: 1.1rem;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: var(--card-shadow-hover);
}

.back-to-top.show {
  display: inline-flex;
}

/* ============================================================
   صفحهٔ خطا
   ============================================================ */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 1rem;
  gap: 0.75rem;
}

.error-page .bi {
  font-size: 3.2rem;
  color: var(--brand-red);
}

.error-page-title {
  font-size: 1.6rem;
  font-weight: 700;
}

.error-page-desc {
  color: var(--text-muted-2);
  max-width: 420px;
}

/* ============================================================
   موبایل
   ============================================================ */
.sidebar-backdrop {
  display: none;
}

@media (max-width: 991.98px) {
  .admin-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    height: 100vh;
    transform: translateX(110%);
    transition: transform 0.2s ease;
    box-shadow: -0.5rem 0 1.5rem rgba(0, 0, 0, 0.12);
  }

  body.sidebar-open .admin-sidebar {
    transform: none;
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 1030;
  }
}

.nav-unread-badge {
  margin-inline-start: auto;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--brand-red);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.admin-content-chat {
  padding: 0;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.admin-body-chat .back-to-top {
  display: none !important;
}

.admin-body-chat .admin-main {
  min-height: 0;
  height: 100vh;
  overflow: hidden;
}

.admin-body-chat .admin-navbar {
  flex-shrink: 0;
}

.admin-content-chat > main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chat-shell {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  height: 100%;
  background: var(--page-bg);
}

.chat-list-pane {
  width: 340px;
  max-width: 42%;
  flex-shrink: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-inline-end: 1px solid var(--border-soft);
  background: var(--surface);
}

.chat-list-search {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}

.chat-list {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
}

.chat-list-status {
  padding: 0.6rem;
  text-align: center;
  color: var(--text-muted-2);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.chat-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-soft);
}

.chat-item:hover,
.chat-item.active {
  background: var(--sidebar-link-hover-bg);
}

.chat-item-body {
  min-width: 0;
  flex: 1;
}

.chat-item-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
}

.chat-item-name {
  font-weight: 600;
  color: var(--text-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-time {
  color: var(--text-muted-2);
  font-size: 0.75rem;
  flex-shrink: 0;
}

.chat-item-preview {
  color: var(--text-muted-2);
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.15rem;
}

.chat-item-unread {
  margin-inline-start: auto;
  background: var(--brand-red);
  color: #fff;
  border-radius: 999px;
  min-width: 1.2rem;
  height: 1.2rem;
  font-size: 0.7rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.3rem;
}

.chat-thread-pane {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
}

.chat-thread-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted-2);
  gap: 0.75rem;
}

.chat-thread-empty .bi {
  font-size: 2.5rem;
  opacity: 0.5;
}

.chat-thread {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chat-thread-header {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface);
  font-weight: 600;
  flex-shrink: 0;
}

.chat-thread-header small {
  display: block;
  font-weight: 400;
  color: var(--text-muted-2);
  margin-top: 0.15rem;
}

.chat-messages {
  flex: 1 1 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.chat-bubble-row {
  display: flex;
  max-width: 78%;
}

.chat-bubble-row.mine {
  align-self: flex-start;
}

.chat-bubble-row.theirs {
  align-self: flex-end;
}

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--brand-red-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-inline-start: 0.45rem;
  color: var(--brand-red);
}

.chat-bubble {
  background: var(--surface);
  border-radius: 14px 14px 4px 14px;
  padding: 0.55rem 0.75rem;
  box-shadow: var(--card-shadow);
  position: relative;
}

.chat-bubble-row.mine .chat-bubble {
  background: var(--brand-red-soft);
  border-radius: 14px 14px 14px 4px;
}

.chat-sender {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-strong);
  margin-bottom: 0.2rem;
}

.chat-sender-role {
  font-weight: 400;
  color: var(--text-muted-2);
  font-size: 0.78rem;
}

.chat-bubble-text {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-body);
}

.chat-bubble-image {
  max-width: 240px;
  border-radius: 10px;
  display: block;
  cursor: zoom-in;
  margin-bottom: 0.35rem;
}

.chat-bubble-meta {
  display: flex;
  gap: 0.4rem;
  justify-content: flex-end;
  margin-top: 0.25rem;
  font-size: 0.72rem;
  color: var(--text-muted-2);
}

.chat-deleted {
  font-style: italic;
  color: var(--text-muted-2);
}

.chat-bubble-actions {
  margin-top: 0.25rem;
  display: flex;
  gap: 0.4rem;
}

.chat-bubble-actions button {
  border: 0;
  background: transparent;
  color: var(--text-muted-2);
  font-size: 0.75rem;
  padding: 0;
}

.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
  padding: 0.7rem 0.85rem;
  background: var(--surface);
  border-top: 1px solid var(--border-soft);
  flex-shrink: 0;
}

.chat-composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 0.55rem 0.75rem;
  background: var(--page-bg);
  color: var(--text-body);
  max-height: 140px;
}

.chat-icon-btn {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--brand-red);
  font-size: 1.2rem;
}

.chat-send-btn {
  background: var(--brand-red);
  color: #fff;
}

@media (max-width: 768px) {
  .chat-list-pane {
    width: 100%;
    max-width: none;
  }

  .chat-shell.is-thread .chat-list-pane {
    display: none;
  }

  .chat-shell:not(.is-thread) .chat-thread-pane {
    display: none;
  }
}

