/* ── Chat Panel Components ── */

.chat-panel-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.chat-header {
  padding: 14px 16px;
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-back-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  line-height: 1;
  transition: color .15s;
}

.chat-back-btn .material-symbols-outlined {
  font-size: 20px;
}

.chat-back-btn:hover {
  color: var(--primary);
}

.chat-header-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 240px;
  display: inline-block;
  vertical-align: bottom;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.chat-empty, .chat-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text3);
  font-size: 14px;
  text-align: center;
  padding: 20px;
}

.chat-bubble {
  max-width: 80%;
  padding: 8px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
  position: relative;
}

.chat-bubble-self {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-bubble-other {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.chat-bubble-author {
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 2px;
}

.chat-bubble-self .chat-bubble-author {
  color: rgba(255,255,255,0.75);
}

.chat-bubble-other .chat-bubble-author {
  color: var(--primary);
}

.chat-bubble-body {
  white-space: pre-wrap;
}

.chat-bubble-body.wb-note-content {
  white-space: normal;
}

/* Override note markdown colors for self-bubbles (primary background) */
.chat-bubble-self .wb-note-content a { color: #a5b4fc; }
.chat-bubble-self .wb-note-content code { background: rgba(255,255,255,0.15); color: #f9a8d4; }
.chat-bubble-self .wb-note-content pre { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.2); }
.chat-bubble-self .wb-note-content pre code { background: none; color: #fff; }
.chat-bubble-self .wb-note-content blockquote { border-left-color: #a5b4fc; background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.85); }
.chat-bubble-self .wb-note-content h1,
.chat-bubble-self .wb-note-content h2 { border-bottom-color: rgba(255,255,255,0.3); }
.chat-bubble-self .wb-note-content th { background: rgba(255,255,255,0.15); color: #fff; }
.chat-bubble-self .wb-note-content td,
.chat-bubble-self .wb-note-content th { border-color: rgba(255,255,255,0.2); }
.chat-bubble-self .wb-note-content tr:nth-child(even) { background: rgba(255,255,255,0.05); }
.chat-bubble-self .wb-note-content hr { border-top-color: rgba(255,255,255,0.3); }
.chat-bubble-self .wb-note-content s { opacity: 0.5; }

.chat-bubble-time {
  font-size: 10px;
  color: var(--text3);
  margin-top: 4px;
  text-align: right;
}

.chat-bubble-self .chat-bubble-time {
  color: rgba(255,255,255,0.6);
}

.chat-bubble-actions {
  display: none;
  position: absolute;
  top: 2px;
  right: 6px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  letter-spacing: 1px;
  color: inherit;
  opacity: 0.6;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
}

.chat-bubble-self:hover .chat-bubble-actions {
  display: block;
}

.chat-bubble-actions:hover {
  opacity: 1;
  background: rgba(255,255,255,0.15);
}

.chat-bubble-menu {
  position: absolute;
  top: 24px;
  right: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px var(--shadow);
  z-index: 50;
  overflow: hidden;
  min-width: 100px;
}

.chat-bubble-menu-item {
  display: block;
  width: 100%;
  padding: 8px 16px;
  border: none;
  background: none;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  transition: background .15s;
  font-family: inherit;
}

.chat-bubble-menu-item:hover {
  background: var(--bg3);
}

.chat-bubble-menu-delete {
  color: var(--danger);
}

.chat-bubble-editing {
  padding: 4px;
}

.chat-bubble-edit-input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--primary);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  line-height: 1.4;
  resize: none;
  overflow: hidden;
  outline: none;
  box-sizing: border-box;
}

.chat-input-area {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  position: relative;
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  resize: none;
  outline: none;
  max-height: 80px;
  font-family: inherit;
  line-height: 1.4;
}

.chat-input:focus {
  border-color: var(--primary);
}

.chat-emoji-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
  flex-shrink: 0;
  padding: 0;
}

.chat-emoji-btn:hover {
  background: var(--bg3);
}

.chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  transition: opacity .2s;
}

.chat-send-btn:active {
  opacity: 0.7;
}

.emoji-picker {
  position: absolute;
  bottom: 100%;
  left: 12px;
  margin-bottom: 4px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px var(--shadow);
  z-index: 100;
  max-height: 200px;
  overflow-y: auto;
}

.emoji-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background .15s;
  padding: 0;
}

.emoji-btn:hover {
  background: var(--bg3);
}
