/* ==========================================================================
   Shared sheet / dialog (scripts/bc-sheet.js, bcSheetStart()/bcSheetEnd() in functions_css.php).
   Centred dialog from 600px, bottom sheet with a grip on phones. Also used by the
   training log sheet (profile_training.php / scripts/bc-training.js).
   ========================================================================== */
.bc-sheet { position: fixed; inset: 0; z-index: 100010; display: flex; align-items: center; justify-content: center; font-family: var(--bc-font); line-height: 1.4; }
.bc-sheet[hidden] { display: none; }
.bc-sheet span, .bc-sheet p { line-height: inherit; }
.bc-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 11, 16, 0.44);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.25s var(--bc-ease);
}
.bc-sheet.is-open .bc-sheet-backdrop { opacity: 1; }
.bc-sheet-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(560px, calc(100% - 32px));
  max-height: min(820px, calc(100dvh - 48px));
  border-radius: 24px;
  background: var(--bc-surface);
  color: var(--bc-ink-2);
  box-shadow: var(--bc-shadow-3), 0 0 0 1px var(--bc-line);
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  transition: opacity 0.25s var(--bc-ease), transform 0.35s var(--bc-ease);
}
.bc-sheet-panel:focus { outline: none; }
.bc-sheet.is-open .bc-sheet-panel { opacity: 1; transform: none; }
.bc-sheet--sm .bc-sheet-panel, .bc-sheet--confirm .bc-sheet-panel { width: min(420px, calc(100% - 32px)); }
.bc-sheet-grip { display: none; }
.bc-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 22px 6px; }
.bc-sheet-head h2 { margin: 0; font-size: 20px; font-weight: 700; line-height: 1.25; color: var(--bc-ink); letter-spacing: -0.02em; }
.bc-sheet-head h2:empty { visibility: hidden; }
.bc-sheet-x {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-left: auto;
  border: 0;
  border-radius: 50%;
  font-size: 16px;
  color: var(--bc-muted);
  background: var(--bc-surface-2);
  cursor: pointer;
  transition: color 0.15s var(--bc-ease), background 0.15s var(--bc-ease);
}
.bc-sheet-x:hover { color: var(--bc-ink); background: var(--bc-surface-3); }
.bc-sheet-x:focus-visible, .bc-sheet-btn:focus-visible { outline: none; box-shadow: var(--bc-ring); }
.bc-sheet-body { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; padding: 8px 22px 12px; }
/* A select with long options ("Promotion type") must not widen the sheet: iOS sizes it to its longest option */
.bc-sheet-body select, .bc-sheet-body input, .bc-sheet-body textarea { max-width: 100%; min-width: 0; }
.bc-sheet-body select { text-overflow: ellipsis; }
.bc-sheet-body > *, .bc-sheet-body form, .bc-sheet-body .bc-set-field { min-width: 0; max-width: 100%; }
.bc-sheet-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 22px calc(18px + env(safe-area-inset-bottom)); border-top: 1px solid var(--bc-line); }
.bc-sheet-error { margin: 8px 0 0; padding: 10px 12px; border-radius: 12px; font-size: 13.5px; color: #9f1239; background: rgba(225, 29, 72, 0.08); }
.bc-sheet-error[hidden] { display: none; }
.bc-sheet-ok { margin: 8px 0 0; padding: 10px 12px; border-radius: 12px; font-size: 13.5px; color: #15803d; background: rgba(22, 163, 74, 0.09); }
.bc-sheet-ok[hidden] { display: none; }
html.bc-sheet-lock, html.bc-sheet-lock body { overflow: hidden; }

/* Text + form bits inside sheets */
.bc-sheet-msg { margin: 2px 0 6px; font-size: 15px; line-height: 1.5; color: var(--bc-ink-2); white-space: pre-line; overflow-wrap: anywhere; }
.bc-sheet-lead { margin: 0 0 14px; font-size: 14px; line-height: 1.5; color: var(--bc-muted); }
.bc-sheet-label { display: block; margin: 0 0 6px; font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--bc-muted); }
.bc-sheet-field { margin: 0 0 14px; }
.bc-sheet-field .form-control, .bc-sheet-field .form-select, .bc-sheet-input {
  display: block;
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--bc-line-strong);
  border-radius: 14px;
  background: var(--bc-surface);
  color: var(--bc-ink);
  font: inherit;
  font-size: 15px;
  box-shadow: none;
  transition: border-color 0.15s var(--bc-ease), box-shadow 0.15s var(--bc-ease);
}
.bc-sheet-field .form-control:focus, .bc-sheet-field .form-select:focus, .bc-sheet-input:focus { outline: none; border-color: var(--bc-accent); box-shadow: var(--bc-ring); }
.bc-sheet-field .form-control[readonly] { background: var(--bc-surface-2); }
.bc-sheet-row { display: flex; gap: 8px; align-items: stretch; }
.bc-sheet-row > .bc-sheet-input, .bc-sheet-row > .form-control { flex: 1 1 auto; min-width: 0; }
.bc-sheet-check { display: flex; align-items: center; gap: 10px; margin: 4px 0 0; font-size: 14px; color: var(--bc-ink-2); cursor: pointer; }
.bc-sheet-check input { width: 18px; height: 18px; accent-color: var(--bc-accent); }
.bc-sheet-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; font-size: 13.5px; color: var(--bc-muted); }
.bc-sheet-links a { color: var(--bc-accent) !important; font-weight: 600; text-decoration: none; }
.bc-sheet-links a:hover { text-decoration: underline; }
.bc-sheet-divider { height: 1px; margin: 18px 0 14px; background: var(--bc-line); border: 0; }
.bc-sheet-sub { margin: 0 0 10px; font-size: 14px; font-weight: 700; color: var(--bc-ink); }

/* Buttons */
.bc-sheet-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; width: 100%; }
.bc-sheet-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 20px;
  border: 0;
  border-radius: 14px;
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none !important;
  cursor: pointer;
  transition: transform 0.15s var(--bc-ease), filter 0.15s var(--bc-ease), background 0.15s var(--bc-ease), color 0.15s var(--bc-ease);
}
.bc-sheet-btn:active { transform: scale(0.98); }
.bc-sheet-btn[disabled] { opacity: 0.55; cursor: default; }
.bc-sheet-btn--primary { color: var(--bc-on-ink) !important; background: var(--bc-ink); }
.bc-sheet-btn--primary:hover { filter: brightness(1.25); }
.bc-sheet-btn--danger { color: #fff !important; background: linear-gradient(135deg, #f43f5e, #be123c); box-shadow: 0 10px 22px -12px rgba(225, 29, 72, 0.8); }
.bc-sheet-btn--danger:hover { filter: brightness(1.05); }
.bc-sheet-btn--soft { color: var(--bc-ink) !important; background: var(--bc-surface-2); box-shadow: inset 0 0 0 1px var(--bc-line-strong); }
.bc-sheet-btn--soft:hover { background: var(--bc-surface-3); }
.bc-sheet-btn--quiet { color: var(--bc-muted) !important; background: transparent; }
.bc-sheet-btn--quiet:hover { color: var(--bc-ink) !important; background: var(--bc-surface-2); }
.bc-sheet-btn--block { width: 100%; }
.bc-sheet-btn.is-done { color: var(--bc-green) !important; box-shadow: inset 0 0 0 1.5px var(--bc-green); }
.bc-sheet--danger .bc-sheet-head h2 { color: #be123c; }

/* Likers list (newsfeed "who reacted") */
.bc-likers { list-style: none; margin: 0; padding: 0; }
.bc-likers li { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.bc-likers li + li { border-top: 1px solid var(--bc-line); }
.bc-likers-av { flex: 0 0 auto; width: 36px; height: 36px; line-height: 0; }
.bc-likers-av img, .bc-likers-av .bc-av { width: 36px !important; height: 36px !important; margin: 0 !important; border-radius: 50% !important; object-fit: cover; }
.bc-likers-name { flex: 1 1 auto; min-width: 0; font-size: 14.5px; font-weight: 600; color: var(--bc-ink) !important; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bc-likers-name:hover { text-decoration: underline; }
.bc-likers-empty { margin: 6px 0 10px; font-size: 14px; color: var(--bc-muted); }

/* Toasts */
.bc-notes { position: fixed; left: 0; right: 0; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 100100; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 16px; pointer-events: none; }
.bc-note {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: min(520px, 100%);
  padding: 12px 16px;
  border-radius: 14px;
  font-family: var(--bc-font);
  font-size: 14px;
  font-weight: 550;
  line-height: 1.4;
  color: #fff;
  background: #16161d;
  box-shadow: 0 14px 34px -12px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(10px) scale(0.98);
  transition: opacity 0.22s var(--bc-ease), transform 0.3s var(--bc-ease);
  pointer-events: auto;
}
.bc-note.is-in { opacity: 1; transform: none; }
.bc-note i { flex: 0 0 auto; font-size: 16px; }
.bc-note--error i { color: #fb7185; }
.bc-note--success i { color: #4ade80; }
.bc-note--info i { color: #7dd3fc; }
.bc-note--warning i { color: #fbbf24; }
/* Rich toast: title, text and a button (drawToast() / bcNotify({title, text, href})) */
.bc-note--rich { align-items: flex-start; gap: 12px; width: min(440px, 100%); padding: 14px 12px 14px 16px; border-radius: 18px; background: #16161d; border: 1px solid rgba(255, 255, 255, 0.08); }
.bc-note--rich > i { font-size: 20px; margin-top: 1px; }
.bc-note-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.bc-note-title { font-size: 14.5px; font-weight: 700; }
.bc-note-text { font-weight: 450; color: rgba(255, 255, 255, 0.78); font-size: 13.5px; }
.bc-note-action {
  align-self: flex-start; margin-top: 8px; padding: 7px 14px; border-radius: 999px;
  background: var(--bc-surface); color: var(--bc-ink) !important; font-weight: 650; font-size: 13.5px; text-decoration: none !important;
}
.bc-note-action:hover { background: #e9e9ef; }
.bc-note-x { flex: none; width: 30px; height: 30px; margin: -4px -2px 0 0; border: 0; border-radius: 50%; background: transparent; color: rgba(255, 255, 255, 0.6); cursor: pointer; display: grid; place-items: center; }
.bc-note-x:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
@media (max-width: 767px) {
  .bc-notes { bottom: calc(84px + env(safe-area-inset-bottom)); }
}

/* Phones: bottom sheet with a grip */
@media (max-width: 599px) {
  .bc-sheet { align-items: flex-end; }
  .bc-sheet-panel, .bc-sheet--sm .bc-sheet-panel, .bc-sheet--confirm .bc-sheet-panel { width: 100%; max-height: calc(100dvh - 24px); border-radius: 24px 24px 0 0; transform: translateY(100%); }
  .bc-sheet.is-open .bc-sheet-panel { transform: none; }
  .bc-sheet-grip { display: block; flex: 0 0 auto; width: 40px; height: 5px; margin: 8px auto 0; border-radius: 3px; background: var(--bc-line-strong); }
  .bc-sheet-head { padding: 10px 18px 4px; }
  .bc-sheet-body { padding: 8px 18px 8px; }
  .bc-sheet-foot { padding: 12px 18px calc(14px + env(safe-area-inset-bottom)); }
  .bc-sheet-actions { flex-direction: column-reverse; align-items: stretch; }
  .bc-sheet-actions .bc-sheet-btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .bc-sheet-panel, .bc-sheet-backdrop, .bc-note { transition: none !important; }
}

/* Profile photo that opens the lightbox (hero + preview sheet) */
button.bc-photo-zoom:not(:disabled) { cursor: zoom-in; }
.bc-photo-zoom { position: relative; display: inline-block; padding: 0; border: 0; background: none; line-height: 0; border-radius: 50%; cursor: zoom-in; }
.bc-photo-zoom:focus-visible { outline: none; box-shadow: var(--bc-ring); }
.bc-photo-zoom-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 22px;
  color: #fff;
  background: rgba(11, 11, 16, 0.32);
  opacity: 0;
  transition: opacity 0.2s var(--bc-ease);
  pointer-events: none;
}
@media (hover: hover) {
  .bc-photo-zoom:hover .bc-photo-zoom-hint, .bc-photo-zoom:focus-visible .bc-photo-zoom-hint { opacity: 1; }
}

/* Inline field error (e.g. passwords that don't match, fnValidatePasswords() in jsscript.php) */
.bc-field-error { margin: -6px 0 12px; padding: 8px 12px; border-radius: 10px; font-size: 13.5px; font-weight: 550; color: #9f1239; background: rgba(225, 29, 72, 0.08); }
.form-control.is-invalid, input.is-invalid { border-color: var(--bc-red) !important; }
/* Photo file missing: bcAvErr() swapped in the initials, so there is nothing to zoom into */
button.bc-photo-zoom:not(:has(img)) { cursor: default; }
.bc-photo-zoom:not(:has(img)) .bc-photo-zoom-hint { display: none; }
/* Confirm: a short question lives in the title alone */
.bc-sheet--confirm .bc-sheet-body:has(> .bc-sheet-msg[hidden]) { padding: 0 0 4px; }
.bc-sheet--confirm .bc-sheet-foot { border-top: 0; padding-top: 10px; }
.bc-sheet-foot > .bc-sheet-links { width: 100%; }

/* ==========================================================================
   Login sheet (#modalLogin in modals.php, scripts/bc-login.js)
   ========================================================================== */
.bc-login [hidden] { display: none !important; }
.bc-login .bc-login-lead { margin-bottom: 14px; }
.bc-login #loginErrorMessage { margin: 0 0 14px; }
.bc-login #bcLoginCodeError { margin: 10px 0 0; }
.bc-login-alt { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 18px; margin-top: 10px; }
.bc-login-link {
  display: inline-block;
  padding: 8px 4px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--bc-accent) !important;
  text-decoration: none;
  cursor: pointer;
}
.bc-login-link:hover { text-decoration: underline; }
.bc-login-link[disabled] { color: var(--bc-muted) !important; cursor: default; text-decoration: none; font-variant-numeric: tabular-nums; }
.bc-login-link:focus-visible { outline: none; border-radius: 8px; box-shadow: var(--bc-ring); }
.bc-login-lockout { display: grid; justify-items: center; gap: 4px; margin: 10px 0 16px; }
.bc-login-hint { margin: 10px 0 0; font-size: 13.5px; line-height: 1.45; color: var(--bc-muted); text-align: center; }
.bc-login-sent strong { color: var(--bc-ink); font-weight: 650; overflow-wrap: anywhere; }
.bc-login-warn { margin: -4px 0 14px; padding: 10px 12px; border-radius: 12px; background: rgba(245, 158, 11, 0.12); color: #92400e; font-size: 13.5px; line-height: 1.45; }
.bc-login-fallback { margin: 6px 0 0; text-align: center; font-size: 13px; }
.bc-login-fallback a { color: var(--bc-muted) !important; text-decoration: underline; }
.bc-login .bc-sheet-foot .bc-sheet-links span { color: var(--bc-muted); }

/* Password with show / hide */
.bc-pw { position: relative; }
.bc-pw .bc-sheet-input { padding-right: 52px; }
.bc-pw-toggle {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--bc-muted);
  font-size: 16px;
  cursor: pointer;
}
.bc-pw-toggle:hover { color: var(--bc-ink); background: var(--bc-surface-2); }
.bc-pw-toggle:focus-visible { outline: none; box-shadow: var(--bc-ring); }

/* 6-digit code: one real input (autofill, paste, screen readers) laid over six boxes */
.bc-otp { position: relative; margin: 0 0 4px; }
.bc-otp-input {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: transparent;
  font-size: 16px; /* no iOS zoom on focus */
  outline: none;
  cursor: text;
}
.bc-otp-input::selection { background: transparent; }
.bc-otp-boxes { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.bc-otp-boxes span {
  position: relative;
  display: grid;
  place-items: center;
  height: 58px;
  border: 1px solid var(--bc-line-strong);
  border-radius: 14px;
  background: var(--bc-surface);
  color: var(--bc-ink);
  font: 700 26px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  transition: border-color 0.15s var(--bc-ease), box-shadow 0.15s var(--bc-ease);
}
.bc-otp-boxes span:nth-child(3) { margin-right: 6px; }
.bc-otp-boxes span:nth-child(4) { margin-left: 6px; }
.bc-otp-boxes span.is-filled { border-color: var(--bc-ink-2); }
.bc-otp.is-focus .bc-otp-boxes span.is-active { border-color: var(--bc-accent); box-shadow: var(--bc-ring); }
.bc-otp.is-focus .bc-otp-boxes span.is-active:empty::after {
  content: '';
  width: 2px;
  height: 26px;
  border-radius: 1px;
  background: var(--bc-accent);
  animation: bcOtpCaret 1s steps(1) infinite;
}
.bc-otp.is-error .bc-otp-boxes span { border-color: var(--bc-red); }
@keyframes bcOtpCaret { 50% { opacity: 0; } }
@media (max-width: 380px) {
  .bc-otp-boxes { gap: 6px; }
  .bc-otp-boxes span { height: 52px; font-size: 22px; }
  .bc-otp-boxes span:nth-child(3) { margin-right: 3px; }
  .bc-otp-boxes span:nth-child(4) { margin-left: 3px; }
}
@media (prefers-reduced-motion: reduce) {
  .bc-otp.is-focus .bc-otp-boxes span.is-active:empty::after { animation: none; }
}
