/* ===========================================================
   RichLife SPA — custom styles
   Purple theme · mobile-first · accessible touch targets
   =========================================================== */

:root {
  --brand-primary: #7c3aed;     /* violet-600 */
  --brand-accent: #a855f7;      /* purple-500 */
  --brand-bg: #faf5ff;          /* purple-50 */
  --brand-bg-soft: #f3e8ff;     /* purple-100 */
  --admin-bg: #f8fafc;          /* slate-50 */
  --merchant-bg: #ecfdf5;       /* emerald-50 */
  --danger: #dc2626;            /* red-600 */
  --success: #059669;           /* emerald-600 */
  --warning: #d97706;           /* amber-600 */
}

/* ---- Base -------------------------------------------------- */
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  overscroll-behavior-y: contain;
}
* { -webkit-tap-highlight-color: transparent; }

/* ---- App portals (background per portal) ------------------- */
.portal-rlm      { background-color: var(--brand-bg); }
.portal-admin    { background-color: var(--admin-bg); }
.portal-merchant { background-color: var(--merchant-bg); }

/* ---- Cards ------------------------------------------------- */
.card {
  background: #ffffff;
  border-radius: 1rem;
  box-shadow: 0 1px 2px rgba(124, 58, 237, 0.04), 0 1px 3px rgba(15, 23, 42, 0.05);
  border: 1px solid rgba(124, 58, 237, 0.06);
}
.card-soft { background: rgba(255,255,255,0.7); backdrop-filter: blur(8px); }

/* ---- Buttons ----------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  border-radius: 0.75rem;
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.2;
  min-height: 44px;        /* touch target */
  transition: background-color .15s, border-color .15s, transform .05s, opacity .15s;
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--brand-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #6d28d9; }

.btn-secondary { background: #fff; color: var(--brand-primary); border-color: var(--brand-accent); }
.btn-secondary:hover:not(:disabled) { background: var(--brand-bg-soft); }

.btn-ghost { background: transparent; color: var(--brand-primary); }
.btn-ghost:hover:not(:disabled) { background: var(--brand-bg-soft); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #047857; }

.btn-sm { min-height: 36px; padding: 0.375rem 0.75rem; font-size: 0.8rem; }

/* ---- Form inputs ------------------------------------------- */
.input, .select, .textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border-radius: 0.75rem;
  border: 1px solid #e2e8f0;       /* slate-200 */
  background: #fff;
  font-size: 0.95rem;
  min-height: 44px;
  transition: border-color .15s, box-shadow .15s;
  color: #0f172a;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.18);
}
.textarea { min-height: 96px; resize: vertical; }
.label { display:block; font-size:0.8rem; font-weight:600; color:#475569; margin-bottom:0.25rem; }

/* ---- Bottom navigation (mobile) ---------------------------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: #fff;
  border-top: 1px solid #ede9fe;
  display: flex; justify-content: space-around;
  padding: 0.35rem 0.25rem calc(0.35rem + env(safe-area-inset-bottom));
  z-index: 40;
}
.bottom-nav-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center;
  gap: 2px;
  padding: 0.3rem 0.25rem;
  color: #94a3b8;                /* slate-400 */
  font-size: 0.65rem; font-weight: 600;
  background: transparent; border: 0;
  min-height: 48px;
  text-decoration: none;
  transition: color .15s;
}
.bottom-nav-item svg { width: 22px; height: 22px; }
.bottom-nav-item.active { color: var(--brand-primary); }
.bottom-nav-item.active svg { transform: scale(1.08); }

/* leave room for bottom nav on mobile */
.has-bottom-nav { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }

/* ---- Sticky header ----------------------------------------- */
.app-header {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid #ede9fe;
  padding-top: env(safe-area-inset-top);
}

/* ---- Badges & pills ---------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.15rem 0.55rem; border-radius: 999px;
  font-size: 0.7rem; font-weight: 600;
}
.badge-violet { background: var(--brand-bg-soft); color: var(--brand-primary); }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-slate { background: #f1f5f9; color: #475569; }

.pill {
  padding: 0.4rem 0.85rem; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600;
  border: 1px solid #e2e8f0;
  background: #fff; color: #475569;
  cursor: pointer; white-space: nowrap;
  transition: all .15s;
}
.pill.active { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); }
.pill:hover:not(.active) { border-color: var(--brand-accent); color: var(--brand-primary); }

/* ---- Custom scrollbars for long lists ---------------------- */
.scroll-list {
  max-height: 24rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #c4b5fd transparent;
}
.scroll-list::-webkit-scrollbar { width: 6px; height: 6px; }
.scroll-list::-webkit-scrollbar-track { background: transparent; }
.scroll-list::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #c4b5fd, #a855f7);
  border-radius: 999px;
}
.scroll-list::-webkit-scrollbar-thumb:hover { background: #9333ea; }

/* ---- Loading skeleton + shimmer ---------------------------- */
.skeleton {
  background: linear-gradient(90deg, #ede9fe 25%, #f5f3ff 37%, #ede9fe 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 0.5rem;
}
@keyframes shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.skeleton-text { height: 0.75rem; margin-bottom: 0.4rem; }
.skeleton-text.lg { height: 1.25rem; }
.skeleton-text.sm { height: 0.6rem; }

/* ---- Toast ------------------------------------------------- */
.toast-container {
  position: fixed; top: max(0.75rem, env(safe-area-inset-top));
  left: 50%; transform: translateX(-50%);
  z-index: 100;
  display: flex; flex-direction: column; gap: 0.4rem;
  pointer-events: none;
  width: calc(100% - 2rem); max-width: 32rem;
}
.toast {
  pointer-events: auto;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  background: #1e293b; color: #fff;
  font-size: 0.85rem; font-weight: 500;
  box-shadow: 0 8px 24px rgba(15,23,42,0.18);
  display: flex; align-items: flex-start; gap: 0.5rem;
  animation: toast-in .25s ease-out;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--brand-primary); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Star rating ------------------------------------------- */
.star-row { display: inline-flex; gap: 0.15rem; }
.star {
  width: 28px; height: 28px;
  color: #cbd5e1; cursor: pointer;
  transition: color .1s, transform .1s;
}
.star:hover, .star.active { color: #f59e0b; }
.star.active:hover { transform: scale(1.1); }

/* ---- Empty / error states ---------------------------------- */
.empty-state {
  text-align: center; padding: 2.5rem 1rem; color: #64748b;
}
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 0.75rem; color: #c4b5fd; }

/* ---- Misc helpers ------------------------------------------ */
.gradient-brand {
  background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-accent) 100%);
}
.gradient-text {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tabular-nums { font-variant-numeric: tabular-nums; }

.fade-in { animation: fade-in .25s ease-out; }
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Desktop sidebar for admin/merchant */
.sidebar-link {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 0.85rem;
  border-radius: 0.6rem;
  color: #475569; font-weight: 600; font-size: 0.88rem;
  cursor: pointer; transition: background .15s, color .15s;
  min-height: 44px;
}
.sidebar-link:hover { background: #f1f5f9; color: var(--brand-primary); }
.sidebar-link.active { background: var(--brand-bg-soft); color: var(--brand-primary); }
.sidebar-link svg { width: 18px; height: 18px; }

/* ===========================================================
   Global SVG sizing — prevents inline icons from rendering at
   their native (often huge) viewBox size. Every container that
   renders an ICONS.* svg gets a fixed size here so we never get
   "giant svg" regressions when a new view is added.
   =========================================================== */
.btn svg        { width: 18px; height: 18px; flex-shrink: 0; }
.btn-sm svg     { width: 16px; height: 16px; flex-shrink: 0; }
.badge svg      { width: 14px; height: 14px; flex-shrink: 0; }
.pill svg       { width: 14px; height: 14px; flex-shrink: 0; }
.toast svg      { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.bottom-nav-item svg { width: 22px; height: 22px; flex-shrink: 0; }
.empty-state svg { width: 48px; height: 48px; flex-shrink: 0; }
.star svg       { width: 100%; height: 100%; }

/* Inline icon + text combos (alert banners, hint rows) — keep
   the icon and the text on the same line, vertically centered,
   and clamp the icon to 16px so it never dwarfs the text. */
.icon-text-row {
  display: flex; align-items: flex-start; gap: 0.5rem;
  line-height: 1.5;
}
.icon-text-row > svg {
  width: 16px; height: 16px; flex-shrink: 0;
  margin-top: 0.125rem;
}
.icon-text-row > span { flex: 1; min-width: 0; }

/* Circular icon badges used inside action buttons (e.g. the
   "New request" plus icon). Keeps the circle tight and aligned
   with the label text instead of pushing it down. */
.btn .icon-circle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; flex-shrink: 0;
}
.btn .icon-circle svg { width: 18px; height: 18px; }

svg { width: 1em; height: 1em; flex-shrink: 0; vertical-align: middle; }
