/* ──────────────────────────────────────────────────────────
 * Baraka Portal — Design System v2 (2026-05-09)
 * Refined: tighter shadows, calmer borders, better hierarchy.
 * Brand palette stays — green/gold — but with broader scale.
 * ────────────────────────────────────────────────────────── */

:root {
  /* ATEN Brand — purple + gold */
  --brand-green:      #4B52C8;        /* purple (kept var name for backward compat) */
  --brand-green-dark: #3B40A0;
  --brand-green-50:   #eef0fd;
  --brand-green-100:  #d8dcf8;
  --brand-gold:       #D4A017;
  --brand-gold-light: #E5B042;
  --brand-gold-50:    #fdf6e3;
  --brand-cream:      #F5F3FF;
  --brand-brown:      #3B40A0;

  /* Surface */
  --bg:               #FAFAFC;
  --surface:          #FFFFFF;
  --surface-alt:      #F7F7FB;

  /* Borders */
  --border:           #E5E5EF;
  --border-strong:    #C7C7D6;
  --border-soft:      #F0F0F7;

  /* Ink */
  --ink:              #1A1A1A;
  --ink-2:            #555;
  --ink-3:            #888;
  --ink-4:            #AAA;

  /* Accent (status) */
  --success:          #16a34a;
  --warning:          #C8921A;
  --danger:           #DC2626;
  --info:             #2563eb;

  /* Shadows */
  --shadow-1: 0 1px 2px rgba(20, 30, 10, .04);
  --shadow-2: 0 2px 6px rgba(20, 30, 10, .06), 0 1px 2px rgba(20, 30, 10, .04);
  --shadow-3: 0 8px 24px rgba(20, 30, 10, .08), 0 2px 6px rgba(20, 30, 10, .05);
  --shadow-modal: 0 20px 60px rgba(0, 0, 0, .25);

  /* Radii */
  --r-sm: .5rem;
  --r-md: .75rem;
  --r-lg: 1rem;
  --r-xl: 1.25rem;
  --r-pill: 999px;

  /* Spacing scale (4/8/12/16/24/32/48) */
  --s-1: .25rem;
  --s-2: .5rem;
  --s-3: .75rem;
  --s-4: 1rem;
  --s-6: 1.5rem;
  --s-8: 2rem;
  --s-12: 3rem;
}

* { font-family: 'Cairo', sans-serif; box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { background: var(--bg); color: var(--ink); line-height: 1.55; }

/* ─── Typography ─── */
h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.01em; }
h3 { font-size: 1.05rem; font-weight: 700; }
.text-eyebrow { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); }
.text-mono-num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ─── Brand utilities ─── */
.bg-brand-green       { background-color: var(--brand-green); }
.bg-brand-green-dark  { background-color: var(--brand-green-dark); }
.bg-brand-gold        { background-color: var(--brand-gold); }
.bg-brand-gold-light  { background-color: var(--brand-gold-light); }
.bg-brand-cream       { background-color: var(--brand-cream); }
.bg-brand-bg          { background-color: var(--bg); }
.text-brand-green     { color: var(--brand-green); }
.text-brand-gold      { color: var(--brand-gold); }
.text-brand-brown     { color: var(--brand-brown); }
.border-brand-green   { border-color: var(--brand-green); }
.border-brand-gold    { border-color: var(--brand-gold); }

/* ─── Animations ─── */
@keyframes bp-fade-up { from { opacity:0; transform:translateY(6px);} to { opacity:1; transform:translateY(0);} }
@keyframes bp-fade-in { from { opacity:0;} to { opacity:1;} }
@keyframes bp-skeleton-pulse { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
.animate-fadeUp { animation: bp-fade-up .25s cubic-bezier(.4, 0, .2, 1) both; }
.animate-fadeIn { animation: bp-fade-in .2s ease both; }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--brand-green); }

/* ─── Card ─── */
.bp-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  box-shadow: var(--shadow-1);
  transition: border-color .15s ease, box-shadow .15s ease, transform .12s ease;
}
.bp-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.bp-card.is-clickable { cursor: pointer; }
.bp-card.is-clickable:active { transform: scale(.995); }
.bp-card.is-flat { box-shadow: none; }
.bp-card.is-strong { border-width: 2px; border-color: var(--brand-green); }

/* Stale highlight (CRM lead aging) */
.stale-amber { border-color: var(--brand-gold) !important; box-shadow: inset 4px 0 0 var(--brand-gold), var(--shadow-1); }
.stale-red   { border-color: var(--danger) !important; box-shadow: inset 4px 0 0 var(--danger), var(--shadow-1); }

/* ─── Section heading (above a card group) ─── */
.bp-section-title {
  font-size: .9rem; font-weight: 800; color: var(--brand-green);
  display: flex; align-items: center; gap: var(--s-2);
  margin-bottom: var(--s-2);
}
.bp-section-title .count { color: var(--ink-3); font-weight: 600; font-size: .75rem; }

/* ─── Buttons ─── */
.bp-btn-primary, .bp-btn-gold, .bp-btn-ghost, .bp-btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  font-weight: 700;
  border-radius: var(--r-md);
  transition: background .15s ease, border-color .15s ease, transform .1s ease, box-shadow .15s ease;
  cursor: pointer;
  user-select: none;
}
.bp-btn-primary {
  background: var(--brand-green); color: white;
  padding: .65rem 1.1rem;
  box-shadow: 0 1px 0 rgba(0,0,0,.04), inset 0 -1px 0 rgba(0,0,0,.1);
}
.bp-btn-primary:hover { background: var(--brand-green-dark); }
.bp-btn-primary:active { transform: scale(.97); }
.bp-btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.bp-btn-gold {
  background: var(--brand-gold); color: var(--brand-green-dark);
  padding: .55rem 1rem;
  box-shadow: 0 1px 0 rgba(0,0,0,.05), inset 0 -1px 0 rgba(0,0,0,.08);
}
.bp-btn-gold:hover { background: var(--brand-gold-light); }
.bp-btn-gold:active { transform: scale(.97); }

.bp-btn-ghost {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: .5rem .9rem;
}
.bp-btn-ghost:hover { border-color: var(--border-strong); background: var(--surface-alt); }
.bp-btn-ghost:active { transform: scale(.97); }

.bp-btn-danger {
  background: #fef2f2; color: var(--danger);
  border: 1px solid #fecaca;
  padding: .5rem .9rem;
}
.bp-btn-danger:hover { background: #fee2e2; border-color: #fca5a5; }

.bp-btn-sm { font-size: .75rem; padding: .4rem .75rem; }
.bp-btn-lg { font-size: 1rem; padding: .85rem 1.5rem; }

/* ─── Inputs ─── */
.bp-input, .bp-select, .bp-textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: .65rem .9rem;
  font-size: .95rem;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
  background: var(--surface);
  color: var(--ink);
}
.bp-input:focus, .bp-select:focus, .bp-textarea:focus {
  border-color: var(--brand-green);
  box-shadow: 0 0 0 3px rgba(45, 80, 22, .12);
}
.bp-input::placeholder { color: var(--ink-4); }
.bp-textarea { min-height: 5rem; resize: vertical; }

/* ─── Badges / pills ─── */
.bp-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.bp-pill-green { background: var(--brand-green-50); color: var(--brand-green); }
.bp-pill-gold  { background: var(--brand-gold-50); color: var(--brand-brown); }
.bp-pill-blue  { background: #eff6ff; color: var(--info); }
.bp-pill-red   { background: #fef2f2; color: var(--danger); }
.bp-pill-gray  { background: #f3f4f6; color: #4b5563; }
.bp-pill-purple{ background: #f5f3ff; color: #7c3aed; }
.bp-pill-amber { background: #fffbeb; color: #b45309; }

/* ─── Divider ─── */
.bp-divider { height: 1px; background: var(--border-soft); margin: var(--s-3) 0; }

/* ─── KPI tile (used on home/manager) ─── */
.bp-kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3);
  text-align: center;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.bp-kpi:hover { border-color: var(--border-strong); box-shadow: var(--shadow-1); }
.bp-kpi-value { font-size: 1.5rem; font-weight: 800; color: var(--brand-green); line-height: 1.1; font-variant-numeric: tabular-nums; }
.bp-kpi-label { font-size: 11px; color: var(--ink-3); margin-top: 4px; font-weight: 600; }

/* ─── Skeleton (loading state) ─── */
.bp-skeleton {
  display: inline-block;
  background: linear-gradient(90deg, #eee 25%, #f8f8f8 50%, #eee 75%);
  background-size: 200% 100%;
  animation: bp-skeleton-pulse 1.4s ease-in-out infinite;
  border-radius: 4px;
  color: transparent !important;
  user-select: none;
}
.bp-skeleton-text { height: .9em; width: 4ch; vertical-align: -0.1em; }
.bp-skeleton-line { height: .9em; width: 100%; display: block; margin: .25em 0; }

/* ─── Empty state ─── */
.bp-empty {
  padding: var(--s-8) var(--s-4);
  text-align: center;
  color: var(--ink-3);
}
.bp-empty-icon { font-size: 2.75rem; margin-bottom: var(--s-2); display: block; opacity: .65; }
.bp-empty-title { font-weight: 800; color: var(--ink-2); margin-bottom: 4px; }
.bp-empty-sub { font-size: .85rem; }

/* ─── Modal sheet (works on mobile + desktop) ─── */
.bp-modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, .55);
  display: flex; align-items: flex-end; justify-content: center;
  padding: var(--s-3);
  animation: bp-fade-in .15s ease both;
}
@media (min-width: 640px) {
  .bp-modal-backdrop { align-items: center; }
}
.bp-modal {
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  width: 100%;
  max-width: 32rem;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
  animation: bp-fade-up .2s cubic-bezier(.4, 0, .2, 1) both;
}
@media (min-width: 640px) {
  .bp-modal { border-radius: var(--r-xl); }
}

/* ─── Print ─── */
@media print {
  .no-print { display: none !important; }
  body { background: white !important; padding-bottom: 0 !important; }
  .bp-card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
}

/* ──────────────────────────────────────────────────────────
 *  NAVIGATION (top bar + drawer + bottom bar)
 * ────────────────────────────────────────────────────────── */

.bp-nav {
  background: var(--brand-green);
  color: white;
  padding: .7rem 1rem;
  box-shadow: 0 1px 0 rgba(0,0,0,.06);
  position: sticky; top: 0; z-index: 40;
}
.bp-nav-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
}
.bp-nav-brand { font-weight: 800; font-size: 1.05rem; color: white; letter-spacing: -0.01em; }
.bp-nav-brand .gold { color: var(--brand-gold-light); }
.bp-nav-tabs { display: flex; gap: .25rem; flex-wrap: wrap; }
.bp-nav-tab {
  padding: .4rem .8rem;
  border-radius: .5rem;
  font-size: .82rem;
  font-weight: 600;
  color: rgba(255,255,255,.85);
  white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.bp-nav-tab:hover  { background: rgba(255,255,255,.1); color: white; }
.bp-nav-tab.active { background: var(--brand-gold); color: var(--brand-green-dark); font-weight: 700; }

/* Hamburger */
.bp-hamburger {
  background: rgba(255,255,255,.12);
  color: white;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: .5rem;
  cursor: pointer;
  transition: background .15s ease;
}
.bp-hamburger:hover { background: rgba(255,255,255,.2); }
.bp-hamburger:active { transform: scale(.94); }

/* Mobile drawer */
.bp-drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 49;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.bp-drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.bp-drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 84%; max-width: 320px;
  background: var(--surface);
  z-index: 50;
  transform: translateX(100%);
  transition: transform .25s cubic-bezier(.4, 0, .2, 1);
  display: flex; flex-direction: column;
  box-shadow: -8px 0 30px rgba(0,0,0,.12);
}
.bp-drawer.open { transform: translateX(0); }

.bp-drawer-header {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.bp-drawer-close {
  position: absolute;
  top: .85rem; left: .85rem;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: #f3f4f6;
  color: #555;
  font-weight: 700; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .15s ease;
}
.bp-drawer-close:hover { background: #e5e7eb; }

.bp-drawer-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-2) 0;
  display: flex; flex-direction: column;
}
.bp-drawer-item {
  display: flex; align-items: center;
  gap: .85rem;
  padding: .85rem 1.25rem;
  font-weight: 600; font-size: .95rem;
  color: var(--ink);
  border-right: 3px solid transparent;
  transition: background .15s ease, border-color .15s ease;
  min-height: 48px;
}
.bp-drawer-item:hover { background: var(--surface-alt); }
.bp-drawer-item.active {
  background: var(--brand-cream);
  color: var(--brand-green);
  border-right-color: var(--brand-green);
  font-weight: 700;
}
.bp-drawer-icon { font-size: 1.2rem; width: 1.5rem; text-align: center; }

/* Drawer sections (grouped nav) */
.bp-drawer-section { padding: .5rem 0 .25rem; border-bottom: 1px solid var(--border); }
.bp-drawer-section:last-child { border-bottom: none; }
.bp-drawer-section-title {
  padding: .65rem 1.25rem .35rem;
  font-size: .72rem;
  font-weight: 800;
  color: var(--ink-mute, #6b7280);
  letter-spacing: .04em;
  text-transform: uppercase;
  opacity: .7;
}

/* "More" button on top bar */
.bp-nav-more {
  background: rgba(255,255,255,.18) !important;
  border: 1px dashed rgba(255,255,255,.3);
  cursor: pointer;
  font-family: inherit;
}
.bp-nav-more:hover { background: rgba(255,255,255,.28) !important; }

.bp-drawer-footer {
  padding: var(--s-3) 1.25rem;
  border-top: 1px solid var(--border);
}
.bp-drawer-signout {
  width: 100%;
  background: #fef2f2; color: #991b1b;
  font-weight: 700;
  padding: .75rem;
  border-radius: var(--r-md);
  font-size: .9rem;
  border: 1px solid #fecaca;
  transition: background .15s ease;
}
.bp-drawer-signout:hover { background: #fee2e2; }

/* Mobile bottom bar */
.bp-bottom-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(255, 255, 255, .98);
  backdrop-filter: saturate(150%) blur(12px);
  -webkit-backdrop-filter: saturate(150%) blur(12px);
  border-top: 1px solid var(--border);
  padding: .3rem .25rem;
  padding-bottom: max(.3rem, env(safe-area-inset-bottom));
  display: flex; justify-content: space-around;
  z-index: 30;
}
.bp-bottom-tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center;
  gap: 2px;
  padding: .45rem .2rem;
  font-size: .7rem;
  font-weight: 600;
  color: var(--ink-3);
  border-radius: var(--r-sm);
  min-width: 0; min-height: 56px;
  justify-content: center;
  transition: color .15s ease, background .15s ease;
}
.bp-bottom-tab:hover { background: var(--surface-alt); }
.bp-bottom-tab.active { color: var(--brand-green); background: rgba(45, 80, 22, 0.06); }
.bp-bottom-tab.active .bp-bottom-icon { transform: scale(1.15); }
.bp-bottom-icon { font-size: 1.45rem; line-height: 1; transition: transform .15s ease; }
.bp-bottom-label {
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
  font-weight: 700;
}

/* ─── Floating Action Button (FAB) ─── */
.bp-fab {
  position: fixed;
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  right: 16px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #D4A017, #B8881F);
  color: #1F3A0F;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(212, 160, 23, .4), 0 2px 6px rgba(0,0,0,.15);
  z-index: 35;
  border: none;
  cursor: pointer;
  transition: transform .2s cubic-bezier(.4, 0, .2, 1), box-shadow .2s ease;
}
.bp-fab:hover { transform: scale(1.05); box-shadow: 0 8px 20px rgba(212, 160, 23, .5); }
.bp-fab:active { transform: scale(.95); }
.bp-fab.open { transform: rotate(45deg); background: linear-gradient(135deg, #C4302B, #A02622); color: white; }
.bp-fab.open:hover { transform: rotate(45deg) scale(1.05); }

@media (min-width: 768px) {
  .bp-fab { bottom: 24px; right: 24px; }
}

.bp-fab-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
  z-index: 33;
}
.bp-fab-backdrop.open { opacity: 1; pointer-events: auto; }

.bp-fab-sheet {
  position: fixed;
  bottom: calc(140px + env(safe-area-inset-bottom, 0px));
  right: 16px;
  display: flex; flex-direction: column; gap: 12px;
  align-items: flex-end;
  z-index: 34;
  opacity: 0; pointer-events: none;
  transform: translateY(12px);
  transition: opacity .25s ease, transform .25s cubic-bezier(.4, 0, .2, 1);
}
.bp-fab-sheet.open { opacity: 1; pointer-events: auto; transform: translateY(0); }

@media (min-width: 768px) {
  .bp-fab-sheet { bottom: 92px; right: 24px; }
}

.bp-fab-action {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none;
  animation: bp-fade-up .25s ease both;
}
.bp-fab-sheet.open .bp-fab-action:nth-child(1) { animation-delay: .03s; }
.bp-fab-sheet.open .bp-fab-action:nth-child(2) { animation-delay: .06s; }
.bp-fab-sheet.open .bp-fab-action:nth-child(3) { animation-delay: .09s; }

.bp-fab-action-label {
  background: white;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: .85rem;
  color: var(--ink-1);
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  white-space: nowrap;
}
.bp-fab-action-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  color: white;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

/* Mobile-first body padding for bottom bar */
@media (max-width: 767px) {
  body { padding-bottom: 76px; }
  .bp-nav-tab  { padding: .35rem .6rem; font-size: .75rem; }
  .bp-nav-brand { font-size: 1rem; }
  .bp-btn-primary, .bp-btn-gold, .bp-btn-ghost, .bp-btn-danger { min-height: 44px; }
  .bp-input, .bp-select, .bp-textarea { min-height: 44px; font-size: 16px; /* prevents iOS zoom */ }
  h1 { font-size: 1.25rem; }
  h2 { font-size: 1.1rem; }
}

@media print {
  .bp-bottom-bar, .bp-drawer, .bp-drawer-backdrop, .bp-hamburger { display: none !important; }
}
