/* ────────────────────────────────────────────────────────────────────
   Live chat widget — kookjang24
   Brand accent: #77EEBB
   Mounted into any Flask page via `chat-widget.js`.
   Everything is scoped under .k24-chat to avoid colliding with predictions.css
   ──────────────────────────────────────────────────────────────────── */

:root {
  --k24-accent: #77EEBB;
  --k24-accent-dim: rgba(119, 238, 187, 0.2);
  --k24-bg: #0f1115;
  --k24-bg-2: #171a20;
  --k24-bg-3: #1f242c;
  --k24-fg: #e6e8eb;
  --k24-fg-dim: #9aa4b2;
  --k24-border: #2a303a;
  --k24-danger: #ff6b6b;
}

/* ── floating launcher button ───────────────────────────────────────── */
.k24-chat-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9998;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--k24-accent);
  color: #0b0d10;
  border: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  font-size: 22px;
  display: grid;
  place-items: center;
  transition: transform 0.15s ease;
}
.k24-chat-launcher:hover { transform: translateY(-2px); }
/* When the mobile bottom-nav hosts the chat entry point, drop the
   floating bubble so there's only one clear launcher on screen. */
.k24-chat-launcher--nav-hosted { display: none; }
.k24-chat-launcher[data-online]::after {
  content: attr(data-online);
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 22px;
  padding: 2px 6px;
  border-radius: 11px;
  background: #0b0d10;
  color: var(--k24-accent);
  font-size: 11px;
  font-weight: 700;
  border: 1.5px solid var(--k24-accent);
}

/* ── drawer ─────────────────────────────────────────────────────────── */
.k24-chat-drawer {
  position: fixed;
  right: 20px;
  bottom: 90px;
  z-index: 9999;
  width: min(380px, calc(100vw - 40px));
  height: min(560px, calc(100vh - 120px));
  background: var(--k24-bg);
  color: var(--k24-fg);
  border: 1px solid var(--k24-border);
  border-radius: 14px;
  display: none;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", sans-serif;
}
.k24-chat-drawer[data-open="true"] { display: flex; }

/* Mobile layout: fullscreen drawer that sits above the bottom-nav.
   The nav stays visible so the user can see "채팅" lit up (is-active)
   and tap it again to close. Breakpoint matches the nav's own
   max-width: 1024px so tablets get the same sheet. */
@media (max-width: 1024px) {
  .k24-chat-drawer {
    top: 0;
    left: 0;
    right: 0;
    bottom: calc(var(--mobile-nav-h, 60px) + env(safe-area-inset-bottom));
    width: auto;
    height: auto;
    max-height: none;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
  }
}

.k24-chat-header {
  padding: 12px 14px;
  background: var(--k24-bg-2);
  border-bottom: 1px solid var(--k24-border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.k24-chat-title {
  font-weight: 700;
  font-size: 14px;
  flex: 1;
}
.k24-chat-presence {
  font-size: 12px;
  color: var(--k24-fg-dim);
}
.k24-chat-presence::before {
  content: "●";
  color: var(--k24-accent);
  margin-right: 4px;
}
.k24-chat-close {
  background: none;
  border: none;
  color: var(--k24-fg-dim);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

/* banner — visible on first open, dismissable */
.k24-chat-banner {
  padding: 10px 14px;
  background: var(--k24-accent-dim);
  border-bottom: 1px solid var(--k24-border);
  font-size: 12px;
  color: var(--k24-fg);
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.k24-chat-banner strong { color: var(--k24-accent); }
.k24-chat-banner-dismiss {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--k24-fg-dim);
  cursor: pointer;
  font-size: 14px;
}

/* ── message list ───────────────────────────────────────────────────── */
.k24-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.k24-msg {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--k24-bg-2);
  border: 1px solid transparent;
}
.k24-msg.k24-msg-mine {
  background: var(--k24-accent-dim);
  border-color: var(--k24-accent);
}
.k24-msg-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 11px;
  color: var(--k24-fg-dim);
}
.k24-msg-nick { color: var(--k24-fg); font-weight: 600; }
.k24-msg-content {
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}
.k24-msg.k24-msg-deleted .k24-msg-content {
  color: var(--k24-fg-dim);
  font-style: italic;
}
.k24-msg-actions {
  display: flex;
  gap: 8px;
  margin-top: 2px;
  opacity: 0;
  transition: opacity 0.1s ease;
}
.k24-msg:hover .k24-msg-actions { opacity: 1; }
.k24-msg-actions button {
  background: none;
  border: none;
  color: var(--k24-fg-dim);
  cursor: pointer;
  font-size: 11px;
  padding: 0;
}
.k24-msg-actions button:hover { color: var(--k24-danger); }

.k24-chat-system {
  font-size: 11px;
  color: var(--k24-fg-dim);
  text-align: center;
  padding: 4px 0;
}

/* ── composer ───────────────────────────────────────────────────────── */
.k24-chat-composer {
  border-top: 1px solid var(--k24-border);
  padding: 10px;
  display: flex;
  gap: 8px;
  background: var(--k24-bg-2);
}
.k24-chat-input {
  flex: 1;
  resize: none;
  max-height: 80px;
  min-height: 36px;
  padding: 8px 10px;
  background: var(--k24-bg);
  color: var(--k24-fg);
  border: 1px solid var(--k24-border);
  border-radius: 8px;
  /* iOS Safari auto-zooms on focus when a form control's computed
     font-size is below 16px. Keep it exactly 16px everywhere — the
     visual difference on desktop is negligible and this eliminates
     the jarring viewport zoom on iPhones/iPads. */
  font-size: 16px;
  font-family: inherit;
}
.k24-chat-input:focus {
  outline: none;
  border-color: var(--k24-accent);
}
.k24-chat-send {
  background: var(--k24-accent);
  color: #0b0d10;
  border: none;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
}
.k24-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── nickname modal ─────────────────────────────────────────────────── */
.k24-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
}
.k24-modal-backdrop[data-open="true"] { display: flex; }

.k24-modal {
  background: var(--k24-bg);
  border: 1px solid var(--k24-border);
  border-radius: 14px;
  padding: 22px;
  width: min(340px, calc(100vw - 40px));
  color: var(--k24-fg);
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", sans-serif;
}
.k24-modal h2 {
  margin: 0 0 8px;
  font-size: 16px;
}
.k24-modal p {
  margin: 0 0 14px;
  font-size: 12px;
  color: var(--k24-fg-dim);
  line-height: 1.5;
}
.k24-modal input {
  width: 100%;
  padding: 10px 12px;
  background: var(--k24-bg-2);
  color: var(--k24-fg);
  border: 1px solid var(--k24-border);
  border-radius: 8px;
  /* 16px — see .k24-chat-input comment about iOS auto-zoom. */
  font-size: 16px;
  box-sizing: border-box;
}
.k24-modal input:focus {
  outline: none;
  border-color: var(--k24-accent);
}
.k24-modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.k24-modal button {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
}
.k24-modal-primary {
  background: var(--k24-accent);
  color: #0b0d10;
}
.k24-modal-secondary {
  background: var(--k24-bg-3);
  color: var(--k24-fg);
}
.k24-modal-error {
  margin-top: 10px;
  font-size: 12px;
  color: var(--k24-danger);
  min-height: 16px;
}

