/* public/styles.css (Updated) */
:root {
  --vh: 1vh;
  --bg: #F9F9FF;
  --card: #fff;
  --my-bubble: #A294F9;
  --other-bubble: #B3D4FF;
  --text: #0F1720;
  --muted: #6B7280;
  --radius: 18px;
  --shadow: 0 4px 14px rgba(0,0,0,0.08);
}

/* --- Basic Setup & Mobile Viewport Fix --- */
* { box-sizing: border-box; }
html, body {
  height: 100%; margin: 0;
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  overscroll-behavior: none;
  overflow: hidden;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  color: var(--text);
}

/* --- App Layout & View Switching --- */
#app {
  display: flex;
  flex-direction: column;
  height: calc(var(--vh, 1vh) * 100);
  min-height: 100svh;
  background: var(--bg);
}
.chat-page {
  display: none; /* Hide pages by default */
  flex-direction: column;
  height: 100%;
}
/* Show the active page based on the data-view attribute */
#app[data-view="public"] #public-chat-page,
#app[data-view="dm"] #dm-chat-page {
  display: flex;
}

/* --- Topbar --- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; background: var(--my-bubble); color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  position: sticky; top: 0; z-index: 30;
}
.topbar .title { font-size: 44px; font-weight: 800; font-family: 'DynaPuff', cursive; }
.topbar .subtitle { font-size: 22px; opacity: 0.95; margin-top: 2px; }
.topbar-left, .topbar-right { min-width: 44px; display: flex; justify-content: center; }
.topbar-center { flex: 1; text-align: center; }
.icon-btn {
  background: transparent; border: none; color: inherit;
  padding: 6px; border-radius: 10px; cursor: pointer; font-size: 20px;
  display: inline-flex; align-items: center; justify-content: center;
}
#dm-back-btn { font-size: 24px; }

/* --- Chat Area --- */
.chat-container {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain; padding: 14px 12px;
  display: flex; flex-direction: column;
}
#public-chat-list, #dm-chat-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 10px;
}
.message {
  display: block; position: relative; max-width: 78%;
  padding: 10px 14px; border-radius: var(--radius);
  font-size: 22px; line-height: 1.35; word-break: break-word;
  box-shadow: var(--shadow); font-weight: 500;
}
.message.received {
  align-self: flex-start; background: var(--other-bubble); color: var(--text);
  border-bottom-left-radius: 6px;
}
.message.sent {
  align-self: flex-end; background: var(--my-bubble); color: #fff;
  border-bottom-right-radius: 6px;
}
.message .text { white-space: pre-wrap; }
.message .meta { display: block; font-size: 14px; color: #fff; margin-top: 8px; opacity: 0.9; }
.message.received .meta { color: var(--muted); }
.message.sending { opacity: 0.8; }
.user-id-btn {
  background: rgba(0,0,0,0.05); border: none; padding: 4px 8px; border-radius: 8px;
  cursor: pointer; font-weight: 600; font-size: 13px; margin-bottom: 6px;
  display: block; color: var(--text);
}
.message.sent .user-id-btn { display: none; }

/* ✨ --- IMAGE BLUR STYLES (RESTORED) --- ✨ */
.message img.chat-image {
  max-width: 100%; max-height: 40vh; width: auto; height: auto;
  border-radius: var(--radius); cursor: pointer; display: block;
  margin-top: 8px; object-fit: contain;
}
.message img.blurred {
  filter: blur(12px);
  transition: filter 0.2s ease;
}
.message img.unblurred {
  filter: none; /* This class isn't strictly needed but can be useful */
}

/* --- Composer --- */
.composer-form {
  position: sticky; bottom: 0; z-index: 40; display: flex; gap: 8px;
  padding: 10px; border-top: 1px solid rgba(2,6,23,0.04);
  background: var(--card); align-items: flex-end;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
}
.msg-input {
  flex: 1; min-height: 44px; max-height: 140px; padding: 10px 12px;
  border-radius: 12px; border: 1px solid #e6edf3; font-size: 16px;
  resize: none; background: #fff;
}
.msg-input:focus { outline: none; border-color: var(--my-bubble); }
.send-btn {
  border: none; background: var(--my-bubble); color: #fff; font-weight: 700;
  padding: 10px 14px; border-radius: 10px; cursor: pointer;
}
.send-btn:disabled { background: rgba(162,148,249,0.45); cursor: default; }

/* --- DM Panel --- */
.dm-panel {
  position: fixed; right: 12px; top: 72px; width: 280px;
  max-width: 90%; background: var(--card);
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
  border-radius: 12px; padding: 12px; transform: translateY(-10px);
  opacity: 0; pointer-events: none;
  transition: transform .18s ease, opacity .18s ease; z-index: 60;
}
.dm-panel.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
.dm-panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.dm-panel-section h4 { margin: 12px 0 6px 0; font-size: 14px; }
.dm-threads {
  max-height: 40vh; overflow: auto; padding: 6px; gap: 6px;
  display: flex; flex-direction: column;
}
.dm-thread {
  padding: 8px; border-radius: 10px; background: #f4f4f5;
  cursor: pointer; display: flex; justify-content: space-between; align-items: center;
}
.dm-thread-meta { font-size: 12px; color: var(--muted); }
.dm-empty { font-size: 13px; color: var(--muted); padding: 8px; }

@media (max-width:600px) {
  .topbar .title { font-size: 24px; }
  .topbar .subtitle { font-size: 14px; }
  .message { font-size: 16px; }
}