/* chat-themes.css — loaded after fullscreen.css. The wallpaper picture (--kc-image) is set by chat-themes.js from the
   themes the admin uploaded; with no theme the chat keeps the app's normal background. */

/* ---------- wallpaper ---------- */
body[data-chat-theme] .chat-page .thread-messages {
  background-color: transparent;
  background-image: var(--kc-image);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  background-attachment: scroll;
}
body[data-chat-theme] .chat-page {
  --kc-n1: #22e5ff; --kc-n2: #ff3df2; --kc-m1: #7b3ff2; --kc-m2: #d62ff0; --kc-glow: rgba(214, 47, 240, .5);
  --kc-in-bg: #14122c; --kc-in-fg: #eef0f6;
}
body[data-theme="light"][data-chat-theme] .chat-page { --kc-m1: #6a5cf0; --kc-m2: #4d3fc9; --kc-glow: rgba(77, 63, 201, .25); }

/* ---------- bubbles (dark mode only — light mode keeps the app's own light bubble palette) ---------- */
body[data-theme="dark"][data-chat-theme] .chat-page .thread-bubble:not(.mine):not(.thread-bubble-sticker):not(.thread-bubble-gif):not(.thread-bubble-voice) {
  background: var(--kc-in-bg); color: var(--kc-in-fg);
}
body[data-theme="dark"][data-chat-theme] .chat-page .thread-bubble.mine:not(.thread-bubble-sticker):not(.thread-bubble-gif) {
  background: #2b3358; color: #fff;
}
/* Messages stay plain — no neon colour, border or glow. Only the wallpaper behind them shines. */
body[data-theme="dark"][data-chat-theme] .chat-page .thread-bubble[data-who]:not(.mine)::before,
body[data-theme="dark"][data-chat-theme] .chat-page .thread-bubble-sender { color: inherit !important; opacity: .72; }

/* ---------- neon (dark mode only): background / chrome glow, never the message bubbles ---------- */
body[data-theme="dark"][data-chat-theme] .chat-page .thread-head { box-shadow: 0 8px 24px -10px var(--kc-glow); }
body[data-theme="dark"][data-chat-theme] .chat-page .thread-head::after {
  animation: kcSweep 7s linear infinite;
  background: linear-gradient(90deg, transparent, var(--kc-n1), var(--kc-n2), transparent) 0 0 / 220% 100%;
  bottom: -1px; box-shadow: 0 0 10px var(--kc-n1); content: ''; height: 2px; left: 0; pointer-events: none; position: absolute; right: 0;
}
@keyframes kcSweep { from { background-position: 0 0; } to { background-position: -220% 0; } }
body[data-theme="dark"][data-chat-theme] .chat-page .thread-compose { border-top-color: color-mix(in srgb, var(--kc-n1) 35%, transparent); box-shadow: 0 -8px 24px -12px var(--kc-glow); }
body[data-theme="dark"][data-chat-theme] .chat-page .thread-compose-textarea:focus {
  border-color: var(--kc-n1); box-shadow: 0 0 0 1px var(--kc-n1), 0 0 16px -2px var(--kc-glow); outline: 0;
}
body[data-chat-theme] .chat-page .thread-send-button { background: linear-gradient(135deg, var(--kc-m1), var(--kc-m2)); color: #fff; }
body[data-theme="dark"][data-chat-theme] .chat-page .thread-send-button { box-shadow: 0 0 14px -1px var(--kc-glow); }

/* ---------- head buttons: title takes the free space, buttons sit together on the right ---------- */
.chat-page .thread-head .thread-head-meta { margin-right: auto; min-width: 0; }
.chat-page .thread-head .thread-clear-button, .chat-page .thread-head .thread-call-button { margin-left: 0; }
.chat-page .thread-head .kc-clear-button svg { fill: none; height: 19px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.9; width: 19px; }
.chat-page .thread-head .kc-clear-button:hover { color: #ff6b81; }
body[data-theme="dark"] .chat-page .thread-head .kc-clear-button:hover { background: rgba(255, 107, 129, .14); }

/* ---------- clear animation ---------- */
.thread-messages.kc-clearing > * { animation: kcClear .28s ease-in forwards; }
@keyframes kcClear { to { opacity: 0; transform: translateY(10px) scale(.96); } }

/* ---------- smooth, comfortable long chats ---------- */
.chat-page .thread-messages { overscroll-behavior-y: contain; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.chat-page .thread-bubble { font-size: 13.5px; line-height: 1.5; text-wrap: pretty; }
.chat-page .thread-head, .chat-page .thread-compose, .chat-page button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.chat-page .thread-head { -webkit-user-select: none; user-select: none; }
.chat-page .thread-messages > .thread-bubble:nth-last-child(-n+3) { animation: kcIn .22s ease-out; }
@keyframes kcIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (pointer: coarse) { .chat-page .thread-compose-textarea { font-size: 16px; } }
@media (prefers-reduced-motion: reduce) {
  body[data-theme="dark"][data-chat-theme] .chat-page .thread-head::after { animation: none; }
  .chat-page .thread-messages > .thread-bubble:nth-last-child(-n+3) { animation: none; }
}

/* ---------- clear-chat popup ---------- */
.kc-modal { align-items: center; background: rgba(6, 8, 18, .6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: flex; inset: 0; justify-content: center; opacity: 0; padding: 20px; position: fixed; transition: opacity .16s ease; z-index: 100000; }
.kc-modal.is-open { opacity: 1; }
.kc-modal-card { background: #fff; border: 1px solid rgba(28, 35, 61, .12); border-radius: 20px; box-shadow: 0 24px 60px rgba(10, 14, 30, .35); color: #1c233d; max-width: 360px; padding: 24px 22px 18px; text-align: center; transform: translateY(12px) scale(.97); transition: transform .18s cubic-bezier(.2, .9, .3, 1.2); width: 100%; }
.kc-modal.is-open .kc-modal-card { transform: none; }
body[data-theme="dark"] .kc-modal-card { background: #121629; border-color: rgba(139, 123, 255, .35); box-shadow: 0 0 0 1px rgba(139, 123, 255, .2), 0 0 40px -8px rgba(139, 123, 255, .5), 0 24px 60px rgba(0, 0, 0, .6); color: #eef0f9; }
.kc-modal-icon { align-items: center; background: rgba(255, 71, 99, .12); border-radius: 50%; color: #ff4763; display: inline-flex; height: 52px; justify-content: center; margin-bottom: 10px; width: 52px; }
.kc-modal-icon svg { fill: none; height: 26px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; width: 26px; }
.kc-modal-card h3 { font-size: 18px; letter-spacing: -.02em; margin: 0 0 6px; }
.kc-modal-card p { color: #5d667f; font-size: 13.5px; line-height: 1.5; margin: 0 0 18px; }
body[data-theme="dark"] .kc-modal-card p { color: #a3abc2; }
.kc-modal-actions { display: flex; gap: 10px; }
.kc-btn { border: 0; border-radius: 12px; cursor: pointer; flex: 1; font: 700 14px/1 inherit; font-family: inherit; min-height: 44px; padding: 0 14px; }
.kc-btn-ghost { background: rgba(120, 104, 233, .1); color: inherit; }
body[data-theme="dark"] .kc-btn-ghost { background: rgba(255, 255, 255, .08); }
.kc-btn-danger { background: linear-gradient(135deg, #ff4763, #e0223f); box-shadow: 0 6px 16px -4px rgba(224, 34, 63, .55); color: #fff; }
.kc-btn:active { transform: scale(.97); }
.kc-btn:focus-visible { outline: 2px solid #8b7bff; outline-offset: 2px; }

/* ---------- Settings: chat theme picker ---------- */
.kc-theme-section { margin-top: 14px; }
.kc-theme-section-head { align-items: center; display: flex; gap: 10px; justify-content: space-between; margin-bottom: 8px; }
.kc-theme-section-head h4 { font-size: 13.5px; margin: 0; }
.kc-theme-now { background: rgba(120, 104, 233, .14); border-radius: 999px; color: #7868e9; font-size: 10.5px; font-weight: 700; margin-left: 6px; padding: 2px 8px; vertical-align: middle; }
.kc-theme-reset { background: none; border: 0; color: #7868e9; cursor: pointer; font: 600 12px/1 inherit; font-family: inherit; padding: 4px 2px; }
.kc-theme-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); margin-top: 6px; }
.kc-theme-card { background: transparent; border: 0; border-radius: 16px; color: inherit; cursor: pointer; display: flex; flex-direction: column; font: inherit; gap: 2px; padding: 0; text-align: left; }
.kc-theme-card strong { font-size: 12.5px; margin-top: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kc-theme-card small { color: var(--fs-muted, #6b7388); font-size: 11px; line-height: 1.35; }
.kc-theme-swatch { background-color: rgba(120, 120, 150, .18); background-position: center; background-repeat: no-repeat; background-size: cover; border: 2px solid transparent; border-radius: 16px; box-shadow: 0 0 0 1px rgba(120, 120, 150, .25); display: flex; flex-direction: column; gap: 6px; height: 150px; justify-content: flex-end; overflow: hidden; padding: 8px; position: relative; transition: transform .15s ease, box-shadow .15s ease; }
.kc-theme-card:hover .kc-theme-swatch { transform: translateY(-2px); }
.kc-theme-card:focus-visible { outline: 2px solid #8b7bff; outline-offset: 3px; }
.kc-sw-in, .kc-sw-out { border-radius: 10px; font-size: 10.5px; font-weight: 600; padding: 4px 8px; width: fit-content; }
.kc-sw-in { background: #14122c; color: #eef0f6; }
.kc-sw-out { background: linear-gradient(135deg, #7b3ff2, #d62ff0); color: #fff; margin-left: auto; }
body[data-theme="light"] .kc-sw-in { background: #fff; color: #2b3145; }
.kc-sw-check { align-items: center; background: #22e5ff; border-radius: 50%; color: #08101c; display: none; font-size: 12px; font-weight: 800; height: 20px; justify-content: center; position: absolute; right: 8px; top: 8px; width: 20px; }
.kc-theme-card.is-active .kc-theme-swatch { border-color: #8b7bff; box-shadow: 0 0 0 2px #8b7bff; }
.kc-theme-card.is-active .kc-sw-check { display: inline-flex; }
@media (max-width: 420px) { .kc-theme-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; } .kc-theme-swatch { height: 130px; } }
