@import "tokens.css";
@import "portal-shell.css";
/* BohraConnect business portal — mobile-first, themed (light + dark).
   Every value below is a token from tokens.css; no colour is defined here. */
* { box-sizing: border-box; }
/* Any author-level `display` beats the UA stylesheet's [hidden] rule, so every
   flex/grid element here would ignore the hidden attribute (.media-row did).
   Assert it once, globally, instead of patching each offender. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); background: var(--bg);
  font-family: var(--sans);
  font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
h1, h2 { font-family: var(--serif); font-weight: 600; line-height: 1.2; letter-spacing: -.01em; }
a { color: var(--teal); text-decoration: none; }
.muted { color: var(--muted); }
.hint { color: var(--gold); font-size: 14px; }
img { max-width: 100%; }

/* buttons */
.btn, .btn-ghost {
  border-radius: var(--radius-sm); padding: 12px 18px; font: inherit;
  font-weight: 600; cursor: pointer; min-height: 44px; transition: background .15s, border-color .15s;
}
.btn { background: var(--teal); color: var(--on-teal); border: 0; }
.btn:hover { background: var(--teal-600); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--teal); }
.btn-ghost.sm { padding: 7px 12px; min-height: 0; font-size: 14px; }
.btn-ghost.danger { color: var(--danger); border-color: var(--danger); }
.row-end { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

/* fields */
input, textarea, select { font: inherit; color: var(--ink); }
.auth-card label, .stack label, .dlg label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 14px; }
.auth-card input, .stack input, .stack textarea,
.dlg input, .dlg select, .dlg textarea,
#composer textarea, #runAt, .composer input, .composer textarea, .composer select {
  width: 100%; margin-top: 6px; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--field); color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--teal); outline-offset: -1px; border-color: var(--teal); }
.auth-err { color: var(--danger); font-size: 14px; margin: 6px 0 0; }

/* auth (login) */
.auth-body { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.auth-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 28px; width: 100%; max-width: 380px; }
.auth-logo { height: 44px; display: block; margin: 0 auto 12px; }
.auth-card h1 { text-align: center; margin: 0 0 4px; }
.auth-sub { text-align: center; color: var(--muted); margin: 0 0 20px; font-size: 15px; }
.auth-card button { width: 100%; margin-top: 8px; }

/* server-rendered screens (pages list, composer); the chrome is portal-shell.css */
.wrap { max-width: 860px; margin: 0 auto; padding: 20px 16px calc(60px + env(safe-area-inset-bottom)); }
.back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 14px; color: var(--muted); min-height: 44px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: clamp(24px, 6vw, 32px); }

/* pages grid */
.grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.card { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); transition: transform .12s, border-color .12s; }
.card:hover { border-color: var(--teal); transform: translateY(-2px); }
.card-avatar { width: 52px; height: 52px; border-radius: 50%; overflow: hidden; background: var(--teal); color: var(--on-teal); display: grid; place-items: center; font-size: 22px; font-weight: 700; flex: none; position: relative; }
.card-avatar.lg { width: 88px; height: 88px; font-size: 36px; }
.card-avatar img { width: 100%; height: 100%; object-fit: cover; }
.card-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.card-body strong { font-size: 16px; }
.card-body .muted { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge-lapsed { color: var(--danger); font-size: 12px; font-weight: 600; }

/* empty state */
.empty { text-align: center; background: var(--card); border: 1px dashed var(--line); border-radius: 18px; padding: 44px 22px; }
.empty-emoji { font-size: 44px; }
.empty h2 { margin: 10px 0 6px; }
.empty p { color: var(--muted); max-width: 440px; margin: 0 auto 16px; }

/* page hero + stats + panels */
.page-hero { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.avatar-edit { position: absolute; bottom: 0; right: 0; background: var(--card); border: 1px solid var(--line); border-radius: 50%; width: 30px; height: 30px; display: grid; place-items: center; cursor: pointer; font-size: 14px; }
.page-hero-meta { min-width: 0; }
.page-hero-meta h1 { margin: 0 0 2px; font-size: clamp(22px, 5.5vw, 30px); }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 20px; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-align: center; }
.stats strong { display: block; font-size: 22px; }
.stats span { color: var(--muted); font-size: 12px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.panel h2 { margin: 0 0 14px; font-size: 18px; }
.stack { display: block; }

/* composer — type switcher */
.type-tabs { display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -2px 14px; padding: 2px; scrollbar-width: none; }
.type-tabs::-webkit-scrollbar { display: none; }
.type-tab { flex: none; display: inline-flex; align-items: center; gap: 6px; background: var(--raised); border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 9px 14px; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.type-tab[aria-selected="true"] { background: var(--teal); border-color: var(--teal); color: var(--on-teal); }

/* composer — rich text toolbar + editor + preview */
.rt-toolbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.rt-btn { background: var(--raised); border: 1px solid var(--line); color: var(--ink); border-radius: 8px; min-width: 40px; min-height: 40px; padding: 0 12px; font-size: 15px; font-weight: 700; cursor: pointer; }
.rt-btn:hover { border-color: var(--teal); }
.rt-wrap { position: relative; }
.rt-hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.rt-preview { margin-top: 10px; padding: 12px 14px; border: 1px dashed var(--line); border-radius: var(--radius-sm); background: var(--raised); font-size: 15px; }
.rt-preview:empty { display: none; }
.rt-preview .b { font-weight: 700; }
.rt-preview .m { color: var(--teal); font-weight: 600; }
.rt-preview .h { color: var(--gold); font-weight: 600; }
.rt-preview .bl { display: flex; gap: 6px; }
.rt-preview .bl::before { content: "•"; color: var(--muted); }
.preview-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 14px 0 4px; font-weight: 700; }

/* mention autocomplete */
.mention-pop { position: absolute; left: 0; right: 0; z-index: 30; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); overflow: hidden; margin-top: 4px; }
.mention-row { display: flex; flex-direction: column; padding: 10px 14px; cursor: pointer; border-top: 1px solid var(--line); }
.mention-row:first-child { border-top: 0; }
.mention-row:hover, .mention-row.active { background: var(--teal-tint); }
.mention-row b { font-size: 15px; }
.mention-row span { font-size: 13px; color: var(--muted); }

/* life-event fields + occasion chips */
.life-fields { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; margin: 4px 0 12px; background: var(--raised); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.chip { background: var(--card); border: 1px solid var(--line); color: var(--ink); border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 600; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--teal); border-color: var(--teal); color: var(--on-teal); }

/* media thumbs */
.media-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.file-btn { display: inline-flex; align-items: center; gap: 6px; }
.file-btn input { display: none; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumb { width: 58px; height: 58px; border-radius: 10px; background: var(--raised); display: grid; place-items: center; font-size: 22px; border: 1px solid var(--line); position: relative; }
.thumb.loading { opacity: .6; font-size: 13px; font-weight: 700; color: var(--muted); }
.thumb .x { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; background: var(--danger); color: #fff; border: 0; font-size: 12px; line-height: 1; cursor: pointer; display: grid; place-items: center; }

/* composer actions */
.composer-actions { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.sched-block { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sched-when { font-size: 13px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 8px; margin-bottom: 0 !important; }
.sched-when input { width: auto; margin-top: 0; }
.run-echo { font-size: 12px; font-weight: 600; min-height: 16px; }
.run-echo.ok { color: var(--ok); }
.run-echo.bad { color: var(--danger); }

/* queue + published list */
.queue, .ranklist { list-style: none; margin: 0; padding: 0; }
/* wrap so the inline reschedule editor (width:100%) drops onto its own line
   instead of squeezing the caption into a narrow column beside it */
.queue-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--line); }
.queue-main { flex: 1 1 220px; }
.queue-item:first-child { border-top: 0; }
.queue-main { min-width: 0; }
.q-cap { display: block; font-weight: 500; }
.q-meta { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.q-err { color: var(--danger); font-style: normal; }
.queue-act { display: flex; gap: 8px; flex: none; }
.pill { font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 2px 8px; border-radius: 20px; letter-spacing: .03em; }
.pill-pending { background: var(--gold-bg); color: var(--gold); }
.pill-published { background: var(--ok-bg); color: var(--ok); }
.pill-failed { background: var(--danger-bg); color: var(--danger); }
.pill-canceled { background: var(--raised); color: var(--muted); }
.kind-tag { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--teal); background: var(--teal-tint); padding: 2px 7px; border-radius: 6px; }

/* panel heading count badge */
.panel h2 .count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; margin-left: 6px; border-radius: 11px; background: var(--teal-tint); color: var(--teal); font-size: 12px; font-family: system-ui, sans-serif; vertical-align: 2px; }

/* inline reschedule (replaces the old prompt()) */
.reschedule-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; width: 100%; padding: 10px 0 2px; }
.reschedule-row .resched-input { width: auto; flex: 1 1 200px; margin: 0; padding: 9px 12px; border: 1px solid var(--teal); border-radius: var(--radius-sm); background: var(--field); color: var(--ink); }
.btn.sm { padding: 7px 14px; min-height: 0; font-size: 14px; }
.q-rel { color: var(--muted); }
.q-when { font-weight: 600; color: var(--ink); }

/* icon button (row-level destructive action) */
.icon-btn { flex: none; width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-size: 15px; line-height: 1; display: grid; place-items: center; }
.icon-btn:hover { border-color: var(--danger); background: var(--danger-bg); }
.icon-btn:disabled { opacity: .5; cursor: default; }

/* danger zone */
.danger-zone { border-color: var(--danger); }
.danger-zone h2 { color: var(--danger); }

/* avatar busy state */
.card-avatar.busy { opacity: .5; }
.card-avatar.busy::after { content: "…"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 24px; color: #fff; }

/* toast */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 60; max-width: min(460px, calc(100vw - 32px)); padding: 12px 18px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 600; text-align: center; }
.toast.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok); }
.toast.warn { background: var(--gold-bg); color: var(--gold); border: 1px solid var(--gold); }
.toast.bad { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); }

/* rank list */
.rank-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.rank-item:first-child { border-top: 0; }
.rank-thumb { width: 46px; height: 46px; border-radius: 8px; object-fit: cover; background: var(--raised); flex: none; display: grid; place-items: center; color: var(--muted); }
.rank-cap { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-input { width: 64px; text-align: center; margin: 0 !important; flex: none; padding: 9px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); color: var(--ink); }
.rank-input:focus { outline: 2px solid var(--teal); outline-offset: -1px; }

/* dialog */
.dlg { border: 0; border-radius: 18px; box-shadow: var(--shadow-lg); padding: 22px; width: min(440px, 94vw); background: var(--card); color: var(--ink); }
.dlg::backdrop { background: rgba(10,15,27,.55); backdrop-filter: blur(2px); }
.dlg h2 { margin: 0 0 4px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.field-note { font-weight: 600; font-size: 13px; }
.field-note.ok { color: var(--ok); }
.field-note.bad { color: var(--danger); }

/* ≥640px: multi-column grid + 4-up stats + roomier padding */
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .wrap { padding: 24px 20px 60px; }
  .panel { padding: 20px; }
}
@media (max-width: 480px) {
  .page-hero { flex-direction: column; text-align: center; }
  .composer-actions .row-end { width: 100%; }
  .composer-actions .row-end .btn { flex: 1; }
}
