/* Components — PartnerPanel */
/* Consumes only design tokens from tokens.css */

/* ============ Buttons ============ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font: inherit;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

.btn--primary {
  background: hsl(var(--color-primary-600));
  color: var(--text-on-primary);
}

.btn--primary:hover {
  background: hsl(var(--color-primary-500));
  text-decoration: none;
}

.btn--ghost {
  background: transparent;
  border-color: var(--border-subtle);
  color: var(--text-secondary);
}

.btn--ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
}

/* Destructive action (delete). Same geometry as .btn--ghost, existing
   danger token — no new colours are introduced. */
.btn--danger {
  background: transparent;
  border-color: hsl(var(--color-danger) / .45);
  color: hsl(var(--color-danger));
}

.btn--danger:hover {
  background: hsl(var(--color-danger) / .1);
  color: hsl(var(--color-danger));
  text-decoration: none;
}

.btn--block { width: 100%; }

/* Compact button used in card headers (e.g. «دانلود CSV»). */
.btn--sm {
  padding: 7px 12px;
  font-size: var(--text-sm);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ============ Card ============ */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card__title {
  text-align: center;
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.card__action {
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-decoration: none;
}

.card__action:hover { color: hsl(var(--color-primary-600)); }

.link {
  color: hsl(var(--color-primary-600));
  text-decoration: none;
}

.link:hover { text-decoration: underline; }

/* ============ Page title block ============ */

.page-header { margin-bottom: 28px; }

.page-header__title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  margin: 0 0 4px;
  color: var(--text-primary);
}

.page-header__subtitle {
  font-size: var(--text-base);
  color: var(--text-muted);
  margin: 0;
}

/* ============ Stats ============ */

/* .stats-grid is the canonical name; .stat-grid is the singular spelling the
   partner panel views use. Both must resolve, otherwise the stat cards fall
   back to block layout (no columns, no gap) and the page reads as one solid
   block of text. */
.stats-grid,
.stat-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 24px;
}

/* Consecutive top-level page blocks (page-header, stat-grid, card,
   form-grid, ...) are always spaced apart. Vertical margins collapse between
   siblings, so the existing margin-bottom on .page-header / .stats-grid is
   not doubled — this only supplies the spacing those blocks never had. */
.app-content > * + * {
  margin-top: 24px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.stat-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.stat-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-card__icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-card__icon--primary {
  background: hsl(var(--color-primary-500) / .14);
  color: hsl(var(--color-primary-600));
}

.stat-card__icon--success {
  background: hsl(var(--color-success) / .14);
  color: hsl(var(--color-success));
}

.stat-card__icon--warning {
  background: hsl(var(--color-warning) / .16);
  color: hsl(var(--color-warning));
}

.stat-card__icon--danger {
  background: hsl(var(--color-danger) / .14);
  color: hsl(var(--color-danger));
}

.stat-card__label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin: 0;
}

.stat-card__value {
  font-size: 26px;
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  line-height: 1.2;
  margin: 0;
}

.stat-card__delta {
  font-size: var(--text-xs);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.stat-card__delta--up {
  background: hsl(var(--color-success) / .12);
  color: hsl(var(--color-success));
}

.stat-card__delta--down {
  background: hsl(var(--color-danger) / .12);
  color: hsl(var(--color-danger));
}

/* ============ Dashboard grid ============ */

.dashboard-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr;
}

@media (min-width: 1100px) {
  .dashboard-grid { grid-template-columns: 2fr 1fr; }
}

/* ============ Table ============ */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}


.table thead th {
  /* Project rule: all list-header cells are centered everywhere. */
  text-align: center;
  padding: 10px 12px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border-subtle);
}

.table tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.table tbody tr:last-child td { border-bottom: 0; }

.table tbody tr:hover td {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Phones: tighter cells so a 6-column table fits a swipe-safe area inside
   .table-wrap instead of forcing a very long horizontal scroll. */
@media (max-width: 640px) {
  .table thead th { padding: 8px 10px; }
  .table tbody td { padding: 10px; }
}

.table__amount {
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* ============ Summary list ============ */

.summary-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.summary-list li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.summary-list li:last-child { border-bottom: 0; }

.summary-list__label {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.summary-list__value {
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.summary-list__value--success { color: hsl(var(--color-success)); }

.summary-list__value--danger { color: hsl(var(--color-danger)); }

/* ============ User menu ============ */

.topbar-user { position: relative; }

.topbar-user__btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 1px solid transparent;
  padding: 4px 12px 4px 4px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.topbar-user__btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-subtle);
}

.topbar-user__avatar {
  font-size: var(--text-xl);
  font-weight: 600;
  color: hsl(var(--color-primary-700));
  background: hsl(var(--color-primary-500) / .14);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  overflow: hidden;
  flex-shrink: 0;
}

/* Signed-in user has an avatar file → show it instead of the initial. */
.topbar-user__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.topbar-user__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.25;
}

.topbar-user__name {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
}

.topbar-user__role {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.topbar-user__menu {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  min-width: 220px;
  padding: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  display: none;
}

.topbar-user__menu.is-open { display: block; }

.topbar-user__menu-header {
  padding: 8px 12px 10px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 6px;
}

.topbar-user__role-badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  background: hsl(var(--color-primary-500) / .12);
  color: hsl(var(--color-primary-600));
}

.topbar-user__menu-logout {
  display: flex;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius-md);
  color: hsl(var(--color-danger));
  font-size: var(--text-sm);
  text-align: start;
}

.topbar-user__menu-logout:hover {
  background: hsl(var(--color-danger) / .08);
}

/* ============ Alerts (login) ============ */

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  margin-bottom: 16px;
}

.alert--danger {
  background: hsl(var(--color-danger) / .1);
  color: hsl(var(--color-danger));
  border: 1px solid hsl(var(--color-danger) / .2);
}

.alert--info {
  background: hsl(var(--color-primary-500) / .1);
  color: hsl(var(--color-primary-600));
  border: 1px solid hsl(var(--color-primary-500) / .2);
}

.alert--warning {
  background: hsl(var(--color-warning) / .1);
  color: hsl(var(--color-warning));
  border: 1px solid hsl(var(--color-warning) / .25);
}

/* ============ Empty state ============ */

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* standalone «حالت خالی» block (views/partials/empty-state.php).
   The modifier keeps the table-cell .empty-state above untouched. */
.empty-state--block {
  padding: 56px 24px;
  max-width: 420px;
  margin: 0 auto;
}

.empty-state__icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg,
    hsl(var(--color-primary-500) / .12),
    hsl(var(--color-accent-500) / .12));
  color: hsl(var(--color-primary-600));
}

[data-theme="dark"] .empty-state__icon {
  color: hsl(var(--color-primary-300));
}

.empty-state__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin: 0 0 8px;
}

.empty-state__message {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin: 0 0 20px;
  line-height: 1.85;
}

/* ============ Partner tier progress card ============ */

.tier-card {
  padding: 24px;
}

.tier-card__header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.tier-card__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.tier-card__progress {
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  overflow: hidden;
  margin: 12px 0 10px;
}

.tier-card__bar {
  height: 100%;
  background: linear-gradient(90deg,
    hsl(var(--color-primary-500)),
    hsl(var(--color-accent-500)));
  border-radius: var(--radius-full);
  transition: width .6s ease;
}

.tier-card__hint {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.8;
}

/* Dashboard «آخرین تیکت‌ها» rows */
.mini-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.mini-list__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mini-list__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.mini-list__title {
  font-size: var(--text-sm);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 320px;
}

.mini-list__date {
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
}

/* ============ Form grid ============ */

.form-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .form-grid {
    grid-template-columns: 2fr 1fr;
  }
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

.field__label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  margin-bottom: 6px;
  display: block;
}

.field__input {
  padding: 11px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  color: var(--text-primary);
  transition: all var(--transition-fast);
  width: 100%;
}

.field__input:focus {
  outline: none;
  border-color: hsl(var(--color-primary-500));
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px hsl(var(--color-primary-500) / .15);
}

.field__input--error {
  border-color: hsl(var(--color-danger));
}

/* ============ Select (combo box) ============ */

/* .field__input colors apply to the closed select, but the option popup
 * is rendered by the OS: give <option> explicit theme-aware colors so
 * the list is readable in BOTH light and dark mode. Without this, the
 * dark theme inherits light-on-light into the native popup. */
select.field__input,
select {
  color: var(--text-primary);
  background-color: var(--bg-elevated);
}

select.field__input option,
select option {
  background: var(--bg-surface);
  color: var(--text-primary);
}

select.field__input option:checked,
select option:checked {
  background-color: hsl(var(--color-primary-500));
  color: var(--text-on-primary);
}

/* Disabled controls read as inactive on every browser: one rule for the
   whole field family (the select-only rule below is kept for older pages). */
.field__input:disabled,
.field__input[disabled],
textarea.field__input:disabled {
  background: var(--bg-hover);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: .85;
}

select.field__input:disabled,
select:disabled {
  color: var(--text-muted);
  background: var(--bg-hover);
}

.field__error {
  font-size: var(--text-sm);
  color: hsl(var(--color-danger));
  margin-top: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

/* ============ Badge variants ============ */

.badge--success {
  background: hsl(var(--color-success) / .12);
  color: hsl(var(--color-success));
  border-color: hsl(var(--color-success) / .3);
}

.badge--warning {
  background: hsl(var(--color-warning) / .12);
  color: hsl(var(--color-warning));
  border-color: hsl(var(--color-warning) / .3);
}

.badge--danger {
  background: hsl(var(--color-danger) / .1);
  color: hsl(var(--color-danger));
  border-color: hsl(var(--color-danger) / .3);
}

.badge--muted {
  background: var(--bg-elevated);
  color: var(--text-muted);
  border-color: var(--border-subtle);
}

.badge--info {
  background: hsl(var(--color-info) / .12);
  color: hsl(var(--color-info));
  border-color: hsl(var(--color-info) / .3);
}

/* ============ Alert variants ============ */

.alert--success {
  background: hsl(var(--color-success) / .1);
  color: hsl(var(--color-success));
  border: 1px solid hsl(var(--color-success) / .2);
}

/* ============ Loading bar ============ */

.loading-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  overflow: hidden;
  pointer-events: none;
}

.loading-bar::after {
  content: '';
  display: block;
  height: 100%;
  width: 0;
  background: hsl(var(--color-primary-500));
  transition: width .2s;
}

.loading-bar.is-active::after {
  width: 30%;
  animation: loading-slide 1s infinite linear;
}

@keyframes loading-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

/* ============ Amount colors ============ */

.amount-negative { color: hsl(var(--color-danger)); }
.amount-positive { color: hsl(var(--color-success)); }

/* ============ Balance cards ============ */

.balance-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-bottom: 24px;
}

.balance-card {
  padding: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}

.balance-card__label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: 4px;
}

.balance-card__value {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
}

.balance-card__value--danger { color: hsl(var(--color-danger)); }
.balance-card__value--success { color: hsl(var(--color-success)); }

/* ============ Tab badge ============ */

.tab-badge {
  display: inline-block;
  margin-inline-start: 6px;
  padding: 1px 8px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  font-size: 11px;
  color: var(--text-muted);
}

/* ============ Days badge ============ */

.days-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
}

.days-badge--ok {
  background: hsl(var(--color-success) / .15);
  color: hsl(var(--color-success));
}

.days-badge--warn {
  background: hsl(var(--color-warning) / .15);
  color: hsl(var(--color-warning));
}

.days-badge--danger {
  background: hsl(var(--color-danger) / .15);
  color: hsl(var(--color-danger));
}

/* ============ Tabs ============ */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 20px;
}

.tab {
  padding: 10px 16px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: var(--text-sm);
  user-select: none;
}

.tab.is-active {
  color: hsl(var(--color-primary-600));
  border-bottom-color: hsl(var(--color-primary-500));
  font-weight: var(--weight-medium);
}

/* ============ Divider ============ */

.divider-dot {
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--border-strong);
  vertical-align: middle;
  margin: 0 8px;
}

/* ---- Auth pages (glassmorphism) ---- */

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

/* Ambient glass blobs — decorative, non-interactive, theme-aware. */
.auth-body::before,
.auth-body::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  z-index: 0;
}

.auth-body::before {
  width: 520px;
  height: 520px;
  top: -140px;
  inset-inline-start: -120px;
  background: hsl(var(--color-primary-500) / .28);
}

.auth-body::after {
  width: 460px;
  height: 460px;
  bottom: -120px;
  inset-inline-end: -100px;
  background: hsl(var(--color-accent-500) / .24);
}

.auth-main { position: relative; z-index: 1; width: 100%; max-width: 420px; }

.auth-card {
  position: relative;
  /* True frosted glass: translucency + backdrop blur + inner highlight
   * border (works in both themes; tokens switch underneath). */
  background: hsl(var(--color-primary-500) / .07);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid hsl(var(--color-primary-300) / .35);
  border-radius: var(--radius-xl);
  padding: 40px 32px;
  box-shadow:
    inset 0 1px 0 hsl(0 0% 100% / .22),
    0 20px 60px hsl(232 45% 12% / .35);
  animation: fadeSlideUp 400ms ease-out;
}

/* Faint inner ring for the glass depth. */
.auth-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(
    160deg,
    hsl(0 0% 100% / .10) 0%,
    hsl(0 0% 100% / 0) 45%,
    hsl(0 0% 100% / .04) 100%
  );
}

/* Dark mode: darker tint + stronger glow border for legibility. */
[data-theme="dark"] .auth-card {
  background: hsl(var(--color-primary-500) / .06);
  border-color: hsl(var(--color-primary-300) / .22);
  box-shadow:
    inset 0 1px 0 hsl(0 0% 100% / .10),
    0 24px 64px hsl(0 0% 0% / .5);
}

.auth-brand { position: relative; text-align: center; margin-bottom: 28px; }

.auth-brand__mark {
  width: 96px;
  height: 96px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* NO background, NO border, NO circle: the source logo PNG is already
   * transparent, so it sits directly on the glass card. */
  background: transparent;
}

.auth-brand__mark img {
  width: 96px;
  height: 96px;
  object-fit: contain;
  /* Drop the (likely white-boxed) sampled logo asset a bit if it still
   * carries a subtle baked-in rim: blend the edge toward the glass. */
  filter: drop-shadow(0 6px 18px hsl(var(--color-primary-700) / .45));
}

.auth-brand h1 {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  margin: 0 0 4px;
}

.auth-brand p {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin: 0;
}

.auth-form { display: flex; flex-direction: column; gap: 18px; position: relative; }

.field { display: flex; flex-direction: column; gap: 6px; }

.field label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
}

.field input {
  padding: 11px 14px;
  background: hsl(var(--color-primary-500) / .06);
  border: 1px solid hsl(var(--color-primary-300) / .22);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  color: var(--text-primary);
  transition: all var(--transition-fast);
  width: 100%;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.field input::placeholder { color: var(--text-muted); }

.field input:focus {
  outline: none;
  border-color: hsl(var(--color-primary-400) / .75);
  background: hsl(var(--color-primary-500) / .1);
  box-shadow: 0 0 0 3px hsl(var(--color-primary-500) / .2);
}

.field__password { position: relative; }

.field__password input { padding-inline-end: 44px; }

.field__toggle {
  position: absolute;
  inset-inline-end: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
}

.field__toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
  user-select: none;
  cursor: pointer;
  color: var(--text-secondary);
}

/* Glassy primary button on the auth card. */
.auth-form .btn--primary {
  background: linear-gradient(
    135deg,
    hsl(var(--color-primary-600)),
    hsl(var(--color-primary-500))
  );
  padding-block: 12px;
  box-shadow:
    inset 0 1px 0 hsl(0 0% 100% / .28),
    0 10px 26px hsl(var(--color-primary-600) / .35);
}

.auth-form .btn--primary:hover {
  filter: brightness(1.06);
  background: linear-gradient(
    135deg,
    hsl(var(--color-primary-600)),
    hsl(var(--color-primary-500))
  );
}

/* ============ Sale item repeater ============ */

.item-card {
  padding: 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  position: relative;
}

.item-card__remove {
  position: absolute;
  inset-inline-end: 8px;
  top: 8px;
  background: transparent;
  border: 0;
  color: hsl(var(--color-danger));
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  font-size: var(--text-base);
  line-height: 1;
}

.item-card__remove:hover {
  background: hsl(var(--color-danger) / .1);
}

.item-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

@media (min-width: 720px) {
  .item-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.sale-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: hsl(var(--color-primary-500) / .08);
  border-radius: var(--radius-md);
  font-weight: var(--weight-semibold);
  color: hsl(var(--color-primary-600));
  margin-top: 16px;
}

.auth-footer {
  margin-top: 24px;
  text-align: center;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.auth-footer a {
  color: var(--text-muted);
  text-decoration: none;
}

.auth-footer a:hover { color: hsl(var(--color-primary-600)); }

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ============ List toolbar (live-search + combobox filters) ============ */
/* Every list page puts its filters in a form inside .card. These rules
 * force ALL filter inputs/comboboxes to one identical width and height
 * and let the toolbar span the full card width, overriding the per-view
 * inline max-width values. */

form[data-live-search],
.card > form.get-filter {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  width: 100%;
}

form[data-live-search] > .field,
.card > form.get-filter > .field {
  flex: 1 1 240px !important;
  min-width: 180px;
  max-width: none !important;
  margin: 0 !important;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

form[data-live-search] > .field input:not([type="hidden"]):not([type="checkbox"]),
form[data-live-search] > .field select,
.card > form.get-filter > .field input:not([type="hidden"]):not([type="checkbox"]),
.card > form.get-filter > .field select {
  height: 40px;
  box-sizing: border-box;
  padding: 0 14px;
  margin: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  color: var(--text-primary);
  width: 100%;
}

form[data-live-search] > .field input:focus,
form[data-live-search] > .field select:focus,
.card > form.get-filter > .field input:focus,
.card > form.get-filter > .field select:focus {
  outline: none;
  border-color: hsl(var(--color-primary-500));
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px hsl(var(--color-primary-500) / .15);
}

/* Reset / clear button sits in the same row → same height as the filters. */
form[data-live-search] > .btn,
.card > form.get-filter > .btn {
  height: 40px;
}

/* ============ Sidebar counter badge ============ */

.nav-link__badge {
  display: inline-flex;
  padding: 1px 8px;
  border-radius: 999px;
  background: hsl(var(--color-danger) / .15);
  color: hsl(var(--color-danger));
  font-size: 11px;
  font-weight: 600;
  margin-inline-start: auto;
}

/* Lighter variants for «در انتظار تأیید» / informational counts. */
.nav-link__badge--warning {
  background: hsl(var(--color-warning) / .18);
  color: hsl(var(--color-warning));
}

.nav-link__badge--info {
  background: hsl(var(--color-primary-500) / .15);
  color: hsl(var(--color-primary-600));
}

/* Partner tier badge next to the user name in the topbar. */
.topbar-user__tier {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* ============ Status badges (tokens only) ============ */

.badge--warning {
  background: hsl(var(--color-warning) / .12);
  color: hsl(var(--color-warning));
  border-color: hsl(var(--color-warning) / .3);
}

.badge--danger {
  background: hsl(var(--color-danger) / .12);
  color: hsl(var(--color-danger));
  border-color: hsl(var(--color-danger) / .3);
}

/* ---- Settings: per-item list editor (فهرست‌های سیستم) ---- */
.list-editor__items { display: flex; flex-direction: column; gap: 8px; }
.list-editor__row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.list-editor__row .list-editor__input { flex: 1 1 8rem; min-width: 0; margin: 0; }
.list-editor__remove { color: hsl(var(--color-danger)); padding: 4px 10px; }

/* ---- Settings: three-column card layout (تنظیمات) ----
   عمومی | مالی (+ تست ایمیل) | فهرست‌های سیستم
   روی صفحه‌های باریک به دو و بعد یک ستون جمع می‌شود. */
.settings-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr;
  align-items: start;
}

@media (min-width: 720px) {
  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .settings-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* هر کارت دقیقاً هم‌عرض ستون خودش است. align-self: start (رفتار قبلی)
   کارت را به اندازهٔ محتوایش جمع می‌کرد و عرض کارت‌ها ناهم‌اندازه می‌شد. */
.settings-card { align-self: stretch; }

/* هر ستون: کارت‌هایش پشت‌سرهم با فاصلهٔ یکنواخت. */
.settings-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-self: start;
}

/* فیلدها پشت‌سرهم و جمع‌وجور، نه پراکنده. */
.settings-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* هر فهرست یک کارت کوچک و مرتب، نه خطهای پراکنده. */
.settings-body .list-editor {
  padding: 14px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
}

/* نوار ذخیره: پایین‌ترین آیتم؛ خودِ کلید اندازهٔ طبیعی دارد، نه تمام عرض.
   در چیدمان راست‌به‌چپ، flex-start یعنی سمت راست — همان‌جایی که کاربر
   انتظار دکمهٔ ذخیره را دارد (flex-end دکمه را به چپ می‌برد). */
.settings-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-start;
  margin-top: 4px;
}

.settings-field { margin-bottom: 0; }

.field__input--numeric { font-variant-numeric: tabular-nums; }

/* ---- Avatar picker (انتخاب آواتار از storage/uploads/avatars) ---- */

.avatar-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.avatar-picker__item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 80px;
  cursor: pointer;
}

/* Radio is kept in the DOM (form submits it) but visually hidden. */
.avatar-picker__item > input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.avatar-picker__tile {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--border-subtle);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.avatar-picker__tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-picker__tile--none {
  color: var(--text-muted);
  font-size: var(--text-lg);
}

.avatar-picker__item > input:checked + .avatar-picker__tile {
  border-color: hsl(var(--color-primary-500));
  box-shadow: 0 0 0 3px hsl(var(--color-primary-500) / .2);
}

.avatar-picker__item > input:focus-visible + .avatar-picker__tile {
  outline: 2px solid hsl(var(--color-primary-600));
  outline-offset: 2px;
}

.avatar-picker__cap {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.3;
  word-break: break-all;
}

/* Avatar preview on profile / user pages. */
.profile-avatar {
  width: 88px;
  height: 88px;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  display: block;
}
/* --------------------------------------------------------------------------
   Login page — force center alignment
   -------------------------------------------------------------------------- */
.auth-brand,
.auth-brand h1,
.auth-brand p,
.auth-brand__mark {
  text-align: center;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 28px;
}

.auth-brand__mark {
  margin-inline: auto;
}

.auth-form,
.auth-footer {
  text-align: center;
}

.auth-form .field {
  text-align: right;   /* فیلدها متن راست (چون ورودی فارسی است) */
}
/* Login page logo — smaller */
.auth-brand__mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
}

.auth-brand__mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
/* Dashboard stat cards — centered layout */
.stat-card {
  text-align: center;
  align-items: center;
  flex-direction: column;
  gap: 12px;
}

.stat-card__top {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.stat-card__body {
  text-align: center;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.stat-card__label {
  text-align: center;
  margin: 0;
}

.stat-card__value {
  text-align: center;
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.stat-card__delta {
  text-align: center;
  margin: 0;
}

/* ============ Auth layout: app version ============ */

.auth-version {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin: 16px 0 0;
}

/* ============ Flash messages ============ */

.flash {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: var(--text-sm);
  transition: opacity .5s ease, transform .5s ease;
  border: 1px solid transparent;
  text-align: right;
}

.flash--fading {
  opacity: 0;
  transform: translateY(-6px);
}

.flash__text {
  flex: 1;
  line-height: 1.8;
}

.flash__close {
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  color: inherit;
  opacity: .55;
  padding: 0 4px;
}

.flash__close:hover {
  opacity: 1;
}

.flash--success {
  background: hsl(var(--color-success) / .1);
  color: hsl(var(--color-success));
  border-color: hsl(var(--color-success) / .3);
}

.flash--error {
  background: hsl(var(--color-danger) / .1);
  color: hsl(var(--color-danger));
  border-color: hsl(var(--color-danger) / .3);
}

.flash--info {
  background: hsl(var(--color-info) / .1);
  color: hsl(var(--color-info));
  border-color: hsl(var(--color-info) / .3);
}

/* ============ Ticket conversation bubbles ============ */

.ticket-msg {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  text-align: right;
}

.ticket-msg--admin {
  background: hsl(var(--color-primary-500) / .06);
  border-color: hsl(var(--color-primary-500) / .2);
  margin-inline-start: 40px;
}

.ticket-msg--partner,
.ticket-msg--customer {
  background: var(--bg-elevated);
  margin-inline-end: 40px;
}

.ticket-msg__head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.ticket-msg__author {
  font-weight: 600;
  color: var(--text-secondary);
}

.ticket-msg__body {
  font-size: var(--text-sm);
  line-height: 1.9;
  color: var(--text-primary);
  white-space: pre-wrap;
}

/* ===================== نمودار میله‌ای (SVG، بدون کتابخانه) ============ */
.bar-chart {
  width: 100%;
  overflow-x: auto;
  padding: 16px 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}

.bar-chart__svg { display: block; min-width: 600px; width: 100%; }

.bar-chart__bar {
  fill: hsl(var(--color-primary-500));
  transition: fill var(--transition-fast);
}

.bar-chart__bar:hover { fill: hsl(var(--color-primary-600)); }

.bar-chart__bar--accent { fill: hsl(var(--color-accent-500)); }

.bar-chart__label {
  font-size: 12px;
  fill: var(--text-muted);
  font-family: var(--font-sans);
  text-anchor: middle;
}

.bar-chart__value {
  font-size: 12px;
  fill: var(--text-primary);
  font-family: var(--font-sans);
  text-anchor: middle;
  font-weight: 600;
}

.bar-chart__grid {
  stroke: var(--border-subtle);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.bar-chart__axis {
  font-size: 11px;
  fill: var(--text-muted);
  font-family: var(--font-sans);
  text-anchor: end;
}

[data-theme="dark"] .bar-chart__bar { fill: hsl(var(--color-primary-400)); }

[data-theme="dark"] .bar-chart__bar--accent { fill: hsl(var(--color-accent-400)); }
