/* ═══════════════════════════════════════════════════════════════
   Marketing Studio — app.css
   Arabic-first, RTL, Bootstrap 5.3, Dark/Light mode
   Font: Cairo (Google Fonts)
═══════════════════════════════════════════════════════════════ */

/* ── Base ───────────────────────────────────────────────────── */
:root {
  --ms-green:      #1a8a4a;
  --ms-green-dark: #126034;
  --ms-green-light:#22c55e;
  --ms-sidebar-w:  260px;
  --ms-navbar-h:   60px;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Cairo', 'Segoe UI', Arial, sans-serif;
  direction: rtl;
  min-height: 100vh;
}

/* ── Navbar ─────────────────────────────────────────────────── */
#mainNav {
  height: var(--ms-navbar-h);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,.08);
  z-index: 1030;
}

[data-bs-theme="dark"]  #mainNav { background: rgba(18, 18, 18, .92); }
[data-bs-theme="light"] #mainNav { background: rgba(255,255,255,.95); box-shadow: 0 2px 8px rgba(0,0,0,.06); }

.navbar-brand {
  font-size: 1.1rem;
  font-weight: 700;
}

/* ── Brand icon ─────────────────────────────────────────────── */
.brand-icon {
  width: 64px; height: 64px; border-radius: 18px;
  background: linear-gradient(135deg, var(--ms-green), #16a34a);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; color: #fff;
  box-shadow: 0 4px 20px rgba(26,138,74,.4);
}

/* ── Avatar ─────────────────────────────────────────────────── */
.avatar-sm {
  width: 32px; height: 32px; font-size: .8rem; font-weight: 700;
}

/* ── Auth pages ─────────────────────────────────────────────── */
.auth-body {
  background: radial-gradient(ellipse at 60% 40%, rgba(26,138,74,.15) 0%, transparent 60%),
              radial-gradient(ellipse at 20% 80%, rgba(34,197,94,.08) 0%, transparent 50%);
}

.auth-card {
  animation: slideUp .4s ease;
  border: 1px solid rgba(255,255,255,.08);
}

@keyframes slideUp {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Stat cards ─────────────────────────────────────────────── */
.stat-card {
  border: 1px solid rgba(255,255,255,.07);
  transition: transform .2s, box-shadow .2s;
}
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}

.stat-icon {
  font-size: 1.8rem;
  margin-bottom: .5rem;
}

/* ── AI output ──────────────────────────────────────────────── */
.ai-output {
  line-height: 1.9;
  font-size: .95rem;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.07);
}

[data-bs-theme="dark"] .card  { background: #1a1a1a; }
[data-bs-theme="light"] .card { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.06); }

.card-header {
  border-bottom: 1px solid rgba(255,255,255,.07);
  font-weight: 600;
  padding: 1rem 1.25rem;
  background: transparent;
}

/* ── Tables ─────────────────────────────────────────────────── */
.table { font-size: .9rem; }
.table th { font-weight: 600; white-space: nowrap; }
.table-hover tbody tr:hover { background: rgba(26,138,74,.06); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-success {
  background: var(--ms-green);
  border-color: var(--ms-green);
}
.btn-success:hover {
  background: var(--ms-green-dark);
  border-color: var(--ms-green-dark);
}

/* ── Badges ─────────────────────────────────────────────────── */
.badge { font-weight: 600; letter-spacing: .02em; }

/* ── Form controls ──────────────────────────────────────────── */
.form-control:focus, .form-select:focus {
  border-color: var(--ms-green);
  box-shadow: 0 0 0 .2rem rgba(26,138,74,.25);
}

/* ── Nav tabs ───────────────────────────────────────────────── */
.nav-tabs .nav-link { font-weight: 500; color: inherit; }
.nav-tabs .nav-link.active {
  color: var(--ms-green-light);
  border-bottom-color: var(--ms-green-light);
  font-weight: 600;
}

/* ── Admin sidebar (for admin pages) ───────────────────────── */
.admin-layout {
  display: flex;
  min-height: calc(100vh - var(--ms-navbar-h));
}

.admin-sidebar {
  width: var(--ms-sidebar-w);
  flex-shrink: 0;
  padding: 1.5rem 1rem;
  border-left: 1px solid rgba(255,255,255,.08);
  position: sticky;
  top: var(--ms-navbar-h);
  height: calc(100vh - var(--ms-navbar-h));
  overflow-y: auto;
}

.admin-main { flex: 1; padding: 1.5rem; overflow: hidden; }

.sidebar-link {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .75rem; border-radius: 8px;
  color: inherit; text-decoration: none; font-size: .9rem;
  transition: background .15s;
}
.sidebar-link:hover, .sidebar-link.active {
  background: rgba(26,138,74,.15);
  color: var(--ms-green-light);
}
.sidebar-link i { font-size: 1.1rem; }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.25); }

/* ── Footer ─────────────────────────────────────────────────── */
.ms-footer {
  border-top: 1px solid rgba(255,255,255,.07);
  padding: 1.5rem 0;
  font-size: .85rem;
  text-align: center;
  color: #888;
  margin-top: auto;
}

/* ── Spinner overlay ────────────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .admin-sidebar { display: none; }
  .admin-layout  { flex-direction: column; }
}

/* ── Studio & Campaign Components ──────────────────────────── */
.feature-icon {
  width: 56px; height: 56px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; margin-bottom: 1rem;
}
.tool-btn {
  display: flex; align-items: center; gap: .5rem;
  padding: .4rem .75rem; border-radius: 8px; cursor: pointer;
  font-size: .82rem; color: inherit; text-decoration: none;
  transition: background .15s; border: none; background: none;
  width: 100%; text-align: right;
}
.tool-btn:hover, .tool-btn.active {
  background: rgba(26,138,74,.15); color: #22c55e;
}
.section-label {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  color: #666; padding: .5rem .75rem .25rem; letter-spacing: .05em;
}
.tool-panel { width: 100%; }
.ai-result-box {
  min-height: 120px; line-height: 1.9;
  white-space: pre-wrap; word-break: break-word;
}

/* ── Campaign Log & Progress ──────────────────────────────── */
.log-box {
  height: 200px; overflow-y: auto;
  font-family: monospace; font-size: .78rem;
  background: rgba(0,0,0,.2); padding: .75rem;
  border-radius: 8px;
}
.log-ok    { color: #22c55e; }
.log-fail  { color: #ef4444; }
.log-info  { color: #94a3b8; }
.progress-wrap {
  background: rgba(255,255,255,.06);
  border-radius: 8px; overflow: hidden;
  height: 28px; position: relative;
}
.progress-bar-inner {
  height: 100%;
  background: linear-gradient(90deg,#1a8a4a,#22c55e);
  transition: width .3s;
  display: flex; align-items: center;
  padding: 0 12px; font-size: .8rem;
  font-weight: 600; color: #fff; white-space: nowrap;
}

/* ── AI Chat ──────────────────────────────────────────────── */
.chat-msg {
  padding: .75rem 1rem; border-radius: 12px;
  max-width: 85%; margin-bottom: .75rem;
}
.chat-msg.user      { background: rgba(26,138,74,.2); margin-right: auto; }
.chat-msg.assistant { background: rgba(255,255,255,.06); margin-left: auto; }

/* ── Contacts & Referrals ─────────────────────────────────── */
.contact-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(26,138,74,.15);
  border: 1px solid rgba(26,138,74,.3);
  border-radius: 20px; padding: 2px 10px; font-size: .78rem; margin: 2px;
}
.group-item {
  border-radius: 8px; transition: background .15s; cursor: pointer;
}
.group-item:hover, .group-item.active {
  background: rgba(26,138,74,.12);
}
.invite-link-box {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 10px; padding: .75rem 1rem;
  font-family: monospace; font-size: .9rem;
  word-break: break-all; cursor: pointer;
}
.step-badge {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(26,138,74,.2);
  border: 2px solid #1a8a4a;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 1.1rem; color: #1a8a4a; flex-shrink: 0;
}
.reward-pill {
  background: rgba(255,193,7,.15);
  border: 1px solid rgba(255,193,7,.4);
  border-radius: 20px; padding: 3px 12px;
  font-size: .8rem; font-weight: 700; color: #ffc107;
}

/* ── Cursor helpers ───────────────────────────────────────── */
.cursor-pointer { cursor: pointer; }
.btn-xs { font-size: .65rem; padding: 2px 5px; }

/* ── Toast overrides ──────────────────────────────────────── */
.toast { max-width: 380px; }
