/* ============================================================
   KUPR Messages — Telegram-Style Dark Theme
   Version: 1.0.0 (March 2026)
   Dependencies: kupr-fonts.css (Poppins), kupr-mobile.css
   ============================================================ */

:root {
  --km-bg:           #0e0e10;
  --km-sidebar-bg:   #12121f;
  --km-chat-bg:      #0a0a16;
  --km-bubble-out:   #1a3a5c;
  --km-bubble-in:    #1a1a2e;
  --km-accent:       #ffd700;
  --km-accent-soft:  #e6c200;
  --km-accent-dim:   rgba(255,215,0,0.12);
  --km-text:         #e8e8ec;
  --km-text-muted:   #8888a0;
  --km-text-dim:     #555568;
  --km-online:       #2ecc71;
  --km-read:         #4fc3f7;
  --km-danger:       #ef5350;
  --km-border:       rgba(255,215,0,0.08);
  --km-hover:        rgba(255,215,0,0.06);
  --km-shadow:       0 4px 24px rgba(0,0,0,0.5);
  --km-radius:       12px;
  --km-bubble-radius: 18px;
  --km-sidebar-w:    360px;
  --km-header-h:     64px;
  --km-input-h:      58px;
  --km-transition:   0.2s ease;
  --km-glow:         0 0 20px rgba(255,215,0,0.06);
}

/* ---- Reset for messaging page ---- */
#kupr-msg-app *,
#kupr-msg-app *::before,
#kupr-msg-app *::after {
  box-sizing: border-box;
}

/* ============================================================
   LAYOUT — Two-column split
   ============================================================ */
#kupr-msg-app {
  display: flex !important;
  position: relative !important; /* stay in normal flow â€” no position:fixed trap */
  width: 100% !important;
  height: calc(100vh - 50px) !important; /* full viewport minus Bootstrap navbar */
  margin: 0 !important;
  background: var(--km-bg) !important;
  overflow: hidden !important;
  z-index: 1 !important;
}
/* Override WoWonder's content-container padding for messages */
.wo-msg-container {
  padding: 0 !important;
  overflow: hidden !important;
}
.wo-msg-container .effect-load,
.wo-msg-container #contnet {
  padding: 0 !important;
  margin: 0 !important;
  max-width: 100% !important;
  width: 100% !important;
}
/* Hide WoWonder chat/modals that persist after AJAX navigation to messages page */
.wo-msg-container .chat_main,
.wo-msg-container #chat-container,
.wo-msg-container .messagejoint {
  display: none !important;
}

/* Sidebar */
#kupr-msg-sidebar {
  width: var(--km-sidebar-w);
  min-width: var(--km-sidebar-w);
  background: var(--km-sidebar-bg);
  border-right: 1px solid var(--km-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10;
  box-shadow: 4px 0 20px rgba(0,0,0,0.3);
}

/* Chat area */
#kupr-msg-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--km-chat-bg);
  position: relative;
  min-width: 0;
}

/* Chat info panel (slide-in) */
#kupr-msg-info {
  width: 0;
  overflow: hidden;
  background: var(--km-sidebar-bg);
  border-left: 1px solid var(--km-border);
  transition: width var(--km-transition);
  flex-shrink: 0;
}
#kupr-msg-info.open {
  width: 320px;
}

/* ============================================================
   SIDEBAR — Header
   ============================================================ */
.km-sidebar-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--km-border);
  flex-shrink: 0;
}

.km-search-box {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.05);
  border-radius: 22px;
  padding: 0 14px;
  height: 40px;
  transition: background var(--km-transition);
}
.km-search-box:focus-within {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,215,0,0.2);
  box-shadow: 0 0 0 3px rgba(255,215,0,0.06), 0 2px 8px rgba(0,0,0,0.2);
}
.km-search-box svg {
  width: 18px;
  height: 18px;
  color: var(--km-text-muted);
  flex-shrink: 0;
  margin-right: 10px;
}
.km-search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--km-text);
  font-size: 14px;
  width: 100%;
  font-family: inherit;
}
.km-search-box input::placeholder {
  color: var(--km-text-dim);
}

.km-header-actions {
  display: flex;
  gap: 4px;
  margin-top: 10px;
}
.km-header-actions .km-icon-btn {
  width: 36px;
  height: 36px;
}

/* ---- Tab switcher ---- */
.km-chat-tabs {
  display: flex;
  border-bottom: 1px solid var(--km-border);
  flex-shrink: 0;
}
.km-chat-tabs .km-tab {
  flex: 1;
  text-align: center;
  padding: 10px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--km-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--km-transition);
  user-select: none;
}
.km-chat-tabs .km-tab.active {
  color: var(--km-accent);
  border-bottom-color: var(--km-accent);
}
.km-chat-tabs .km-tab:hover:not(.active) {
  color: var(--km-text);
  background: var(--km-hover);
}

/* ============================================================
   SIDEBAR — Chat list
   ============================================================ */
#km-chat-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.km-chat-item {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  transition: background var(--km-transition);
  border-bottom: 1px solid rgba(255,255,255,0.02);
  position: relative;
}
.km-chat-item:hover {
  background: var(--km-hover);
}
.km-chat-item.active {
  background: var(--km-accent-dim);
  border-left: 3px solid var(--km-accent);
  box-shadow: inset 0 0 20px rgba(255,215,0,0.04);
}
.km-chat-item.unread .km-chat-name {
  color: #fff;
  font-weight: 700;
}
.km-chat-item.unread .km-chat-preview {
  color: var(--km-text);
}

/* Avatar */
.km-avatar {
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  margin-right: 12px;
}
.km-avatar img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
}
.km-avatar .km-online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--km-online);
  border: 2px solid var(--km-sidebar-bg);
  box-shadow: 0 0 6px rgba(46,204,113,0.5);
}
.km-avatar .km-online-dot.offline {
  background: var(--km-text-dim);
}

/* Chat info */
.km-chat-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.km-chat-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.km-chat-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--km-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
.km-chat-time {
  font-size: 11px;
  color: var(--km-text-dim);
  flex-shrink: 0;
  margin-left: 8px;
}
.km-chat-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.km-chat-preview {
  font-size: 13px;
  color: var(--km-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  line-height: 1.3;
}
.km-unread-badge {
  background: linear-gradient(135deg, #ffdb4d, var(--km-accent));
  color: #000;
  font-size: 10px;
  font-weight: 800;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  flex-shrink: 0;
  margin-left: 8px;
  box-shadow: 0 2px 8px rgba(255,215,0,0.35);
  letter-spacing: -0.3px;
}
.km-unread-badge.hidden {
  display: none;
}

/* Empty state */
.km-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--km-text-dim);
  text-align: center;
}
.km-empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}

/* ============================================================
   CHAT — Header
   ============================================================ */
.km-chat-header {
  display: flex;
  align-items: center;
  padding: 0 20px;
  height: var(--km-header-h);
  background: linear-gradient(180deg, var(--km-sidebar-bg) 0%, rgba(18,18,31,0.95) 100%);
  border-bottom: 1px solid var(--km-border);
  flex-shrink: 0;
  z-index: 5;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.km-back-btn {
  display: none; /* shown on mobile */
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: none;
  border: none;
  color: var(--km-text);
  cursor: pointer;
  margin-right: 8px;
  transition: background var(--km-transition);
}
.km-back-btn:hover {
  background: var(--km-hover);
}
.km-back-btn svg {
  width: 22px;
  height: 22px;
}

.km-chat-header .km-avatar {
  width: 40px;
  height: 40px;
}
.km-chat-header .km-avatar img {
  width: 40px;
  height: 40px;
}
.km-chat-header .km-avatar .km-online-dot {
  width: 10px;
  height: 10px;
  border-width: 2px;
}

.km-user-info {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}
.km-user-details {
  margin-left: 12px;
}
.km-user-details .km-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--km-text);
}
.km-user-details .km-status {
  font-size: 12px;
  color: var(--km-text-muted);
  letter-spacing: 0.2px;
}
.km-user-details .km-status.online {
  color: var(--km-online);
  font-weight: 500;
  text-shadow: 0 0 8px rgba(46,204,113,0.3);
}

.km-chat-header .km-header-actions {
  display: flex;
  gap: 4px;
  margin: 0;
}

/* ---- Pinned messages bar ---- */
.km-pinned-bar {
  display: none;
  padding: 8px 16px;
  background: rgba(255,215,0,0.06);
  border-bottom: 1px solid var(--km-border);
  font-size: 13px;
  color: var(--km-text-muted);
  cursor: pointer;
  flex-shrink: 0;
}
.km-pinned-bar.active {
  display: flex;
  align-items: center;
  gap: 8px;
}
.km-pinned-bar svg {
  width: 16px;
  height: 16px;
  color: var(--km-accent);
  flex-shrink: 0;
}
.km-pinned-bar .km-pinned-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   CHAT — Messages area
   ============================================================ */
#km-messages-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 20px 8px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end; /* Messages stick to bottom like Telegram */
  gap: 2px;
  scroll-behavior: smooth;
  min-height: 0; /* Flexbox overflow fix */
}

/* Background pattern (premium subtle) */
#kupr-msg-chat {
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(255,215,0,0.02) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(79,195,247,0.015) 0%, transparent 50%),
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffd700' fill-opacity='0.025'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  background-color: var(--km-chat-bg);
}

/* ---- Date separator ---- */
.km-date-sep {
  display: flex;
  justify-content: center;
  margin: 12px 0 8px;
  position: relative;
  z-index: 1;
}
.km-date-sep span {
  background: rgba(10,10,22,0.7);
  color: var(--km-text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 14px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.05);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

/* ============================================================
   MESSAGE BUBBLES
   ============================================================ */
.km-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 75%;
  margin-bottom: 2px;
  position: relative;
  z-index: 1;
  animation: km-fadeIn 0.15s ease;
}
@keyframes km-fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.km-msg.outgoing {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.km-msg.incoming {
  align-self: flex-start;
}

/* Avatar (incoming only) */
.km-msg-avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}
.km-msg-avatar img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}
.km-msg.outgoing .km-msg-avatar {
  display: none;
}

/* Bubble */
.km-msg-bubble {
  padding: 8px 12px;
  border-radius: var(--km-bubble-radius);
  position: relative;
  min-width: 80px;
  word-break: break-word;
}
.km-msg.incoming .km-msg-bubble {
  background: var(--km-bubble-in);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.km-msg.outgoing .km-msg-bubble {
  background: linear-gradient(135deg, #1e4470 0%, var(--km-bubble-out) 100%);
  border-bottom-right-radius: 4px;
  box-shadow: 0 1px 6px rgba(26,58,92,0.4);
}

/* Text */
.km-msg-text {
  font-size: 14px;
  line-height: 1.45;
  color: var(--km-text);
  white-space: pre-wrap;
}
.km-msg-text:empty {
  display: none;
}

/* Meta (time + check) */
.km-msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 3px;
  float: right;
  margin-left: 10px;
}
.km-msg-time {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
}
.km-msg-check {
  display: inline-flex;
  color: rgba(255,255,255,0.35);
}
.km-msg-check.read {
  color: var(--km-read);
}
.km-msg-check svg {
  width: 16px;
  height: 16px;
}

/* ---- Reply quote ---- */
.km-msg-reply {
  background: rgba(255,255,255,0.06);
  border-left: 3px solid var(--km-accent);
  border-radius: 4px;
  padding: 6px 10px;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--km-text-muted);
  cursor: pointer;
  max-height: 60px;
  overflow: hidden;
}
.km-msg-reply .km-reply-name {
  font-weight: 600;
  color: var(--km-accent);
  font-size: 12px;
  margin-bottom: 2px;
}

/* ---- Media ---- */
.km-msg-media {
  margin-top: 4px;
  max-width: 320px;
}
.km-msg-media img {
  max-width: 100%;
  border-radius: 10px;
  display: block;
  cursor: pointer;
}
.km-msg-media video {
  max-width: 100%;
  border-radius: 10px;
}
.km-msg-media .km-file-attach {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  padding: 10px 12px;
}
.km-file-attach .km-file-icon {
  width: 40px;
  height: 40px;
  background: var(--km-accent-dim);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.km-file-attach .km-file-icon svg {
  width: 20px;
  height: 20px;
  color: var(--km-accent);
}
.km-file-attach .km-file-info {
  flex: 1;
  min-width: 0;
}
.km-file-attach .km-file-name {
  font-size: 13px;
  color: var(--km-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.km-file-attach .km-file-size {
  font-size: 11px;
  color: var(--km-text-dim);
}

/* Sticker */
.km-msg-sticker img {
  max-width: 180px;
  max-height: 180px;
}
.km-msg-sticker .km-msg-bubble {
  background: none !important;
  padding: 0;
}

/* ---- Voice message ---- */
.km-msg-voice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
}
.km-voice-play {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--km-accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.km-voice-play svg {
  width: 16px;
  height: 16px;
  color: #000;
}
.km-voice-wave {
  flex: 1;
  height: 24px;
  display: flex;
  align-items: center;
  gap: 2px;
}
.km-voice-wave .km-bar {
  width: 3px;
  background: var(--km-accent);
  border-radius: 2px;
  transition: height 0.1s ease;
}
.km-voice-dur {
  font-size: 11px;
  color: var(--km-text-muted);
  flex-shrink: 0;
}

/* ---- Reactions ---- */
.km-msg-reactions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}
.km-msg-reactions .km-reaction {
  display: flex;
  align-items: center;
  gap: 3px;
  background: rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 14px;
  cursor: pointer;
  transition: background var(--km-transition);
}
.km-reaction:hover {
  background: rgba(255,255,255,0.12);
}
.km-reaction .km-reaction-count {
  font-size: 11px;
  color: var(--km-text-muted);
}

/* ---- Hover actions ---- */
.km-msg-actions {
  position: absolute;
  top: 4px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 5;
}
.km-msg.incoming .km-msg-actions {
  right: -80px;
}
.km-msg.outgoing .km-msg-actions {
  left: -80px;
}
.km-msg:hover .km-msg-actions {
  opacity: 1;
}
.km-msg-actions .km-action-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--km-text-muted);
  transition: all var(--km-transition);
}
.km-action-btn:hover {
  color: var(--km-accent);
  background: rgba(255,215,0,0.15);
}
.km-action-btn svg {
  width: 14px;
  height: 14px;
}

/* ---- Reaction picker (long-press/hover) ---- */
.km-reaction-picker {
  position: absolute;
  display: none;
  background: var(--km-sidebar-bg);
  border: 1px solid var(--km-border);
  border-radius: 24px;
  padding: 6px 8px;
  box-shadow: var(--km-shadow);
  z-index: 50;
  gap: 4px;
  animation: km-scaleIn 0.15s ease;
}
.km-reaction-picker.show {
  display: flex;
}
@keyframes km-scaleIn {
  from { transform: scale(0.8); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.km-reaction-picker .km-react-emoji {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
}
.km-react-emoji:hover {
  transform: scale(1.25);
  background: rgba(255,255,255,0.08);
}

/* ============================================================
   TYPING INDICATOR
   ============================================================ */
.km-typing-bar {
  display: none;
  padding: 8px 16px 4px;
  font-size: 13px;
  color: var(--km-text-muted);
  flex-shrink: 0;
}
.km-typing-bar.active {
  display: flex;
  align-items: center;
  gap: 8px;
}
.km-typing-dots {
  display: flex;
  gap: 3px;
}
.km-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--km-text-muted);
  animation: km-typingBounce 1.4s infinite;
}
.km-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.km-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes km-typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* ============================================================
   REPLY PREVIEW (above input)
   ============================================================ */
#km-reply-preview {
  display: none;
  padding: 8px 14px;
  background: rgba(255,215,0,0.04);
  border-top: 1px solid var(--km-border);
  border-left: 3px solid var(--km-accent);
  flex-shrink: 0;
}
#km-reply-preview.active {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#km-reply-preview .km-reply-content {
  flex: 1;
  min-width: 0;
}
#km-reply-preview .km-reply-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--km-accent);
}
#km-reply-preview .km-reply-text {
  font-size: 13px;
  color: var(--km-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#km-reply-preview .km-reply-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--km-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: 8px;
}
#km-reply-preview .km-reply-close:hover {
  color: var(--km-danger);
}

/* ============================================================
   INPUT AREA
   ============================================================ */
#km-input-area {
  display: flex;
  align-items: flex-end;
  padding: 10px 16px;
  background: linear-gradient(0deg, var(--km-sidebar-bg) 0%, rgba(18,18,31,0.97) 100%);
  border-top: 1px solid var(--km-border);
  flex-shrink: 0;
  gap: 8px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.km-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--km-text-muted);
  flex-shrink: 0;
  transition: all var(--km-transition);
}
.km-icon-btn:hover {
  color: var(--km-accent);
  background: rgba(255,215,0,0.08);
  box-shadow: 0 0 12px rgba(255,215,0,0.08);
}
.km-icon-btn svg {
  width: 22px;
  height: 22px;
}

#km-message-input {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 22px;
  padding: 10px 18px;
  color: var(--km-text);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  line-height: 1.45;
  outline: none;
  transition: all var(--km-transition);
  overflow-y: auto;
}
#km-message-input:focus {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,215,0,0.2);
  box-shadow: 0 0 0 2px rgba(255,215,0,0.06);
}
#km-message-input::placeholder {
  color: var(--km-text-muted);
  font-weight: 400;
}

.km-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffdb4d 0%, var(--km-accent) 50%, #e6a800 100%);
  border: none;
  cursor: pointer;
  display: none; /* show when text present */
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
  box-shadow: 0 2px 12px rgba(255,215,0,0.3);
}
.km-send-btn.visible {
  display: flex;
}
.km-send-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 20px rgba(255,215,0,0.45);
}
.km-send-btn:active {
  transform: scale(0.92);
  box-shadow: 0 1px 6px rgba(255,215,0,0.2);
}
.km-send-btn svg {
  width: 20px;
  height: 20px;
  color: #000;
}

.km-voice-btn {
  display: flex; /* hide when text present */
}
.km-voice-btn.hidden {
  display: none;
}
.km-voice-btn.recording {
  color: var(--km-danger);
  animation: km-pulse 1s infinite;
}
@keyframes km-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* Attach menu */
.km-attach-menu {
  position: absolute;
  bottom: 60px;
  left: 12px;
  background: var(--km-sidebar-bg);
  border: 1px solid var(--km-border);
  border-radius: var(--km-radius);
  padding: 8px 0;
  box-shadow: var(--km-shadow);
  display: none;
  z-index: 20;
  min-width: 180px;
}
.km-attach-menu.show {
  display: block;
  animation: km-scaleIn 0.15s ease;
}
.km-attach-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  color: var(--km-text);
  font-size: 14px;
  transition: background var(--km-transition);
}
.km-attach-option:hover {
  background: var(--km-hover);
}
.km-attach-option svg {
  width: 20px;
  height: 20px;
  color: var(--km-accent);
}

/* ============================================================
   CHAT — Empty / No chat selected
   ============================================================ */
.km-no-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--km-text-dim);
  text-align: center;
  gap: 16px;
  padding: 40px;
}
.km-no-chat svg {
  width: 72px;
  height: 72px;
  opacity: 0.25;
  color: var(--km-accent);
  filter: drop-shadow(0 0 20px rgba(255,215,0,0.15));
}
.km-no-chat h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--km-text);
  margin: 0;
  letter-spacing: -0.3px;
}
.km-no-chat p {
  font-size: 14px;
  color: var(--km-text-muted);
  margin: 0;
  max-width: 280px;
  line-height: 1.5;
}

/* ============================================================
   INFO PANEL (slide-in right)
   ============================================================ */
#kupr-msg-info .km-info-header {
  padding: 20px;
  text-align: center;
  border-bottom: 1px solid var(--km-border);
}
#kupr-msg-info .km-info-header img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 10px;
}
#kupr-msg-info .km-info-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--km-text);
}
#kupr-msg-info .km-info-status {
  font-size: 13px;
  color: var(--km-text-muted);
}
.km-info-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--km-border);
}
.km-info-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--km-accent);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.km-info-action {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  cursor: pointer;
  color: var(--km-text);
  font-size: 14px;
}
.km-info-action:hover {
  color: var(--km-accent);
}
.km-info-action.danger {
  color: var(--km-danger);
}
.km-info-action svg {
  width: 20px;
  height: 20px;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
#km-chat-list::-webkit-scrollbar,
#km-messages-area::-webkit-scrollbar {
  width: 5px;
}
#km-chat-list::-webkit-scrollbar-track,
#km-messages-area::-webkit-scrollbar-track {
  background: transparent;
}
#km-chat-list::-webkit-scrollbar-thumb,
#km-messages-area::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
}
#km-chat-list::-webkit-scrollbar-thumb:hover,
#km-messages-area::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.2);
}

/* Firefox */
#km-chat-list,
#km-messages-area {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

/* ============================================================
   DESKTOP â€” Force sidebar visible (overrides any mobile .hidden state)
   ============================================================ */
@media (min-width: 769px) {
  #kupr-msg-sidebar {
    display: flex !important;
    transform: none !important;
    position: relative !important;
    width: var(--km-sidebar-w) !important;
    min-width: var(--km-sidebar-w) !important;
  }
  .km-back-btn {
    display: none !important; /* hide mobile back button on desktop */
  }
}

/* ============================================================
   MOBILE RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  #kupr-msg-app {
    height: calc(100vh - 50px - 56px) !important; /* navbar=50px, bottom-nav=56px */
  }

  #kupr-msg-sidebar {
    width: 100%;
    min-width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 20;
    transition: transform 0.25s ease;
  }
  #kupr-msg-sidebar.km-sidebar-hidden {
    transform: translateX(-100%) !important;
    visibility: hidden !important;
  }
  /* Safety: if Bootstrap .hidden was added somehow, override it on mobile too */
  #kupr-msg-sidebar.hidden {
    transform: translateX(-100%) !important;
    visibility: hidden !important;
    display: flex !important; /* keep in layout flow â€” hide via transform, not display */
  }

  #kupr-msg-chat {
    width: 100%;
  }

  .km-back-btn {
    display: flex;
  }

  .km-msg {
    max-width: 85%;
  }

  .km-msg-actions {
    display: none; /* use long-press on mobile */
  }

  #km-input-area {
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .km-chat-name {
    max-width: 140px;
  }
  .km-chat-preview {
    max-width: 160px;
  }

  #kupr-msg-info {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 25;
    border-left: none;
    box-shadow: -4px 0 20px rgba(0,0,0,0.5);
  }
  #kupr-msg-info.open {
    width: 85%;
  }
}

@media (max-width: 480px) {
  .km-avatar {
    width: 44px;
    height: 44px;
  }
  .km-avatar img {
    width: 44px;
    height: 44px;
  }
  .km-msg-media {
    max-width: 260px;
  }
}

/* ============================================================
   DAY MODE OVERRIDES (WoWonder night_mode=0)
   ============================================================ */
body.suspended-night-mode #kupr-msg-app,
body:not([class*="night"]) #kupr-msg-app {
  /* Keep dark for messaging even in day mode for consistency */
}

/* ============================================================
   UTILITIES
   ============================================================ */
.km-hidden { display: none !important; }
.km-flex { display: flex; }
.km-flex-center { display: flex; align-items: center; justify-content: center; }
.km-truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* File upload hidden input */
#km-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Loading spinner */
.km-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--km-text-dim);
  border-top-color: var(--km-accent);
  border-radius: 50%;
  animation: km-spin 0.8s linear infinite;
}
@keyframes km-spin {
  to { transform: rotate(360deg); }
}

/* Voice recording overlay */
.km-recording-overlay {
  display: none;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--km-input-h);
  background: var(--km-sidebar-bg);
  border-top: 1px solid var(--km-border);
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 15;
}
.km-recording-overlay.active {
  display: flex;
}
.km-rec-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--km-danger);
  animation: km-pulse 1s infinite;
}
.km-rec-timer {
  font-size: 14px;
  color: var(--km-text);
  font-variant-numeric: tabular-nums;
}
.km-rec-cancel {
  color: var(--km-text-muted);
  font-size: 13px;
  cursor: pointer;
  margin-left: auto;
}
