/* ============================================================
   NeoonReiv Live Chat — Widget (NEON theme)
   Re-skinned from the Sauna theme to match raadio.r12.ee.
   Styles every element the widget.js generates.
   ============================================================ */

#livechat-widget {
  /* Neon palette (matches the radio player) */
  --n1: #ff1e8c;   /* magenta */
  --n2: #00e5ff;   /* cyan    */
  --n3: #b026ff;   /* violet  */
  --bg:    #0d0d18;
  --bg2:   #06060a;
  --panel: rgba(255,255,255,.05);
  --brd:   rgba(255,255,255,.09);
  --text:  #f6f6fb;
  --dim:   #a0a0b4;
  --faint: #62627a;

  position: fixed;
  /* Anchor point for the chat window. The launcher bubble is hidden;
     the radio "Vestlus" button opens the window via window.openLiveChat().
     !important overrides the inline left/right style the widget JS injects. */
  left: 20px !important;
  bottom: calc(150px + env(safe-area-inset-bottom)) !important;
  right: auto !important;
  top: auto !important;
  z-index: 100020;
  font-family: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
#livechat-widget * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Hide all Sauna decorations */
.cta-pour-scene,
.bubble-steam,
.header-steam,
.steam-man { display: none !important; }

/* ── Floating launcher bubble: hidden — chat opens from the radio "Vestlus" button ── */
#livechat-bubble { display: none !important; }

#unread-badge {
  position: absolute;
  top: -3px; right: -3px;
  min-width: 21px; height: 21px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--n2);
  color: #05050a;
  font-size: 11px; font-weight: 900; line-height: 21px;
  text-align: center;
  box-shadow: 0 0 10px rgba(0,229,255,.6);
}

/* ── Greeting bubble (the little CTA that pops up to the right of the launcher) ── */
.sauna-greeting {
  position: absolute;
  bottom: 50%;
  left: 74px;
  transform: translateY(50%);
  display: flex; align-items: center; gap: 8px;
  background: var(--bg);
  border: 1px solid var(--brd);
  border-radius: 16px;
  padding: 11px 14px;
  white-space: nowrap;
  color: var(--text);
  font-size: 14px; font-weight: 600;
  box-shadow: 0 14px 40px rgba(0,0,0,.5), 0 0 20px rgba(176,38,255,.25);
  cursor: pointer;
  animation: nrc-pop .3s ease;
}
.sauna-greeting.hiding { opacity: 0; transition: opacity .3s ease; }
.greeting-close {
  border: none; background: none; color: var(--faint);
  font-size: 18px; line-height: 1; cursor: pointer; padding: 0 0 0 4px;
}
@keyframes nrc-pop { from { opacity: 0; transform: translateY(50%) scale(.85); } to { opacity: 1; transform: translateY(50%) scale(1); } }

/* ── Chat window — opens upward from the bottom-left launcher ── */
#livechat-window {
  position: absolute;
  bottom: 76px;
  left: 0;
  width: min(384px, calc(100vw - 32px));
  height: min(620px, calc(100dvh - 200px));
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--brd);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(0,0,0,.7), 0 0 0 1px rgba(0,229,255,.05);
  animation: nrc-slide-up .32s cubic-bezier(.32,.72,0,1);
}
#livechat-window::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--n2), var(--n3), var(--n1));
  z-index: 5;
}
@keyframes nrc-slide-up { from { opacity: 0; transform: translateY(20px) scale(.98); } to { opacity: 1; transform: none; } }

/* ── Header ── */
#livechat-header {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  background: linear-gradient(135deg, rgba(255,30,140,.12), rgba(176,38,255,.06), transparent);
  flex: none;
}
.header-content { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.header-avatars { flex: none; }
.avatar-circle {
  width: 40px; height: 40px; border-radius: 13px;
  display: grid; place-items: center;
  font-family: "Unbounded", sans-serif; font-weight: 900; font-size: 13px; color: #fff;
  background: linear-gradient(135deg, var(--n2), var(--n3));
  box-shadow: 0 0 16px rgba(0,229,255,.4);
}
.header-text { display: flex; flex-direction: column; min-width: 0; }
.header-title  { font-size: 15px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-status { font-size: 11.5px; color: var(--dim); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#livechat-close {
  width: 34px; height: 34px; flex: none;
  border-radius: 10px;
  border: 1px solid var(--brd);
  background: var(--panel);
  color: var(--text);
  font-size: 22px; line-height: 1;
  cursor: pointer;
  display: grid; place-items: center;
  transition: background .15s;
}
#livechat-close:hover { background: rgba(255,255,255,.1); }

/* ── Body ── */
#livechat-body {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}

/* Pre-chat */
#livechat-prechat {
  padding: 22px 18px;
  display: flex; flex-direction: column; gap: 12px;
  overflow-y: auto;
}
.prechat-welcome { font-size: 15px; line-height: 1.5; color: var(--text); margin-bottom: 4px; }
.prechat-input {
  width: 100%;
  border: 1px solid var(--brd);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
  transition: border-color .15s;
}
.prechat-input:focus { border-color: rgba(0,229,255,.45); }
.prechat-input::placeholder { color: var(--faint); }
.prechat-feedback { color: var(--n1); font-size: 13px; }
#start-chat-btn {
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--n1), var(--n3));
  color: #fff;
  padding: 14px;
  font-size: 15px; font-weight: 800;
  cursor: pointer;
  box-shadow: 0 0 22px rgba(255,30,140,.4);
  transition: transform .15s, box-shadow .2s;
}
#start-chat-btn:hover  { box-shadow: 0 0 32px rgba(255,30,140,.6); }
#start-chat-btn:active { transform: scale(.97); }
#start-chat-btn:disabled { opacity: .6; cursor: default; }

/* Chat view */
#livechat-chat {
  flex: 1; min-height: 0;
  flex-direction: column;
  overflow: hidden;
}
#livechat-messages {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  scrollbar-width: thin; scrollbar-color: #23232e transparent;
}
#livechat-messages::-webkit-scrollbar { width: 4px; }
#livechat-messages::-webkit-scrollbar-thumb { background: #23232e; border-radius: 4px; }

/* ── Messages ── */
.message {
  display: flex; align-items: flex-end; gap: 8px;
  max-width: 86%;
}
.message-visitor { align-self: flex-end; flex-direction: row-reverse; }
.message-host,
.message-system { align-self: flex-start; }

.message-avatar {
  width: 30px; height: 30px; flex: none;
  border-radius: 9px;
  display: grid; place-items: center;
  font-family: "Unbounded", sans-serif; font-weight: 900; font-size: 10px; color: #fff;
  background: linear-gradient(135deg, var(--n2), var(--n3));
}
.message-bubble {
  border-radius: 18px;
  padding: 11px 14px;
  font-size: 14px; line-height: 1.45;
  overflow-wrap: anywhere;
}
.message-visitor .message-bubble {
  border-bottom-right-radius: 5px;
  background: linear-gradient(135deg, var(--n1), var(--n3));
  color: #fff;
  box-shadow: 0 0 16px rgba(255,30,140,.25);
}
.message-host .message-bubble {
  border-bottom-left-radius: 5px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.09);
  color: var(--text);
}
.message-system .message-bubble {
  background: rgba(0,229,255,.08);
  border: 1px solid rgba(0,229,255,.16);
  color: var(--dim);
  font-size: 13px;
  border-radius: 14px;
}
.sender-name { font-size: 11px; font-weight: 700; color: var(--n2); margin-bottom: 3px; }
.message-content { white-space: pre-wrap; }
.message-time { font-size: 9.5px; color: var(--faint); margin-top: 4px; text-align: right; }
.message-host .message-time { text-align: left; }

.message-image-wrap { display: block; }
.message-image {
  display: block;
  width: min(220px, 60vw);
  max-height: 260px;
  object-fit: cover;
  border-radius: 12px;
}
.message-caption { margin-top: 6px; }

/* Inline quick actions (camera / send image under welcome) */
.message-inline-actions { align-self: flex-start; max-width: 100%; }
.inline-quick-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.quick-action-btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--brd);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  padding: 8px 13px;
  font-size: 12.5px; font-weight: 700;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.quick-action-btn:hover { border-color: rgba(0,229,255,.4); background: rgba(0,229,255,.06); }
.quick-action-ico { display: grid; place-items: center; color: var(--n2); }

/* Typing indicator */
#livechat-typing {
  display: none;
  align-items: center; gap: 8px;
  padding: 0 16px 10px;
  font-size: 12px; color: var(--dim);
}
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--n2);
  animation: nrc-typing 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes nrc-typing { 0%,60%,100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* Closed view */
#livechat-closed {
  display: none;
  flex: 1; align-items: center; justify-content: center;
  padding: 24px;
}
.closed-message { text-align: center; }
.closed-message p { color: var(--dim); font-size: 14px; margin: 0 0 16px; }
#new-chat-btn {
  border: none; border-radius: 14px;
  background: linear-gradient(135deg, var(--n1), var(--n3));
  color: #fff; padding: 12px 22px;
  font-size: 14px; font-weight: 800; cursor: pointer;
  box-shadow: 0 0 22px rgba(255,30,140,.4);
}

/* ── Input bar ── */
#livechat-input {
  flex: none;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255,255,255,.07);
  background: var(--bg);
}
.input-container {
  display: flex; align-items: flex-end; gap: 7px;
}
#livechat-camera,
#livechat-attach {
  width: 40px; height: 40px; flex: none;
  border: 1px solid var(--brd);
  border-radius: 12px;
  background: var(--panel);
  color: var(--dim);
  display: grid; place-items: center;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
#livechat-camera:hover,
#livechat-attach:hover { color: var(--n2); border-color: rgba(0,229,255,.4); background: rgba(0,229,255,.05); }
#livechat-text {
  flex: 1; resize: none;
  border: 1px solid var(--brd);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  padding: 10px 14px;
  font-size: 16px; /* 16px prevents iOS zoom */
  line-height: 1.4;
  max-height: 100px;
  outline: none;
  transition: border-color .15s;
}
#livechat-text:focus { border-color: rgba(0,229,255,.4); }
#livechat-text::placeholder { color: var(--faint); }
#livechat-send {
  width: 44px; height: 44px; flex: none;
  border: none; border-radius: 13px;
  background: linear-gradient(135deg, var(--n2), var(--n3));
  color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(0,229,255,.4);
  transition: transform .15s, box-shadow .2s;
}
#livechat-send:hover  { box-shadow: 0 0 24px rgba(0,229,255,.6); }
#livechat-send:active { transform: scale(.92); }

/* ============================================================
   MOBILE — fullscreen window + keyboard-aware input
   ============================================================ */
@media (max-width: 768px) {
  #livechat-widget {
    left: 14px;
    bottom: calc(128px + env(safe-area-inset-bottom));
    right: auto;
    top: auto;
  }

  /* Fullscreen flex column. Height follows the visual viewport (set by JS as
     --livechat-vh) so the input bar stays visible when the keyboard opens. */
  #livechat-window {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: auto;
    width: 100%;
    height: var(--livechat-vh, 100dvh);
    transform: translateY(var(--livechat-vtop, 0px));
    border-radius: 0;
    animation: none;
  }

  /* Header and input stay put; only the message list scrolls. */
  #livechat-header { flex: none; }
  #livechat-body   { flex: 1 1 auto; min-height: 0; }

  /* Input is a normal in-flow flex child pinned at the bottom of the window. */
  #livechat-input {
    flex: none;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: var(--bg);
    border-top: 1px solid rgba(255,255,255,.08);
  }

  #livechat-text { font-size: 16px; }

  .sauna-greeting { display: none !important; }
}

/* ── Wedding mode ───────────────────────────────────────────────────────
   The radio player puts this class on <body>.  The chat widget lives outside
   the radio markup, so it needs its own palette rather than inheriting the
   player CSS variables. */
body.nr-wedding-mode #livechat-widget {
  --n1: #a7644e;
  --n2: #71815f;
  --n3: #c4a16c;
  --bg: #fbf8f2;
  --bg2: #f5f0e8;
  --panel: rgba(255, 253, 248, .82);
  --brd: rgba(91, 105, 79, .22);
  --text: #33402f;
  --dim: #66725d;
  --faint: #8a927e;
  font-family: Georgia, "Times New Roman", serif;
}
body.nr-wedding-mode #livechat-window {
  background: var(--bg);
  border-color: var(--brd);
  box-shadow: 0 24px 70px rgba(82, 75, 58, .22), 0 0 0 1px rgba(113, 129, 95, .08);
}
body.nr-wedding-mode #livechat-window::before {
  background: linear-gradient(90deg, #71815f, #c4a16c, #a7644e);
}
body.nr-wedding-mode #livechat-header {
  border-bottom-color: rgba(91, 105, 79, .16);
  background: linear-gradient(135deg, rgba(113, 129, 95, .16), rgba(196, 161, 108, .13), transparent);
}
body.nr-wedding-mode #livechat-input {
  background: var(--bg);
  border-top-color: rgba(91, 105, 79, .16);
}
body.nr-wedding-mode .avatar-circle,
body.nr-wedding-mode .message-avatar,
body.nr-wedding-mode #livechat-send,
body.nr-wedding-mode #start-chat-btn,
body.nr-wedding-mode #new-chat-btn {
  background: linear-gradient(135deg, #71815f, #9a7459);
  box-shadow: 0 10px 22px rgba(82, 75, 58, .18);
}
body.nr-wedding-mode #livechat-close,
body.nr-wedding-mode .prechat-input,
body.nr-wedding-mode .quick-action-btn,
body.nr-wedding-mode #livechat-camera,
body.nr-wedding-mode #livechat-attach,
body.nr-wedding-mode #livechat-text {
  background: #fffdf8;
  border-color: rgba(91, 105, 79, .22);
  color: var(--text);
}
body.nr-wedding-mode #livechat-close:hover,
body.nr-wedding-mode .quick-action-btn:hover,
body.nr-wedding-mode #livechat-camera:hover,
body.nr-wedding-mode #livechat-attach:hover {
  background: rgba(113, 129, 95, .10);
  border-color: rgba(113, 129, 95, .45);
  color: #5f704f;
}
body.nr-wedding-mode .prechat-input:focus,
body.nr-wedding-mode #livechat-text:focus {
  border-color: rgba(113, 129, 95, .62);
}
body.nr-wedding-mode .message-visitor .message-bubble {
  background: linear-gradient(135deg, #71815f, #9a7459);
  box-shadow: 0 8px 18px rgba(82, 75, 58, .18);
}
body.nr-wedding-mode .message-host .message-bubble {
  background: #fffdf8;
  border-color: rgba(91, 105, 79, .18);
  color: var(--text);
}
body.nr-wedding-mode .message-system .message-bubble {
  background: rgba(113, 129, 95, .09);
  border-color: rgba(113, 129, 95, .18);
  color: var(--dim);
}
body.nr-wedding-mode .sender-name,
body.nr-wedding-mode .quick-action-ico,
body.nr-wedding-mode .typing-dots span { color: #71815f; }
body.nr-wedding-mode .typing-dots span { background: #71815f; }
body.nr-wedding-mode #livechat-messages { scrollbar-color: #b9c3af transparent; }
body.nr-wedding-mode #livechat-messages::-webkit-scrollbar-thumb { background: #b9c3af; }
