:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d9e1ec;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --danger: #b42318;
  --success: #067647;
}

@font-face {
  font-family: "Vazirmatn";
  src: url("/static/Vazirmatn[wght].woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  font-family: "Vazirmatn", Tahoma, sans-serif;
  color: var(--text);
  background: var(--bg);
  direction: rtl;
  /* The app shell owns scrolling so the page does not exceed the viewport. */
  overflow: hidden;
}

button,
input {
  font: inherit;
}

.shell {
  width: min(1040px, calc(100% - 24px));
  margin: 0 auto;
  height: 100vh;
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1.35;
}

.subtitle {
  margin-bottom: 0;
  color: var(--muted);
}

.status-pill {
  min-width: 86px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff1f3;
  color: var(--danger);
  text-align: center;
  white-space: nowrap;
}

.status-pill.connected {
  color: var(--success);
  background: #ecfdf3;
  border-color: #abefc6;
}

.layout {
  /* Allows the chat and users panels to shrink and scroll inside the viewport. */
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
}

.panel {
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.setup-panel {
  padding: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.setup-panel h2,
.chat-header h2 {
  margin-bottom: 12px;
}

label {
  display: block;
  margin: 14px 0 7px;
  color: var(--muted);
  font-size: 0.92rem;
}

input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  color: var(--text);
  background: #ffffff;
}

input:focus {
  border-color: var(--accent);
}

input:disabled {
  opacity: 0.55;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 11px 14px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button.secondary,
button.ghost {
  color: var(--text);
  background: #eef2f7;
  border: 1px solid var(--line);
}

button.ghost {
  padding: 9px 12px;
}

.hint {
  margin-top: 16px;
  padding: 12px;
  border-radius: 8px;
  color: #344054;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  line-height: 1.5;
}

.online-box {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.online-box h3 {
  margin-bottom: 10px;
  font-size: 1rem;
}

ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

#usersList {
  min-height: 0;
  /* Long user lists scroll here instead of making the page taller. */
  overflow-y: auto;
}

li {
  padding: 8px 0;
  border-bottom: 1px solid #eef2f7;
}

.muted {
  color: var(--muted);
}

.chat-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  padding: 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.chat-header p {
  margin-bottom: 0;
  color: var(--muted);
}

.messages {
  min-height: 0;
  flex: 1;
  padding: 18px;
  /* Chat history scrolls inside the chat panel. */
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fbfcfe;
}

.empty-state {
  margin: auto;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.message {
  max-width: 78%;
  padding: 11px 13px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--line);
}

.message.mine {
  align-self: flex-start;
  background: #eff6ff;
  border-color: #bfdbfe;
}

.message.system {
  align-self: center;
  max-width: 90%;
  color: #344054;
  background: #f2f4f7;
}

.message-meta {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.message-content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.message-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .shell {
    min-height: 100vh;
    height: auto;
    overflow: visible;
  }

  .header {
    flex-direction: column;
    align-items: stretch;
  }

  .layout {
    grid-template-columns: 1fr;
    flex: none;
  }

  .chat-panel {
    height: min(560px, calc(100vh - 24px));
  }

  .setup-panel {
    max-height: 42vh;
  }

  .message {
    max-width: 92%;
  }
}
