/* ============================================================
   MAYDAN | ميدان — Demo Design System
   Bootstrap 5 RTL · Cairo font · Light-first (dark optional)
   ============================================================ */

:root {
  /* Brand */
  --my-primary: #0d9488;
  --my-primary-700: #0b7c72;
  --my-primary-100: #d9f2ef;
  --my-indigo: #6366f1;
  --my-indigo-100: #e5e6fb;
  --my-amber: #d97706;
  --my-amber-100: #fdeed7;
  --my-pink: #db2777;
  --my-pink-100: #fbdeeb;

  /* Surfaces & ink (light) */
  --my-body: #f4f6f8;
  --my-card: #ffffff;
  --my-border: #e6eaef;
  --my-ink: #1e293b;
  --my-ink-2: #64748b;
  --my-ink-3: #94a3b8;
  --my-sidebar: #ffffff;
  --my-topbar: rgba(255, 255, 255, .85);
  --my-hover: #f1f5f9;
  --my-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -12px rgba(15, 23, 42, .10);

  --my-radius: 1rem;
  --my-sidebar-w: 264px;
}

[data-bs-theme="dark"] {
  --my-primary-100: #123f3b;
  --my-indigo-100: #26275a;
  --my-amber-100: #423113;
  --my-pink-100: #47182e;
  --my-body: #0f172a;
  --my-card: #16203a;
  --my-border: #233150;
  --my-ink: #e2e8f0;
  --my-ink-2: #94a3b8;
  --my-ink-3: #64748b;
  --my-sidebar: #111a30;
  --my-topbar: rgba(17, 26, 48, .85);
  --my-hover: #1d2a4a;
  --my-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .5);
}

* { font-family: "Cairo", system-ui, -apple-system, sans-serif; }

html { scroll-behavior: smooth; }

body {
  background: var(--my-body);
  color: var(--my-ink);
  min-height: 100vh;
  font-size: .925rem;
}

/* ---------- Layout: sidebar + main ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--my-sidebar-w);
  background: var(--my-sidebar);
  border-inline-end: 1px solid var(--my-border);
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  z-index: 1045;
  display: flex;
  flex-direction: column;
  transition: transform .28s ease;
  overflow-y: auto;
  scrollbar-width: thin;
}

.sidebar-brand {
  display: flex; align-items: center; gap: .7rem;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--my-border);
}
.brand-mark {
  width: 42px; height: 42px; border-radius: .85rem;
  background: linear-gradient(135deg, var(--my-primary), #14b8a6 60%, #2dd4bf);
  color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 1.15rem;
  box-shadow: 0 6px 14px -6px rgba(13, 148, 136, .55);
}
.brand-name { font-weight: 800; font-size: 1.15rem; line-height: 1.1; }
.brand-sub { font-size: .68rem; color: var(--my-ink-3); letter-spacing: .5px; }

.sidebar-nav { padding: .85rem .75rem; flex: 1; }
.sidebar-nav .nav-label {
  font-size: .68rem; font-weight: 700; color: var(--my-ink-3);
  padding: .9rem .75rem .35rem; letter-spacing: .5px;
}
.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: .7rem;
  color: var(--my-ink-2);
  font-weight: 600; font-size: .875rem;
  padding: .58rem .8rem; margin-bottom: .15rem;
  border-radius: .7rem;
  transition: all .15s ease;
}
.sidebar-nav .nav-link i { font-size: 1.05rem; width: 1.3rem; text-align: center; }
.sidebar-nav .nav-link:hover { background: var(--my-hover); color: var(--my-ink); }
.sidebar-nav .nav-link.active {
  background: var(--my-primary-100); color: var(--my-primary-700);
}
[data-bs-theme="dark"] .sidebar-nav .nav-link.active { color: #5eead4; }
.sidebar-nav .nav-link .badge { margin-inline-start: auto; font-size: .65rem; }

.sidebar-user {
  border-top: 1px solid var(--my-border);
  padding: .9rem 1.1rem;
  display: flex; align-items: center; gap: .7rem;
}

/* ---------- Main column ---------- */
.main-col {
  flex: 1;
  margin-inline-start: var(--my-sidebar-w);
  display: flex; flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky; top: 0; z-index: 1030;
  background: var(--my-topbar);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--my-border);
  padding: .65rem 1.4rem;
  display: flex; align-items: center; gap: .9rem;
}
.topbar .search-box { max-width: 380px; flex: 1; }
.topbar .search-box .form-control {
  background: var(--my-hover); border: 1px solid transparent;
  border-radius: .75rem; padding-inline-start: 2.4rem;
}
.topbar .search-box .form-control:focus { border-color: var(--my-primary); box-shadow: none; background: var(--my-card); }
.topbar .search-box i { position: absolute; inset-inline-start: .85rem; top: 50%; transform: translateY(-50%); color: var(--my-ink-3); }

.icon-btn {
  width: 40px; height: 40px; border-radius: .75rem;
  display: grid; place-items: center;
  border: 1px solid var(--my-border);
  background: var(--my-card); color: var(--my-ink-2);
  position: relative; transition: all .15s;
}
.icon-btn:hover { background: var(--my-hover); color: var(--my-ink); }
.icon-btn .dot {
  position: absolute; top: 9px; inset-inline-end: 9px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--my-pink); border: 2px solid var(--my-card);
}

.content { padding: 1.5rem 1.4rem 3rem; max-width: 1440px; width: 100%; margin-inline: auto; }

/* ---------- Sections (SPA-like) ---------- */
.app-section { display: none; animation: fadeUp .3s ease; }
.app-section.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.35rem; font-weight: 800; margin: 0; }
.page-head .text-muted-2 { font-size: .8rem; }

/* ---------- Cards ---------- */
.card {
  background: var(--my-card);
  border: 1px solid var(--my-border);
  border-radius: var(--my-radius);
  box-shadow: var(--my-shadow);
}
.card-header {
  background: transparent; border-bottom: 1px solid var(--my-border);
  padding: 1rem 1.25rem; font-weight: 700;
}

.kpi-card { padding: 1.1rem 1.2rem; height: 100%; }
.kpi-card .kpi-icon {
  width: 46px; height: 46px; border-radius: .85rem;
  display: grid; place-items: center; font-size: 1.25rem;
}
.kpi-card .kpi-val { font-size: 1.5rem; font-weight: 800; line-height: 1.2; }
.kpi-card .kpi-lbl { font-size: .78rem; color: var(--my-ink-2); font-weight: 600; }
.kpi-trend { font-size: .72rem; font-weight: 700; }

.tint-primary { background: var(--my-primary-100); color: var(--my-primary-700); }
.tint-indigo  { background: var(--my-indigo-100);  color: var(--my-indigo); }
.tint-amber   { background: var(--my-amber-100);   color: var(--my-amber); }
.tint-pink    { background: var(--my-pink-100);    color: var(--my-pink); }
[data-bs-theme="dark"] .tint-primary { color: #5eead4; }
[data-bs-theme="dark"] .tint-indigo  { color: #a5b4fc; }
[data-bs-theme="dark"] .tint-amber   { color: #fbbf24; }
[data-bs-theme="dark"] .tint-pink    { color: #f9a8d4; }

/* ---------- Status badges ---------- */
.badge-soft { font-weight: 700; font-size: .7rem; padding: .38em .7em; border-radius: 2rem; }
.st-success { background: #d9f2e5; color: #0c7a43; }
.st-warning { background: #fdeed7; color: #b45309; }
.st-danger  { background: #fbdfe2; color: #b3123c; }
.st-info    { background: #dbeafe; color: #1d4ed8; }
.st-neutral { background: var(--my-hover); color: var(--my-ink-2); }
.st-purple  { background: #ece9fe; color: #6d28d9; }
[data-bs-theme="dark"] .st-success { background: #0c3a26; color: #4ade80; }
[data-bs-theme="dark"] .st-warning { background: #43300f; color: #fbbf24; }
[data-bs-theme="dark"] .st-danger  { background: #47131f; color: #fb7185; }
[data-bs-theme="dark"] .st-info    { background: #172a54; color: #93c5fd; }
[data-bs-theme="dark"] .st-neutral { background: #23304d; color: #94a3b8; }
[data-bs-theme="dark"] .st-purple  { background: #2c2159; color: #c4b5fd; }

/* ---------- Tables ---------- */
.table { --bs-table-bg: transparent; margin: 0; }
.table thead th {
  font-size: .72rem; font-weight: 700; color: var(--my-ink-3);
  text-transform: none; border-bottom: 1px solid var(--my-border);
  padding: .8rem 1rem; white-space: nowrap;
}
.table tbody td { padding: .8rem 1rem; vertical-align: middle; border-color: var(--my-border); font-size: .85rem; }
.table-hover tbody tr:hover { background: var(--my-hover); }

.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: .8rem; color: #fff;
  flex-shrink: 0;
}
.avatar-lg { width: 76px; height: 76px; font-size: 1.5rem; border-radius: 1.4rem; }
.av-1 { background: linear-gradient(135deg, #0d9488, #2dd4bf); }
.av-2 { background: linear-gradient(135deg, #6366f1, #a78bfa); }
.av-3 { background: linear-gradient(135deg, #d97706, #fbbf24); }
.av-4 { background: linear-gradient(135deg, #db2777, #f472b6); }
.av-5 { background: linear-gradient(135deg, #0ea5e9, #38bdf8); }

/* ---------- Progress ---------- */
.progress { background: var(--my-hover); border-radius: 2rem; }
.progress-thin { height: 7px; }

/* ---------- Buttons ---------- */
.btn { border-radius: .7rem; font-weight: 700; }
.btn-primary {
  --bs-btn-bg: var(--my-primary); --bs-btn-border-color: var(--my-primary);
  --bs-btn-hover-bg: var(--my-primary-700); --bs-btn-hover-border-color: var(--my-primary-700);
  --bs-btn-active-bg: var(--my-primary-700); --bs-btn-active-border-color: var(--my-primary-700);
}
.btn-soft {
  background: var(--my-primary-100); color: var(--my-primary-700); border: none;
}
.btn-soft:hover { background: var(--my-primary); color: #fff; }
.btn-outline-light-2 { border: 1px solid var(--my-border); color: var(--my-ink-2); background: var(--my-card); }
.btn-outline-light-2:hover { background: var(--my-hover); color: var(--my-ink); }

/* ---------- Filter bar ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.filter-bar .form-select, .filter-bar .form-control {
  border-radius: .7rem; border-color: var(--my-border);
  font-size: .82rem; font-weight: 600; min-width: 140px; width: auto;
  background-color: var(--my-card); color: var(--my-ink);
}

/* ---------- Opportunity / campaign cards ---------- */
.opp-card { overflow: hidden; transition: transform .18s ease, box-shadow .18s ease; height: 100%; }
.opp-card:hover { transform: translateY(-3px); box-shadow: 0 14px 30px -14px rgba(15, 23, 42, .22); }
.opp-cover { height: 96px; position: relative; }
.opp-cover .company-chip {
  position: absolute; bottom: -18px; inset-inline-start: 1.1rem;
  width: 52px; height: 52px; border-radius: 1rem;
  background: var(--my-card); border: 1px solid var(--my-border);
  display: grid; place-items: center; font-size: 1.4rem;
  box-shadow: var(--my-shadow);
}
.grad-1 { background: linear-gradient(120deg, #0d9488, #2dd4bf); }
.grad-2 { background: linear-gradient(120deg, #6366f1, #a78bfa); }
.grad-3 { background: linear-gradient(120deg, #d97706, #fbbf24); }
.grad-4 { background: linear-gradient(120deg, #db2777, #f472b6); }
.grad-5 { background: linear-gradient(120deg, #0ea5e9, #22d3ee); }

/* ---------- Gamification ---------- */
.level-ring {
  width: 92px; height: 92px; border-radius: 50%;
  background: conic-gradient(var(--my-amber) calc(var(--p) * 1%), var(--my-hover) 0);
  display: grid; place-items: center;
}
.level-ring > div {
  width: 74px; height: 74px; border-radius: 50%;
  background: var(--my-card); display: grid; place-items: center;
  text-align: center; font-weight: 800;
}
.badge-tile {
  text-align: center; padding: 1rem .5rem; border-radius: 1rem;
  border: 1px solid var(--my-border); background: var(--my-card);
  transition: transform .15s;
}
.badge-tile:hover { transform: translateY(-3px); }
.badge-tile .emoji { font-size: 1.9rem; }
.badge-tile.locked { opacity: .4; filter: grayscale(1); }

/* ---------- Chat ---------- */
.chat-list-item { padding: .8rem 1rem; border-bottom: 1px solid var(--my-border); cursor: pointer; display: flex; gap: .7rem; align-items: center; }
.chat-list-item:hover, .chat-list-item.active { background: var(--my-hover); }
.chat-bubble { max-width: 75%; padding: .6rem .95rem; border-radius: 1.1rem; font-size: .85rem; }
.bubble-in  { background: var(--my-hover); border-start-start-radius: .3rem; }
.bubble-out { background: var(--my-primary); color: #fff; border-start-end-radius: .3rem; }

/* ---------- Map demo ---------- */
.map-demo {
  position: relative; min-height: 460px; border-radius: var(--my-radius);
  background:
    radial-gradient(circle at 30% 20%, rgba(13,148,136,.08), transparent 42%),
    radial-gradient(circle at 75% 65%, rgba(99,102,241,.07), transparent 45%),
    repeating-linear-gradient(0deg, transparent 0 39px, var(--my-border) 39px 40px),
    repeating-linear-gradient(90deg, transparent 0 39px, var(--my-border) 39px 40px),
    var(--my-hover);
  overflow: hidden;
}
.map-pin { position: absolute; transform: translate(-50%, -50%); text-align: center; }
.map-pin .pulse {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--my-primary); margin-inline: auto;
  box-shadow: 0 0 0 rgba(13,148,136,.45); animation: pulse 2s infinite;
}
.map-pin.pin-indigo .pulse { background: var(--my-indigo); animation-name: pulseIndigo; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(13,148,136,.45); } 70% { box-shadow: 0 0 0 14px rgba(13,148,136,0); } 100% { box-shadow: 0 0 0 0 rgba(13,148,136,0); } }
@keyframes pulseIndigo { 0% { box-shadow: 0 0 0 0 rgba(99,102,241,.45); } 70% { box-shadow: 0 0 0 14px rgba(99,102,241,0); } 100% { box-shadow: 0 0 0 0 rgba(99,102,241,0); } }
.map-pin .pin-label {
  margin-top: .3rem; background: var(--my-card); border: 1px solid var(--my-border);
  border-radius: 2rem; font-size: .68rem; font-weight: 700;
  padding: .15rem .6rem; box-shadow: var(--my-shadow); white-space: nowrap;
}
.map-watermark {
  position: absolute; bottom: 12px; inset-inline-start: 14px;
  font-size: .7rem; font-weight: 700; color: var(--my-ink-3);
  background: var(--my-card); border: 1px dashed var(--my-border);
  padding: .2rem .7rem; border-radius: 2rem;
}

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-inline-start: 1.4rem; }
.timeline::before {
  content: ""; position: absolute; inset-block: 4px; inset-inline-start: 7px;
  width: 2px; background: var(--my-border);
}
.timeline-item { position: relative; padding-bottom: 1.1rem; }
.timeline-item::before {
  content: ""; position: absolute; inset-inline-start: -1.4rem; top: 5px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--my-card); border: 3px solid var(--my-primary);
}
.timeline-item.muted::before { border-color: var(--my-ink-3); }

/* ---------- Steps (wizard) ---------- */
.step-dots { display: flex; align-items: center; gap: .4rem; }
.step-dot {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-size: .75rem; font-weight: 800;
  background: var(--my-hover); color: var(--my-ink-3);
}
.step-dot.done { background: var(--my-primary); color: #fff; }
.step-dot.current { background: var(--my-primary-100); color: var(--my-primary-700); outline: 2px solid var(--my-primary); }
.step-line { flex: 1; height: 2px; background: var(--my-border); min-width: 16px; }
.step-line.done { background: var(--my-primary); }

/* ---------- Leaderboard ---------- */
.rank-chip {
  width: 30px; height: 30px; border-radius: .6rem; display: grid; place-items: center;
  font-weight: 800; font-size: .8rem; background: var(--my-hover); color: var(--my-ink-2);
}
.rank-1 { background: #fef3c7; color: #b45309; }
.rank-2 { background: #e5e7eb; color: #374151; }
.rank-3 { background: #fde8d7; color: #c2410c; }
[data-bs-theme="dark"] .rank-1 { background: #43300f; color: #fbbf24; }
[data-bs-theme="dark"] .rank-2 { background: #2b3546; color: #cbd5e1; }
[data-bs-theme="dark"] .rank-3 { background: #46220d; color: #fb923c; }

/* ---------- Member app (bottom nav on mobile) ---------- */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; inset-inline: 0; z-index: 1040;
  background: var(--my-card); border-top: 1px solid var(--my-border);
  padding: .35rem .5rem calc(.35rem + env(safe-area-inset-bottom));
}
.bottom-nav .bn-link {
  flex: 1; text-align: center; color: var(--my-ink-3);
  font-size: .62rem; font-weight: 700; text-decoration: none;
  padding: .25rem 0; border-radius: .6rem;
}
.bottom-nav .bn-link i { display: block; font-size: 1.25rem; margin-bottom: .1rem; }
.bottom-nav .bn-link.active { color: var(--my-primary); }

/* ---------- Landing ---------- */
.landing-hero {
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 15%, rgba(13,148,136,.14), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(99,102,241,.12), transparent 45%),
    var(--my-body);
  display: flex; align-items: center; padding: 3rem 1rem;
}
.role-card { text-align: center; padding: 2rem 1.4rem; height: 100%; cursor: pointer; transition: all .2s ease; }
.role-card:hover { transform: translateY(-5px); border-color: var(--my-primary); }
.role-card .role-icon {
  width: 72px; height: 72px; border-radius: 1.4rem; margin-inline: auto;
  display: grid; place-items: center; font-size: 2rem; margin-bottom: 1rem;
}

/* ---------- Misc ---------- */
.text-muted-2 { color: var(--my-ink-2) !important; }
.text-muted-3 { color: var(--my-ink-3) !important; }
.fw-800 { font-weight: 800; }
.fs-7 { font-size: .8rem; }
.fs-8 { font-size: .72rem; }
.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  background: var(--my-hover); color: var(--my-ink-2);
  border-radius: 2rem; padding: .25rem .75rem;
  font-size: .74rem; font-weight: 700;
}
.divider-v { width: 1px; align-self: stretch; background: var(--my-border); }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--my-ink-3); }
.empty-state i { font-size: 2.6rem; display: block; margin-bottom: .6rem; }

.demo-ribbon {
  position: fixed; top: 14px; inset-inline-end: -44px; z-index: 2000;
  transform: rotate(-45deg); transform-origin: center;
  background: var(--my-amber); color: #fff;
  font-size: .68rem; font-weight: 800; letter-spacing: 1px;
  padding: .25rem 3rem; pointer-events: none;
}
html[dir="rtl"] .demo-ribbon { transform: rotate(45deg); }

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(100%); box-shadow: none; }
  html[dir="ltr"] .sidebar { transform: translateX(-100%); }
  body.sidebar-open .sidebar { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.25); }
  .main-col { margin-inline-start: 0; }
  .sidebar-backdrop {
    position: fixed; inset: 0; z-index: 1044; background: rgba(15,23,42,.45);
    opacity: 0; pointer-events: none; transition: opacity .25s;
  }
  body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .content { padding-inline: 1rem; }
  body.has-bottom-nav .bottom-nav { display: flex; }
  body.has-bottom-nav .content { padding-bottom: 5.5rem; }
}

/* Print-ish scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--my-border); border-radius: 4px; }
