/* Mensageiro — usa apenas variáveis de tema */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* Logo (themes.css já estiliza .themes-logo) */

/* Language + theme switch always first on screen, even though themes.py puts the logo right after <body> */
.topbar {
  order: -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}

.brand h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.version {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

select[data-theme-picker], select[data-lang-picker] {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  font-size: 0.9rem;
}

/* Buttons */
.btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  font-size: 0.95rem;
}
.btn:hover { filter: brightness(1.08); }
.btn.primary {
  background: var(--primary);
  color: var(--on-primary);
  border-color: transparent;
}
.btn.ghost { background: transparent; }
.btn.small { padding: 0.2rem 0.5rem; font-size: 1rem; }

/* Layout */
#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel.center {
  max-width: 420px;
  margin: 3rem auto;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-align: center;
}

.panel h2 { margin-top: 0; }
.muted { color: var(--text-muted); }
.error { color: var(--danger); }

#login-form {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-top: 1rem;
}

input[type="text"] {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.55rem 0.7rem;
  font-size: 1rem;
  width: 100%;
}
input:focus { outline: 2px solid var(--focus); outline-offset: 1px; }

/* Chat layout */
.chat-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  flex: 1;
  min-height: 0;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid var(--border);
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.5rem;
  cursor: pointer;
}
.tab.active {
  color: var(--text);
  border-bottom: 2px solid var(--primary);
}

.list {
  list-style: none;
  margin: 0;
  padding: 0.3rem 0;
  overflow-y: auto;
  flex: 1;
}
.list li {
  padding: 0.45rem 0.8rem;
  cursor: pointer;
  border-radius: 4px;
  margin: 0 0.3rem;
}
.list li:hover, .list li.active {
  background: var(--surface-2);
}
.list.small { flex: 0; max-height: 180px; }
.online { border-top: 1px solid var(--border); padding-top: 0.4rem; }
.online h4 { margin: 0.3rem 0.8rem; font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; }

.conversation {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
}

.conv-header {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.conv-header h2 { margin: 0; font-size: 1.1rem; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.msg {
  max-width: 75%;
  padding: 0.45rem 0.7rem;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  word-wrap: break-word;
}
.msg.own {
  align-self: flex-end;
  background: var(--primary);
  color: var(--on-primary);
  border-color: transparent;
}
.msg .meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}
.msg.own .meta { color: color-mix(in srgb, var(--on-primary) 70%, transparent); }

.composer {
  display: flex;
  gap: 0.5rem;
  padding: 0.7rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.composer input { flex: 1; }

/* Dialog */
dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.2rem;
  max-width: 380px;
}
dialog::backdrop { background: color-mix(in srgb, var(--bg) 70%, transparent); }
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}
#room-form { display: flex; flex-direction: column; gap: 0.6rem; }

.list li.empty { cursor: default; font-size: 0.85rem; }
.list li.empty:hover { background: transparent; }
.list li.me { cursor: default; color: var(--text-muted); }
#conv-topic.warn { color: var(--warning); }
.top-actions { flex-wrap: wrap; justify-content: flex-end; }

/* Responsive */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; }
  .top-actions select { max-width: 46vw; }
  .chat-layout { grid-template-columns: 1fr; }
  .sidebar { max-height: 40dvh; }
  .msg { max-width: 90%; }
}
