/* ===========================================================
   صبح ساحل — پنل اعضا  |  Sobhe Sahel Membership Platform
   Shared design system  (RTL, light/dark)
   =========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800;900&display=swap');

/* ---------- Tokens ---------- */
:root {
  --brand: #b81d47;          /* crimson wordmark / active */
  --brand-deep: #8e1638;
  --brand-soft: #fbe7ee;
  --plum: #6d4c5e;           /* signature plum button */
  --plum-deep: #553a49;
  --accent-red: #d92632;     /* اطلاعیه / alerts */
  --gold: #c79a32;
  --gold-soft: #f7eccb;

  --bg: #ffffff;
  --canvas: #f3f3f4;         /* page background */
  --surface: #ffffff;
  --surface-2: #f6f6f7;
  --header-bg: #f1f1f2;
  --text: #1e1e24;
  --text-muted: #6c6c77;
  --text-faint: #9a9aa4;
  --border: #e4e4e8;
  --border-strong: #d3d3da;

  --tier-bronze: #b06b3a;
  --tier-silver: #8f97a3;
  --tier-gold: #c79a32;
  --tier-platinum: #4f9bad;

  --shadow-sm: 0 1px 2px rgba(20,12,20,.06), 0 1px 3px rgba(20,12,20,.05);
  --shadow-md: 0 4px 14px rgba(30,15,30,.08);
  --shadow-lg: 0 16px 40px rgba(30,15,30,.13);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 24px;

  --maxw: 1280px;
  --header-h: 64px;
  --sidebar-w: 268px;

  --font: 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
}

[data-theme="dark"] {
  --brand: #ef5f87;
  --brand-deep: #cf486f;
  --brand-soft: #3a1f2a;
  --plum: #b388a0;
  --plum-deep: #8d6178;
  --accent-red: #f0606a;
  --gold: #e3bd5b;
  --gold-soft: #3a3320;

  --bg: #16131b;
  --canvas: #110f16;
  --surface: #1e1a25;
  --surface-2: #262030;
  --header-bg: #1a1722;
  --text: #efecf3;
  --text-muted: #a79fb2;
  --text-faint: #756d80;
  --border: #2c2736;
  --border-strong: #3a3346;

  --tier-bronze: #cd884f;
  --tier-silver: #aeb6c2;
  --tier-gold: #e3bd5b;
  --tier-platinum: #69bdd0;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 6px 18px rgba(0,0,0,.45);
  --shadow-lg: 0 20px 48px rgba(0,0,0,.55);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--canvas);
  color: var(--text);
  direction: rtl;
  line-height: 1.6;
  font-size: 15px;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, h5 { margin: 0; font-weight: 700; line-height: 1.3; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
input, textarea, select { max-width: 100%; }
ul { margin: 0; padding: 0; list-style: none; }
::selection { background: var(--brand); color: #fff; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* number font helper for Persian digits look */
.tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------- Top header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  background-image: repeating-linear-gradient(135deg, rgba(0,0,0,.014) 0 2px, transparent 2px 9px);
}
[data-theme="dark"] .topbar { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.018) 0 2px, transparent 2px 9px); }
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto; height: 100%;
  padding: 0 20px; display: flex; align-items: center; gap: 18px;
}
.brand-mark { display: flex; align-items: center; gap: 10px; }
.brand-word {
  font-weight: 900; font-size: 26px; color: var(--brand);
  letter-spacing: -.5px; line-height: 1;
}
.brand-tag { font-size: 10.5px; color: var(--text-faint); margin-top: 3px; font-weight: 500; }
.topnav { display: flex; gap: 22px; margin-inline-start: 6px; }
.topnav a { color: var(--text-muted); font-weight: 600; font-size: 14.5px; padding: 6px 0; position: relative; }
.topnav a:hover { color: var(--text); }
.topnav a.active { color: var(--brand); }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; border: 1px solid transparent;
  background: transparent; color: var(--text-muted); position: relative;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .dot { position: absolute; top: 9px; inset-inline-end: 10px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent-red); border: 2px solid var(--header-bg); }

.user-chip {
  display: flex; align-items: center; gap: 9px; padding: 4px 12px 4px 6px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  transition: box-shadow .15s, border-color .15s;
}
.user-chip:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); }
.user-chip .pts { font-weight: 800; font-size: 13px; color: var(--gold); display: flex; align-items: center; gap: 4px; }
.user-chip .uname { font-weight: 600; font-size: 13.5px; }
.avatar {
  border-radius: 50%; background: linear-gradient(135deg, var(--plum), var(--brand));
  color: #fff; display: grid; place-items: center; font-weight: 700; flex: none;
  width: 34px; height: 34px; font-size: 14px;
}
.avatar.lg { width: 64px; height: 64px; font-size: 24px; }
.avatar.xl { width: 84px; height: 84px; font-size: 30px; }

.hamburger { display: none; }

/* ---------- App layout (sidebar + main) ---------- */
.app { max-width: var(--maxw); margin: 0 auto; display: grid; grid-template-columns: var(--sidebar-w) 1fr; gap: 24px; padding: 24px 20px 60px; align-items: start; }
.app.no-side { grid-template-columns: 1fr; }

.sidebar { position: sticky; top: calc(var(--header-h) + 24px); display: flex; flex-direction: column; gap: 16px; }
.side-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.side-userbox { padding: 18px; text-align: center; }
.side-userbox .name { font-weight: 700; margin-top: 10px; font-size: 16px; }
.side-userbox .meta { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }

.tier-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.tier-badge svg { width: 13px; height: 13px; }
.tier-bronze { background: color-mix(in srgb, var(--tier-bronze) 16%, transparent); color: var(--tier-bronze); }
.tier-silver { background: color-mix(in srgb, var(--tier-silver) 20%, transparent); color: var(--tier-silver); }
.tier-gold   { background: color-mix(in srgb, var(--tier-gold) 20%, transparent); color: var(--tier-gold); }
.tier-platinum { background: color-mix(in srgb, var(--tier-platinum) 18%, transparent); color: var(--tier-platinum); }

.side-progress { margin-top: 14px; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--plum), var(--brand)); }
.side-progress .lbl { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-muted); margin-top: 6px; }

.side-nav { padding: 8px; }
.side-nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--r-md); color: var(--text-muted); font-weight: 600; font-size: 14px; transition: background .14s, color .14s; }
.side-nav a svg { width: 19px; height: 19px; flex: none; }
.side-nav a:hover { background: var(--surface-2); color: var(--text); }
.side-nav a.active { background: var(--brand-soft); color: var(--brand); }
.side-nav a .badge-n { margin-inline-start: auto; background: var(--accent-red); color: #fff; font-size: 11px; font-weight: 700; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 99px; display: grid; place-items: center; }
.side-nav .sep { height: 1px; background: var(--border); margin: 8px 10px; }

.main { min-width: 0; }

/* ---------- Generic components ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card.pad { padding: 20px; }
.card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.card-h h3 { font-size: 17px; }
.card-h .more { margin-inline-start: auto; font-size: 13px; color: var(--brand); font-weight: 600; }

.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 25px; }
.page-head p { color: var(--text-muted); margin-top: 6px; }
.breadcrumb { display: flex; align-items: center; gap: 7px; color: var(--text-faint); font-size: 12.5px; margin-bottom: 12px; }
.breadcrumb a:hover { color: var(--brand); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 999px; padding: 11px 22px; font-weight: 700; font-size: 14.5px; transition: transform .08s, box-shadow .15s, background .15s; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; }
.btn-plum { background: var(--plum); color: #fff; box-shadow: var(--shadow-sm); }
.btn-plum:hover { background: var(--plum-deep); }
.btn-brand { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.btn-brand:hover { background: var(--brand-deep); }
.btn-gold { background: var(--gold); color: #2a2208; }
.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-soft { background: var(--brand-soft); color: var(--brand); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 99px; font-size: 11.5px; font-weight: 700; }
.pill-red { background: color-mix(in srgb, var(--accent-red) 14%, transparent); color: var(--accent-red); }
.pill-green { background: color-mix(in srgb, #1f9d57 16%, transparent); color: #1f9d57; }
.pill-gold { background: var(--gold-soft); color: var(--gold); }
[data-theme="dark"] .pill-green { color:#46c483; }

.stat-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(170px,1fr)); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px 18px; box-shadow: var(--shadow-sm); display:flex; flex-direction:column; gap:6px; }
.stat .ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; }
.stat .ic svg { width: 21px; height: 21px; }
.stat .num { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.stat .cap { color: var(--text-muted); font-size: 13px; }

.ic-plum { background: color-mix(in srgb, var(--plum) 16%, transparent); color: var(--plum); }
.ic-brand { background: var(--brand-soft); color: var(--brand); }
.ic-gold { background: var(--gold-soft); color: var(--gold); }
.ic-green { background: color-mix(in srgb,#1f9d57 14%, transparent); color:#1f9d57; }

/* media placeholder */
.ph { background:
    linear-gradient(135deg, color-mix(in srgb,var(--plum) 18%, var(--surface-2)), var(--surface-2));
  position: relative; overflow: hidden; display: grid; place-items: center; color: var(--text-faint); }
.ph::after { content: "صبح ساحل"; position:absolute; font-size: 13px; font-weight:800; color: color-mix(in srgb, var(--brand) 28%, transparent); transform: rotate(-12deg); letter-spacing:1px; opacity:.5; }
.ph svg { width: 30%; height: 30%; opacity: .35; }

/* forms */
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 7px; color: var(--text); }
.input { width: 100%; padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-size: 15px; transition: border-color .15s, box-shadow .15s; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input::placeholder { color: var(--text-faint); }

/* toggle switch */
.switch { width: 44px; height: 25px; border-radius: 99px; background: var(--border-strong); position: relative; transition: background .2s; flex: none; }
.switch::after { content:""; position: absolute; width: 19px; height: 19px; border-radius: 50%; background: #fff; top: 3px; inset-inline-end: 3px; transition: inset-inline-end .2s; box-shadow: var(--shadow-sm); }
.switch.on { background: var(--brand); }
.switch.on::after { inset-inline-end: 22px; }

/* table */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: right; padding: 13px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
.tbl th { color: var(--text-muted); font-weight: 600; font-size: 12.5px; }
.tbl tr:last-child td { border-bottom: none; }

/* section title with bar */
.sec-title { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 800; margin: 0 0 16px; }
.sec-title::before { content:""; width: 5px; height: 22px; border-radius: 3px; background: var(--accent-red); }

/* footer */
.foot { border-top: 1px solid var(--border); background: var(--header-bg); margin-top: 40px; }
.foot-inner { max-width: var(--maxw); margin: 0 auto; padding: 26px 20px; display: flex; flex-wrap: wrap; gap: 14px; align-items: center; color: var(--text-muted); font-size: 13px; }
.foot-inner .brand-word { font-size: 20px; }

/* toast */
.toast-wrap { position: fixed; bottom: 22px; inset-inline-start: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: var(--r-md); box-shadow: var(--shadow-lg); font-weight: 600; font-size: 14px; display:flex; align-items:center; gap:9px; animation: toastIn .25s ease; }
.toast svg { width:18px; height:18px; color: var(--gold); }
@keyframes toastIn { from { opacity:0; transform: translateY(10px);} to {opacity:1; transform:none;} }

/* mobile drawer backdrop */
.backdrop { position: fixed; inset: 0; background: rgba(10,6,12,.45); z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s; }
.backdrop.show { opacity: 1; pointer-events: auto; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; right: 0; left: auto; bottom: 0;
    height: 100dvh; width: 280px; max-width: 86vw; z-index: 70;
    background: var(--bg); padding: 18px; overflow-y: auto;
    transform: translateX(110%); visibility: hidden;
    transition: transform .25s ease, visibility .25s; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); visibility: visible; }
  .sidebar:not(.open) { pointer-events: none; }
  .topnav { display: none; }
  .hamburger { display: grid; }
}
@media (max-width: 620px) {
  .user-chip .uname, .user-chip .pts span { display: none; }
  .topbar-inner { padding: 0 14px; gap: 10px; }
  .app { padding: 16px 14px 50px; }
  .brand-word { font-size: 22px; }
  .page-head h1 { font-size: 21px; }
}
