/* Smart Promotion Platform — RTL dashboard theme */
:root {
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-soft: #eef2ff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f6f7fb;
  --card: #ffffff;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --sidebar-w: 272px;
}

[data-bs-theme="dark"] {
  --ink: #e2e8f0;
  --muted: #94a3b8;
  --line: #1e293b;
  --bg: #0b1120;
  --card: #111a2e;
  --brand-soft: #1e1b4b;
}

* { outline-color: var(--brand); }

body {
  font-family: "Tajawal", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 0.95rem;
}

a { text-decoration: none; }

.app-shell { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  position: fixed;
  inset-inline-start: 0;
  top: 0;
  bottom: 0;
  z-index: 1040;
  background: linear-gradient(180deg, #111827 0%, #0b1220 55%, #111827 100%);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  transition: transform .25s ease;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: 1.15rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.brand-link { display: flex; align-items: center; gap: .75rem; color: #fff; }
.brand-icon {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; font-size: 1.2rem;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 8px 20px rgba(79,70,229,.45);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: .98rem; font-weight: 800; }
.brand-text small { color: #94a3b8; font-size: .7rem; letter-spacing: .04em; }

.sidebar-nav { padding: .6rem .65rem 1rem; flex: 1; }
.nav-section {
  font-size: .67rem; text-transform: uppercase; letter-spacing: .08em;
  color: #64748b; margin: 1rem .65rem .35rem; font-weight: 700;
}
.nav-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem .7rem; margin-bottom: .15rem;
  color: #cbd5e1; border-radius: 10px; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item i { font-size: 1.05rem; width: 1.4rem; text-align: center; color: #94a3b8; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item:hover i { color: #c7d2fe; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(79,70,229,.35), rgba(124,58,237,.18));
  color: #fff;
  box-shadow: inset 3px 0 0 #818cf8;
}
.nav-item.active i { color: #c7d2fe; }
.nav-badge {
  margin-inline-start: auto; background: var(--danger); color: #fff;
  font-size: .66rem; padding: .12rem .42rem; border-radius: 999px; font-weight: 700;
}

.sidebar-footer { padding: .9rem; border-top: 1px solid rgba(255,255,255,.07); }
.support-box {
  display: flex; gap: .6rem; align-items: center;
  background: rgba(255,255,255,.05); border-radius: 10px; padding: .6rem .7rem; margin-bottom: .5rem;
}
.support-box i { font-size: 1.15rem; color: #a5b4fc; }
.support-box small { display: block; color: #94a3b8; font-size: .68rem; }
.support-box a { color: #e2e8f0; font-size: .82rem; font-weight: 600; }

/* Main */
.main-wrapper { flex: 1; margin-inline-start: var(--sidebar-w); min-width: 0; }

.topbar {
  height: 68px; display: flex; align-items: center; gap: 1rem;
  padding: 0 1.5rem; background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 1020;
}
.topbar-search {
  position: relative; flex: 1; max-width: 440px;
}
.topbar-search i { position: absolute; inset-inline-start: .85rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.topbar-search input {
  width: 100%; border: 1px solid var(--line); background: var(--bg);
  border-radius: 10px; padding: .5rem .85rem .5rem 2.4rem; padding-inline-start: 2.4rem; font-size: .88rem;
}
.topbar-search input:focus { background: var(--card); border-color: #a5b4fc; box-shadow: 0 0 0 .2rem rgba(79,70,229,.12); }

.topbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: .45rem; }
.btn-icon { width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 10px; }
.notif-dot {
  position: absolute; top: 2px; inset-inline-end: 0;
  background: var(--danger); color: #fff; font-size: .6rem;
  min-width: 16px; height: 16px; border-radius: 999px; display: grid; place-items: center; padding: 0 3px;
}
.user-chip {
  display: flex; align-items: center; gap: .55rem;
  background: transparent; border: 1px solid transparent; border-radius: 12px; padding: .25rem .45rem;
}
.user-chip:hover { background: var(--bg); }
.user-chip strong { font-size: .82rem; line-height: 1.1; }
.user-chip small { color: var(--muted); font-size: .7rem; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .8rem;
}

.content { padding: 1.6rem 1.75rem 2rem; max-width: 1500px; }
.page-header {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;
  margin-bottom: 1.25rem; flex-wrap: wrap;
}
.page-title { font-size: 1.45rem; font-weight: 800; margin: 0; letter-spacing: -.01em; }
.page-subtitle { color: var(--muted); margin: .25rem 0 0; font-size: .85rem; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Cards & KPI */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 1px 2px rgba(15,23,42,.03); }
.card-header { background: transparent; border-bottom: 1px solid var(--line); padding: .9rem 1.1rem; font-weight: 700; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.card-body { padding: 1.1rem; }
.kpi-card { padding: 1.05rem 1.1rem; height: 100%; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { color: var(--muted); font-size: .78rem; font-weight: 600; }
.kpi-value { font-size: 1.75rem; font-weight: 800; line-height: 1.2; margin-top: .35rem; }
.kpi-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 1.15rem; background: var(--brand-soft); color: var(--brand); }
.kpi-icon.success { background: rgba(16,185,129,.12); color: var(--success); }
.kpi-icon.warning { background: rgba(245,158,11,.13); color: var(--warning); }
.kpi-icon.danger { background: rgba(239,68,68,.12); color: var(--danger); }
.kpi-icon.info { background: rgba(14,165,233,.12); color: #0284c7; }
.kpi-hint { color: var(--muted); font-size: .72rem; margin-top: .35rem; }

/* Tables */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > thead th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .03em;
  color: var(--muted); font-weight: 700; border-bottom: 1px solid var(--line); padding: .65rem .75rem;
}
.table > tbody td { padding: .7rem .75rem; vertical-align: middle; border-color: var(--line); font-size: .86rem; }
.table-hover > tbody > tr:hover > * { background: rgba(79,70,229,.04); }

.badge { font-weight: 600; padding: .35em .55em; border-radius: 7px; font-size: .72rem; }
.soft-badge { background: var(--brand-soft); color: var(--brand); }

/* Forms */
.form-label { font-weight: 600; font-size: .82rem; margin-bottom: .35rem; }
.form-control, .form-select { border-radius: 9px; border-color: var(--line); padding: .5rem .75rem; font-size: .87rem; background: var(--card); color: var(--ink); }
.form-control:focus, .form-select:focus { border-color: #a5b4fc; box-shadow: 0 0 0 .2rem rgba(79,70,229,.12); }
.form-text { font-size: .72rem; color: var(--muted); }
.invalid-feedback { display: block; }

.btn { border-radius: 9px; font-weight: 600; font-size: .85rem; }
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover { background: #4338ca; border-color: #4338ca; }
.btn-outline-primary { color: var(--brand); border-color: #c7d2fe; }
.btn-outline-primary:hover { background: var(--brand); border-color: var(--brand); }
.btn-light { background: var(--bg); border-color: var(--line); color: var(--ink); }
[data-bs-theme="dark"] .btn-light { background: #1e293b; border-color: #334155; color: #e2e8f0; }

/* Helpers */
.text-muted { color: var(--muted) !important; }
.muted-small { color: var(--muted); font-size: .78rem; }
.avatar-sm { width: 30px; height: 30px; border-radius: 8px; object-fit: cover; }
.table-actions { display: flex; gap: .25rem; justify-content: flex-end; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty-state i { font-size: 2.2rem; opacity: .4; display: block; margin-bottom: .6rem; }
.divider { height: 1px; background: var(--line); margin: 1rem 0; }
.chart-box { position: relative; height: 280px; }

/* Page tabs */
.nav-tabs .nav-link { color: var(--muted); border: 0; border-bottom: 2px solid transparent; font-weight: 600; padding: .6rem .9rem; }
.nav-tabs .nav-link.active { color: var(--brand); background: transparent; border-bottom-color: var(--brand); }

/* Alerts */
.alert { border: 0; border-radius: 11px; font-size: .86rem; display: flex; gap: .6rem; align-items: flex-start; }

/* Auth */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--bg); }
.auth-visual {
  background: radial-gradient(circle at 20% 20%, rgba(124,58,237,.55), transparent 45%),
              radial-gradient(circle at 80% 70%, rgba(79,70,229,.5), transparent 40%),
              linear-gradient(160deg, #0b1220, #111827 60%, #1e1b4b);
  color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-form-wrap { display: flex; align-items: center; justify-content: center; padding: 2rem; }
.auth-card { width: 100%; max-width: 420px; }
.auth-feature { display: flex; gap: .75rem; margin-top: 1rem; color: #cbd5e1; font-size: .86rem; }
.auth-feature i { color: #a5b4fc; }

/* Error pages */
.error-page { min-height: 100vh; display: grid; place-items: center; text-align: center; padding: 2rem; }
.error-code { font-size: 5rem; font-weight: 800; line-height: 1; background: linear-gradient(135deg, var(--brand), var(--brand-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }

.min-w-0 { min-width: 0; }
.content-body { line-height: 1.9; font-size: .95rem; }
.content-body p { margin-bottom: .9rem; }
.content-body h2, .content-body h3 { font-weight: 700; margin-top: 1.35rem; margin-bottom: .6rem; }
.form-check-input { width: 1.05rem; height: 1.05rem; }

/* Responsive */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(110%); }
  [dir="rtl"] .sidebar { transform: translateX(110%); }
  .sidebar.show { transform: translateX(0); }
  .main-wrapper { margin-inline-start: 0; }
  .content { padding: 1.1rem; }
  .sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 1035;
    opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .topbar-search { max-width: none; }
}
@media (max-width: 575.98px) {
  .page-title { font-size: 1.2rem; }
  .kpi-value { font-size: 1.45rem; }
  .topbar { padding: 0 .85rem; }
  .topbar-search { display: none; }
}
