/* =====================================================================
   Ufaso Global Chat — Stylesheet
   Dark, glassmorphic, purple-accented. Discord/Telegram hybrid.
   Scoped under #ufaso-chat so it never collides with the host WP theme.
   ===================================================================== */

#ufaso-chat,
#ufaso-chat * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

#ufaso-chat {
  /* ---- design tokens ---- */
  --bg-void: #07070d;
  --bg-deep: #0b0b16;
  --bg-panel: rgba(18, 18, 32, 0.72);
  --bg-glass: rgba(30, 30, 52, 0.55);
  --bg-bubble-other: rgba(40, 40, 66, 0.5);
  --grad-accent: linear-gradient(135deg, #7c3aed 0%, #a855f7 50%, #c084fc 100%);
  --grad-accent-soft: linear-gradient(135deg, #6d28d9 0%, #8b5cf6 100%);
  --accent: #a78bfa;
  --accent-bright: #c084fc;
  --text: #e9e9f5;
  --text-dim: #9aa0b4;
  --text-faint: #5e6378;
  --online: #34d399;
  --away: #fbbf24;
  --danger: #f87171;
  --border: rgba(140, 130, 200, 0.14);
  --border-bright: rgba(168, 139, 250, 0.4);
  --shadow-pop: 0 24px 70px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(168,139,250,0.08);
  --radius: 18px;
  --radius-sm: 12px;

  --font: 'Inter', 'Noto Sans Georgian', system-ui, -apple-system, 'Segoe UI', sans-serif;

  font-family: var(--font);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===== Floating launcher button ===================================== */
#ufaso-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 64px;
  height: 64px;
  border: none;
  border-radius: 50%;
  background: var(--grad-accent);
  box-shadow: 0 12px 30px -6px rgba(124, 58, 237, 0.6), 0 0 0 1px rgba(255,255,255,0.06) inset;
  cursor: pointer;
  z-index: 2147483000;
  display: grid;
  place-items: center;
  transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
  animation: ufaso-float 4s ease-in-out infinite;
}
#ufaso-launcher:hover { transform: scale(1.08) translateY(-2px); box-shadow: 0 18px 40px -8px rgba(124, 58, 237, 0.75); }
#ufaso-launcher:active { transform: scale(0.96); }
#ufaso-launcher svg { width: 30px; height: 30px; color: #fff; }
#ufaso-launcher .ufaso-badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 22px; height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: #ec4899;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
#ufaso-launcher.ufaso-hidden { transform: scale(0); pointer-events: none; }

@keyframes ufaso-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* ===== Window shell ================================================= */
#ufaso-window {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 420px;
  height: 650px;
  min-width: 320px;
  min-height: 420px;
  background: var(--bg-deep);
  background-image:
    radial-gradient(120% 80% at 100% 0%, rgba(124,58,237,0.18), transparent 60%),
    radial-gradient(100% 70% at 0% 100%, rgba(168,85,247,0.12), transparent 55%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  z-index: 2147483001;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  transform-origin: bottom right;
  opacity: 0;
  transform: translateY(20px) scale(0.92);
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.34s cubic-bezier(0.34, 1.4, 0.64, 1);
}
#ufaso-window.ufaso-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
#ufaso-window.ufaso-fullscreen {
  right: 0; bottom: 0; top: 0; left: 0;
  width: 100% !important; height: 100% !important;
  border-radius: 0;
  border: none;
}
#ufaso-window.ufaso-minimized { height: 56px !important; min-height: 56px; }
#ufaso-window.ufaso-minimized .ufaso-body,
#ufaso-window.ufaso-minimized .ufaso-composer { display: none; }

/* Resize handles */
.ufaso-resize {
  position: absolute;
  z-index: 5;
  -webkit-user-select: none;
  user-select: none;
}
.ufaso-resize-l { left: 0; top: 0; width: 6px; height: 100%; cursor: ew-resize; }
.ufaso-resize-t { left: 0; top: 0; width: 100%; height: 6px; cursor: ns-resize; }
.ufaso-resize-tl { left: 0; top: 0; width: 14px; height: 14px; cursor: nwse-resize; }
#ufaso-window.ufaso-fullscreen .ufaso-resize { display: none; }

/* ===== Header ======================================================= */
.ufaso-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  cursor: grab;
  flex-shrink: 0;
}
.ufaso-header:active { cursor: grabbing; }
.ufaso-logo {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: var(--grad-accent);
  display: grid; place-items: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px -2px rgba(124,58,237,0.5);
}
.ufaso-logo svg { width: 20px; height: 20px; color: #fff; }
.ufaso-title { flex: 1; min-width: 0; }
.ufaso-title h3 {
  font-size: 15px; font-weight: 700; letter-spacing: 0.2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 6px;
}
.ufaso-status {
  font-size: 12px; color: var(--text-dim);
  display: flex; align-items: center; gap: 6px; margin-top: 1px;
}
.ufaso-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--online); box-shadow: 0 0 8px var(--online);
}
.ufaso-dot.ufaso-offline { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.ufaso-controls { display: flex; gap: 4px; }
.ufaso-ctrl {
  width: 30px; height: 30px; border: none; border-radius: 9px;
  background: transparent; color: var(--text-dim);
  cursor: pointer; display: grid; place-items: center;
  transition: background 0.18s ease, color 0.18s ease, transform 0.12s ease;
}
.ufaso-ctrl:hover { background: var(--bg-glass); color: var(--text); }
.ufaso-ctrl:active { transform: scale(0.9); }
.ufaso-ctrl.ufaso-close:hover { background: rgba(248,113,113,0.18); color: var(--danger); }
.ufaso-ctrl svg { width: 16px; height: 16px; }

/* ===== Body (sidebar + chat) ======================================= */
.ufaso-body { flex: 1; display: flex; min-height: 0; }

.ufaso-sidebar {
  width: 0;
  flex-shrink: 0;
  background: rgba(10, 10, 20, 0.5);
  border-right: 1px solid var(--border);
  overflow: hidden;
  transition: width 0.3s ease;
  display: flex; flex-direction: column;
}
#ufaso-window.ufaso-show-sidebar .ufaso-sidebar { width: 220px; }
.ufaso-sidebar-head {
  padding: 14px 16px 8px;
  font-size: 13px; color: var(--text-dim);
  display: flex; align-items: center; gap: 8px;
}
.ufaso-online-pill {
  color: var(--online); font-weight: 600;
}
.ufaso-userlist { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.ufaso-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 11px;
  transition: background 0.15s ease;
}
.ufaso-user:hover { background: var(--bg-glass); }
.ufaso-user .ufaso-avatar { width: 34px; height: 34px; }
.ufaso-user-name { font-size: 14px; font-weight: 500; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ufaso-user-status { width: 9px; height: 9px; border-radius: 50%; background: var(--online); box-shadow: 0 0 6px var(--online); flex-shrink: 0; }

/* Avatar (gradient + initial) */
.ufaso-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px; color: #fff;
  flex-shrink: 0; overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}

/* ===== Chat column ================================================== */
.ufaso-chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.ufaso-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 14px 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
.ufaso-messages::-webkit-scrollbar,
.ufaso-userlist::-webkit-scrollbar { width: 8px; }
.ufaso-messages::-webkit-scrollbar-thumb,
.ufaso-userlist::-webkit-scrollbar-thumb { background: rgba(168,139,250,0.25); border-radius: 8px; }
.ufaso-messages::-webkit-scrollbar-thumb:hover { background: rgba(168,139,250,0.4); }

.ufaso-loadmore {
  align-self: center; margin: 6px 0;
  font-size: 12px; color: var(--text-dim);
  background: var(--bg-glass); border: 1px solid var(--border);
  padding: 6px 14px; border-radius: 20px; cursor: pointer;
  transition: all 0.18s ease;
}
.ufaso-loadmore:hover { color: var(--text); border-color: var(--border-bright); }

/* Message row */
.ufaso-msg {
  display: flex; gap: 10px; max-width: 86%;
  animation: ufaso-fade-in 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.ufaso-msg.ufaso-own { align-self: flex-end; flex-direction: row-reverse; }
.ufaso-msg-col { display: flex; flex-direction: column; min-width: 0; }
.ufaso-msg.ufaso-own .ufaso-msg-col { align-items: flex-end; }

.ufaso-msg-meta {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px; padding: 0 4px;
}
.ufaso-msg-name { font-size: 13px; font-weight: 700; }
.ufaso-msg-time { font-size: 11px; color: var(--text-faint); }

.ufaso-bubble {
  position: relative;
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 14.5px;
  word-break: break-word;
  overflow-wrap: anywhere;
  background: var(--bg-bubble-other);
  border: 1px solid var(--border);
  border-top-left-radius: 5px;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.ufaso-msg.ufaso-own .ufaso-bubble {
  background: var(--grad-accent-soft);
  border: none;
  border-top-left-radius: 16px;
  border-top-right-radius: 5px;
  color: #fff;
}
/* subtle glass reflection */
.ufaso-bubble::after {
  content: ''; position: absolute; inset: 0;
  border-radius: inherit;
  background: linear-gradient(160deg, rgba(255,255,255,0.06), transparent 40%);
  pointer-events: none;
}

.ufaso-bubble.ufaso-deleted { font-style: italic; color: var(--text-faint); }

/* Reply preview inside a bubble */
.ufaso-reply-quote {
  border-left: 3px solid var(--accent);
  padding: 3px 8px; margin-bottom: 6px;
  background: rgba(0,0,0,0.18); border-radius: 6px;
  font-size: 12.5px;
}
.ufaso-reply-quote .ufaso-rq-name { color: var(--accent-bright); font-weight: 600; }
.ufaso-reply-quote .ufaso-rq-body { color: var(--text-dim); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }

/* Image message */
.ufaso-msg-img {
  display: block; max-width: 260px; max-height: 280px;
  border-radius: 12px; cursor: zoom-in; margin-top: 2px;
  border: 1px solid var(--border);
}

/* AI message accent */
.ufaso-msg.ufaso-ai .ufaso-bubble {
  background: linear-gradient(135deg, rgba(34,211,238,0.16), rgba(34,211,238,0.06));
  border-color: rgba(34,211,238,0.35);
  white-space: pre-wrap;
}

/* Hover actions (reply / admin delete) */
.ufaso-msg-actions {
  display: flex; gap: 2px; align-self: center;
  opacity: 0; transition: opacity 0.15s ease;
}
.ufaso-msg:hover .ufaso-msg-actions { opacity: 1; }
.ufaso-act {
  width: 26px; height: 26px; border: none; border-radius: 8px;
  background: var(--bg-glass); color: var(--text-dim);
  cursor: pointer; display: grid; place-items: center;
}
.ufaso-act:hover { color: var(--text); background: rgba(168,139,250,0.2); }
.ufaso-act.ufaso-del:hover { color: var(--danger); background: rgba(248,113,113,0.18); }
.ufaso-act svg { width: 14px; height: 14px; }

/* System line */
.ufaso-system {
  align-self: center; font-size: 12px; color: var(--text-faint);
  background: var(--bg-glass); padding: 4px 12px; border-radius: 20px;
}

/* Typing indicator */
.ufaso-typing {
  height: 22px; padding: 0 16px 6px;
  font-size: 12px; color: var(--text-dim);
  display: flex; align-items: center; gap: 6px;
}
.ufaso-typing .ufaso-dots { display: inline-flex; gap: 3px; }
.ufaso-typing .ufaso-dots span {
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
  animation: ufaso-bounce 1.2s infinite ease-in-out;
}
.ufaso-typing .ufaso-dots span:nth-child(2) { animation-delay: 0.15s; }
.ufaso-typing .ufaso-dots span:nth-child(3) { animation-delay: 0.3s; }

/* ===== Reply bar (above composer) ================================== */
.ufaso-replybar {
  display: none;
  align-items: center; gap: 10px;
  padding: 8px 14px;
  background: var(--bg-glass);
  border-top: 1px solid var(--border);
  font-size: 12.5px;
}
.ufaso-replybar.ufaso-show { display: flex; }
.ufaso-replybar .ufaso-rb-text { flex: 1; min-width: 0; }
.ufaso-replybar .ufaso-rb-name { color: var(--accent-bright); font-weight: 600; }
.ufaso-replybar .ufaso-rb-body { color: var(--text-dim); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ufaso-replybar .ufaso-rb-close { background: none; border: none; color: var(--text-dim); cursor: pointer; padding: 4px; }

/* ===== Composer ===================================================== */
.ufaso-composer {
  flex-shrink: 0;
  padding: 12px 14px 14px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.ufaso-input-wrap {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 6px 8px 6px 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.ufaso-input-wrap:focus-within {
  border-color: var(--border-bright);
  box-shadow: 0 0 0 3px rgba(168,139,250,0.12);
}
.ufaso-textarea {
  flex: 1; resize: none; border: none; outline: none;
  background: transparent; color: var(--text);
  font-family: inherit; font-size: 14.5px; line-height: 1.45;
  max-height: 120px; padding: 6px 0;
}
.ufaso-textarea::placeholder { color: var(--text-faint); }
.ufaso-tools { display: flex; align-items: center; gap: 2px; }
.ufaso-tool {
  width: 34px; height: 34px; border: none; border-radius: 10px;
  background: transparent; color: var(--text-dim);
  cursor: pointer; display: grid; place-items: center;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.ufaso-tool:hover { background: rgba(168,139,250,0.16); color: var(--accent-bright); }
.ufaso-tool:active { transform: scale(0.88); }
.ufaso-tool svg { width: 19px; height: 19px; }
.ufaso-send {
  width: 38px; height: 38px; border: none; border-radius: 12px;
  background: var(--grad-accent); color: #fff;
  cursor: pointer; display: grid; place-items: center;
  transition: transform 0.14s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  box-shadow: 0 4px 14px -3px rgba(124,58,237,0.6);
}
.ufaso-send:hover { transform: translateY(-1px) scale(1.04); }
.ufaso-send:active { transform: scale(0.92); }
.ufaso-send:disabled { opacity: 0.4; cursor: default; transform: none; box-shadow: none; }
.ufaso-send svg { width: 18px; height: 18px; }

/* ===== Emoji picker ================================================ */
.ufaso-emoji-panel {
  position: absolute;
  bottom: 76px; right: 14px;
  width: 320px; max-width: calc(100% - 28px);
  height: 300px;
  background: var(--bg-deep);
  border: 1px solid var(--border-bright);
  border-radius: 16px;
  box-shadow: var(--shadow-pop);
  display: none; flex-direction: column;
  z-index: 20; overflow: hidden;
  animation: ufaso-pop 0.2s ease;
}
.ufaso-emoji-panel.ufaso-show { display: flex; }
.ufaso-emoji-tabs {
  display: flex; padding: 8px 10px 6px; gap: 2px;
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.ufaso-emoji-tab {
  border: none; background: transparent; cursor: pointer;
  font-size: 18px; padding: 4px 7px; border-radius: 8px; line-height: 1;
  transition: background 0.15s ease;
}
.ufaso-emoji-tab:hover, .ufaso-emoji-tab.ufaso-active { background: var(--bg-glass); }
.ufaso-emoji-search {
  margin: 8px 10px; padding: 8px 12px;
  background: var(--bg-glass); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-size: 13px; outline: none;
}
.ufaso-emoji-search:focus { border-color: var(--border-bright); }
.ufaso-emoji-grid {
  flex: 1; overflow-y: auto; padding: 4px 8px 10px;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
}
.ufaso-emoji-grid button {
  border: none; background: transparent; cursor: pointer;
  font-size: 22px; padding: 4px; border-radius: 8px; line-height: 1;
  transition: background 0.12s ease, transform 0.1s ease;
}
.ufaso-emoji-grid button:hover { background: var(--bg-glass); transform: scale(1.2); }
.ufaso-emoji-section { grid-column: 1 / -1; font-size: 11px; color: var(--text-faint); padding: 8px 4px 2px; text-transform: uppercase; letter-spacing: 0.6px; }

/* ===== Lightbox ==================================================== */
.ufaso-lightbox {
  position: fixed; inset: 0; z-index: 2147483002;
  background: rgba(0,0,0,0.88);
  display: none; align-items: center; justify-content: center;
  padding: 24px; cursor: zoom-out;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.ufaso-lightbox.ufaso-show { display: flex; animation: ufaso-fade-in 0.2s ease; }
.ufaso-lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 12px; box-shadow: 0 30px 80px rgba(0,0,0,0.6); }
.ufaso-lightbox-close {
  position: absolute; top: 20px; right: 24px;
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,0.1); border: none; color: #fff;
  font-size: 22px; cursor: pointer;
}

/* ===== Nickname modal ============================================== */
.ufaso-modal {
  position: fixed; inset: 0; z-index: 2147483003;
  background: rgba(5,5,12,0.7);
  display: none; align-items: center; justify-content: center; padding: 20px;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.ufaso-modal.ufaso-show { display: flex; animation: ufaso-fade-in 0.25s ease; }
.ufaso-modal-card {
  width: 100%; max-width: 380px;
  background: var(--bg-deep);
  background-image: radial-gradient(120% 80% at 50% 0%, rgba(124,58,237,0.22), transparent 60%);
  border: 1px solid var(--border-bright);
  border-radius: 22px;
  padding: 32px 28px;
  box-shadow: var(--shadow-pop);
  text-align: center;
  animation: ufaso-pop 0.32s cubic-bezier(0.34, 1.5, 0.64, 1);
}
.ufaso-modal-logo {
  width: 60px; height: 60px; margin: 0 auto 16px;
  border-radius: 18px; background: var(--grad-accent);
  display: grid; place-items: center;
  box-shadow: 0 10px 28px -6px rgba(124,58,237,0.6);
}
.ufaso-modal-logo svg { width: 30px; height: 30px; color: #fff; }
.ufaso-modal-card h2 { font-size: 20px; margin-bottom: 6px; }
.ufaso-modal-card p { color: var(--text-dim); font-size: 13.5px; margin-bottom: 20px; }
.ufaso-nick-input {
  width: 100%; padding: 13px 16px;
  background: var(--bg-glass); border: 1px solid var(--border);
  border-radius: 13px; color: var(--text);
  font-size: 15px; outline: none; text-align: center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.ufaso-nick-input:focus { border-color: var(--border-bright); box-shadow: 0 0 0 3px rgba(168,139,250,0.14); }
.ufaso-nick-error { color: var(--danger); font-size: 12.5px; min-height: 18px; margin-top: 8px; }
.ufaso-nick-submit {
  width: 100%; margin-top: 6px; padding: 13px;
  border: none; border-radius: 13px; cursor: pointer;
  background: var(--grad-accent); color: #fff;
  font-size: 15px; font-weight: 600; font-family: inherit;
  transition: transform 0.14s ease, box-shadow 0.2s ease;
  box-shadow: 0 8px 22px -6px rgba(124,58,237,0.55);
}
.ufaso-nick-submit:hover { transform: translateY(-1px); }
.ufaso-nick-submit:active { transform: scale(0.97); }

/* Hidden file input */
.ufaso-file-input { display: none; }

/* ===== Animations ================================================= */
@keyframes ufaso-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes ufaso-pop {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes ufaso-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ===== Mobile ===================================================== */
@media (max-width: 560px) {
  #ufaso-window {
    right: 0 !important; bottom: 0 !important; top: 0 !important; left: 0 !important;
    width: 100% !important; height: 100% !important;
    border-radius: 0; border: none;
  }
  #ufaso-window .ufaso-resize { display: none; }
  #ufaso-launcher { right: 16px; bottom: 16px; }
  .ufaso-msg { max-width: 92%; }
  #ufaso-window.ufaso-show-sidebar .ufaso-sidebar {
    position: absolute; height: 100%; z-index: 10; width: 78%;
    box-shadow: 12px 0 40px rgba(0,0,0,0.5);
  }
}

/* ===== Reduced motion ============================================= */
@media (prefers-reduced-motion: reduce) {
  #ufaso-chat *, #ufaso-launcher { animation: none !important; transition: none !important; }
}
