/* === CHAT WIDGET — Feder und Tinte === */

/* Base reset: prevent page CSS leaking in */
.chat-bubble,
.chat-panel,
.chat-panel *,
.chat-profile-dialog,
.chat-profile-dialog * {
  box-sizing: border-box;
  font-family: Inter, system-ui, sans-serif;
}
/* Restore [hidden] which all:unset breaks */
.chat-panel [hidden] { display: none !important; }

/* ── Floating button ── */
.chat-bubble {
  all: unset;
  box-sizing: border-box;
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 54px;
  height: 54px;
  border-radius: 999px;
  background: linear-gradient(135deg, #4b1f38, #2a1622);
  border: 1px solid rgba(244,207,134,.50);
  box-shadow: 0 8px 28px rgba(0,0,0,.55), 0 0 0 1px rgba(244,207,134,.16) inset, 0 0 22px rgba(185,138,255,.22);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff7ef;
  transition: transform .2s ease, box-shadow .25s ease;
  z-index: 900;
}
.chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 36px rgba(0,0,0,.65), 0 0 0 1px rgba(244,207,134,.32) inset, 0 0 32px rgba(185,138,255,.32);
}
.chat-unread {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f4cf86;
  border: 2px solid #07060d;
  display: none;
}
.chat-unread.visible { display: block; }

/* ── Panel ── */
.chat-panel {
  position: fixed;
  bottom: 88px;
  right: 24px;
  width: min(400px, calc(100vw - 32px));
  max-height: min(580px, calc(100dvh - 112px));
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(36,16,28,.98) 0%, rgba(12,9,20,.99) 100%);
  border: 1px solid rgba(244,207,134,.22);
  box-shadow: 0 28px 70px rgba(0,0,0,.70), 0 0 0 1px rgba(171,46,95,.10) inset;
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  z-index: 899;
  transform: translateY(18px) scale(.96);
  opacity: 0;
  pointer-events: none;
  transition: transform .24s cubic-bezier(.34,1.56,.64,1), opacity .18s ease;
}
.chat-panel.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ── */
.chat-panel .chat-header {
  padding: 13px 16px;
  border-bottom: 1px solid rgba(244,207,134,.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: linear-gradient(90deg, rgba(75,31,56,.28), rgba(42,16,34,.18));
  border-radius: 20px 20px 0 0;
}
.chat-panel .chat-header-title {
  flex: 1;
  font-weight: 700;
  font-size: 14px;
  color: #fff3e0;
  letter-spacing: .02em;
}
.chat-panel .chat-header-sub {
  font-size: 10px;
  color: #9a8fad;
  letter-spacing: .04em;
  margin-top: 2px;
}
.chat-panel .chat-close {
  all: unset;
  box-sizing: border-box;
  color: #9a8fad;
  cursor: pointer;
  font-size: 17px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: color .15s ease, background .15s ease;
}
.chat-panel .chat-close:hover {
  color: #f4cf86;
  background: rgba(244,207,134,.1);
}

/* ── Tabs ── */
.chat-panel .chat-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(244,207,134,.10);
}
.chat-panel .chat-tab {
  all: unset;
  box-sizing: border-box;
  border: 1px solid rgba(244,207,134,.14);
  background: rgba(255,255,255,.04);
  color: #b0a3c2;
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all .18s ease;
  letter-spacing: .01em;
}
.chat-panel .chat-tab:hover {
  border-color: rgba(244,207,134,.28);
  color: #e8daf5;
  background: rgba(255,255,255,.07);
}
.chat-panel .chat-tab.is-active {
  background: linear-gradient(135deg, #4b1f38, #2e1225);
  border-color: rgba(244,207,134,.38);
  color: #ffe8b8;
  box-shadow: 0 0 0 1px rgba(244,207,134,.10) inset, 0 4px 14px rgba(0,0,0,.35);
}

/* ── Nick bar ── */
.chat-panel .chat-nick-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(244,207,134,.08);
}
.chat-panel .chat-nick-label {
  font-size: 11px;
  color: #8f83a8;
  white-space: nowrap;
  letter-spacing: .04em;
  flex-shrink: 0;
}
.chat-panel .chat-nick-input {
  all: unset;
  box-sizing: border-box;
  flex: 1;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(244,207,134,.16);
  border-radius: 9px;
  padding: 6px 11px;
  font-size: 13px;
  color: #f0e8ff;
  transition: border-color .2s ease, background .2s ease;
}
.chat-panel .chat-nick-input::placeholder { color: rgba(255,255,255,.25); }
.chat-panel .chat-nick-input:focus {
  border-color: rgba(244,207,134,.42);
  background: rgba(255,255,255,.08);
}

/* ── Verified status box ── */
.chat-panel .chat-status { padding: 10px 12px; border-bottom: 1px solid rgba(244,207,134,.08); }
.chat-status-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(75,31,56,.32), rgba(42,16,34,.24));
  border: 1px solid rgba(244,207,134,.14);
}
.chat-status-box strong { font-size: 12px; color: #ffe8ba; font-weight: 700; }
.chat-status-box span { font-size: 11px; line-height: 1.5; color: #b0a3c2; }
.chat-status-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chat-status-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 5px;
  padding: 6px 12px;
  border-radius: 10px;
  background: linear-gradient(90deg, #2a1622, #4b1f38, #2a1622);
  border: 1px solid rgba(244,207,134,.35);
  color: #ffe8b8;
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  transition: border-color .18s ease, box-shadow .18s ease;
  width: fit-content;
}
.chat-status-link:hover { border-color: rgba(244,207,134,.6); box-shadow: 0 4px 14px rgba(0,0,0,.35); }

/* ── Messages ── */
.chat-panel .chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  scroll-behavior: smooth;
}
.chat-panel .chat-messages::-webkit-scrollbar { width: 4px; }
.chat-panel .chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-panel .chat-messages::-webkit-scrollbar-thumb {
  background: rgba(244,207,134,.18);
  border-radius: 2px;
}
.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 9px 12px;
  border-radius: 13px;
  background: linear-gradient(135deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
  border: 1px solid rgba(244,207,134,.09);
  animation: msgIn .2s ease;
}
.chat-msg--verified {
  background: linear-gradient(135deg, rgba(75,31,56,.26), rgba(42,16,34,.18));
  border-color: rgba(244,207,134,.14);
}
@keyframes msgIn { from { opacity:0; transform:translateY(5px); } to { opacity:1; transform:translateY(0); } }
.chat-msg-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; }
.chat-msg { position: relative; }
.chat-msg-del {
  all: unset;
  box-sizing: border-box;
  margin-left: auto;
  color: rgba(255,255,255,.2);
  cursor: pointer;
  font-size: 11px;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color .15s ease, background .15s ease;
  flex-shrink: 0;
}
.chat-msg-del:hover { color: #f08080; background: rgba(240,80,80,.12); }
.chat-msg-nick { font-size: 11px; font-weight: 700; color: #f4cf86; letter-spacing: .04em; }
.chat-msg-nick--btn {
  all: unset;
  box-sizing: border-box;
  font-size: 11px;
  font-weight: 700;
  color: #f4cf86;
  letter-spacing: .04em;
  cursor: pointer;
  transition: color .15s ease, text-shadow .15s ease;
}
.chat-msg-nick--btn:hover { color: #ffe8a0; text-shadow: 0 0 8px rgba(244,207,134,.4); }
.chat-msg-text { font-size: 13px; color: #ddd4f0; line-height: 1.55; word-break: break-word; }
.chat-msg-time { font-size: 10px; color: rgba(255,255,255,.25); text-align: right; }
.chat-empty { text-align: center; padding: 28px 0; color: #7a708f; font-size: 13px; margin: 0; font-style: italic; }
.chat-private-gate { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 28px 16px; text-align: center; }
.chat-private-icon { font-size: 32px; margin-bottom: 4px; }
.chat-private-gate strong { font-size: 14px; color: #fff0da; font-weight: 700; }
.chat-private-gate span { font-size: 13px; color: #9a8fad; line-height: 1.5; }
.chat-private-gate .chat-status-link { margin-top: 8px; }

/* ── Badges ── */
.chat-badges { display: inline-flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.chat-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .03em;
  border: 1px solid transparent;
}
.chat-badge--verified { background: rgba(244,207,134,.12); border-color: rgba(244,207,134,.25); color: #ffe8ba; }
.chat-badge--admin { background: rgba(255,122,143,.12); border-color: rgba(255,122,143,.25); color: #ffd0d8; }
.chat-badge--creator { background: rgba(199,158,255,.14); border-color: rgba(199,158,255,.26); color: #ecd8ff; }

/* ── Composer ── */
.chat-panel .chat-form {
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(244,207,134,.12);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.chat-panel .chat-input {
  all: unset;
  box-sizing: border-box;
  flex: 1;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(244,207,134,.18);
  border-radius: 12px;
  padding: 9px 13px;
  font-size: 13px;
  color: #f0e8ff;
  line-height: 1.5;
  min-height: 40px;
  max-height: 90px;
  overflow-y: auto;
  resize: none;
  transition: border-color .2s ease, background .2s ease;
}
.chat-panel .chat-input::placeholder { color: rgba(255,255,255,.25); }
.chat-panel .chat-input:focus {
  border-color: rgba(244,207,134,.40);
  background: rgba(255,255,255,.08);
}
.chat-panel .chat-input:disabled { opacity: .45; cursor: not-allowed; }
.chat-panel .chat-send {
  all: unset;
  box-sizing: border-box;
  background: linear-gradient(135deg, #6f203f, #3a1226);
  border: 1px solid rgba(244,207,134,.40);
  border-radius: 12px;
  color: #ffe8b8;
  cursor: pointer;
  font-size: 16px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
}
.chat-panel .chat-send:hover {
  transform: translateY(-1px);
  border-color: rgba(244,207,134,.65);
  box-shadow: 0 6px 20px rgba(0,0,0,.45), 0 0 12px rgba(244,207,134,.15);
}
.chat-panel .chat-send:disabled { opacity: .35; cursor: not-allowed; transform: none; box-shadow: none; }
.chat-panel .chat-cooldown {
  font-size: 11px;
  color: #f4cf86;
  text-align: center;
  padding: 0 12px 10px;
  min-height: 18px;
  margin: 0;
  opacity: .8;
}

/* ── Profile popup (dialog) ── */
.chat-profile-dialog {
  all: unset;
  box-sizing: border-box;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(360px, calc(100vw - 24px));
  border: 1px solid rgba(244,207,134,.20);
  border-radius: 20px;
  padding: 0;
  background: linear-gradient(160deg, rgba(36,16,28,.98), rgba(12,9,20,.99));
  color: #f3ecff;
  box-shadow: 0 24px 60px rgba(0,0,0,.70), 0 0 0 1px rgba(171,46,95,.10) inset;
  backdrop-filter: blur(20px);
  z-index: 1100;
}
.chat-profile-dialog:not([open]) { display: none; }
.chat-profile-dialog[open] { display: block; }
.chat-profile-dialog::backdrop { background: rgba(0,0,0,.60); backdrop-filter: blur(4px); }
.chat-profile-dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 18px 11px;
  border-bottom: 1px solid rgba(244,207,134,.12);
  background: linear-gradient(90deg, rgba(75,31,56,.22), rgba(42,16,34,.14));
  border-radius: 20px 20px 0 0;
}
.chat-profile-dialog-title { font-size: 14px; font-weight: 700; color: #ffe8ba; letter-spacing: .04em; text-transform: uppercase; }
.chat-profile-dialog-close {
  all: unset;
  box-sizing: border-box;
  color: #9a8fad;
  cursor: pointer;
  font-size: 18px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: color .15s ease, background .15s ease;
}
.chat-profile-dialog-close:hover { color: #f4cf86; background: rgba(244,207,134,.1); }
.chat-profile-dialog-body { padding: 16px 18px 18px; display: grid; gap: 12px; }
.chat-profile-top { display: flex; align-items: flex-start; gap: 14px; }
.chat-profile-avatar {
  width: 54px; height: 54px; border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(244,207,134,.28);
  flex-shrink: 0;
}
.chat-profile-avatar--placeholder {
  width: 54px; height: 54px; border-radius: 50%;
  background: linear-gradient(135deg, #6f203f, #2a1622);
  border: 1px solid rgba(244,207,134,.22);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; color: #f4cf86; flex-shrink: 0;
}
.chat-profile-meta { display: flex; flex-direction: column; gap: 5px; min-width: 0; padding-top: 3px; }
.chat-profile-name { font-size: 16px; color: #fff4e6; font-weight: 700; line-height: 1.1; }
.chat-profile-badges { display: flex; gap: 5px; flex-wrap: wrap; }
.chat-profile-since { font-size: 11px; color: #7a708f; }
.chat-profile-bio {
  font-size: 13px; color: #d0c4e8; line-height: 1.6; margin: 0;
  padding: 11px 13px; border-radius: 12px;
  border: 1px solid rgba(244,207,134,.10);
  background: linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.015));
  overflow-wrap: anywhere;
}
.chat-profile-empty, .chat-profile-empty-bio { font-size: 13px; color: #7a708f; margin: 0; font-style: italic; }

/* ── Responsive ── */
@media (max-width: 760px) {
  .chat-bubble { right: 16px; bottom: 18px; }
  .chat-panel { right: 16px; bottom: 74px; width: min(400px, calc(100vw - 24px)); max-height: min(72dvh, 580px); }
}
