/* Tela de atendimento (briefing, Fase 8) — CSS puro, sem preprocessador
   nem framework (mesma decisão de "sem build step" do resto do front). */

:root {
  --bg: #f0f2f5;
  --panel: #ffffff;
  --border: #e2e5e9;
  --text: #111b21;
  --text-muted: #667781;
  --accent: #00a884;
  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --error: #d32f2f;
  --unread: #00a884;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* ---------- Login ---------- */

body.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--panel);
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  padding: 32px;
  width: 320px;
  max-width: 90vw;
}

.login-card h1 {
  font-size: 20px;
  margin: 0 0 20px;
}

.login-card label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin: 12px 0 4px;
}

.login-card input {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 15px;
}

.login-card button {
  width: 100%;
  margin-top: 20px;
  padding: 10px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}

.login-error {
  background: #fdecea;
  color: var(--error);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
}

/* ---------- Layout de duas colunas ---------- */

.page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.quality-banner {
  flex-shrink: 0;
  background: #fdecea;
  color: #8a1c1c;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  padding: 8px 16px;
}

.app {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.conversations {
  width: 360px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.conversations__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.conversations__header h1 {
  font-size: 17px;
  margin: 0;
}

.logout-form {
  margin: 0;
}

.logout-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted);
}

.search-input {
  margin: 10px 12px;
  padding: 8px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 14px;
}

.conversation-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}

.conversation-list__empty {
  padding: 24px 16px;
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
}

.conversation-item {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.conversation-item:hover {
  background: var(--bg);
}

.conversation-item--active {
  background: #e9edef;
}

.conversation-item__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.conversation-item__name {
  font-weight: 600;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item__time {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.conversation-item__preview {
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unread-badge {
  background: var(--unread);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  min-width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  flex-shrink: 0;
}

.window-chip {
  display: inline-block;
  margin-top: 4px;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 10px;
}

.window-chip--open {
  background: #e3f6ee;
  color: var(--accent);
}

.window-chip--closed {
  background: #eee;
  color: var(--text-muted);
}

/* ---------- Thread ---------- */

.thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #efeae2;
  overflow: hidden;
}

.thread-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.thread-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.thread__header {
  background: var(--panel);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.back-btn {
  display: none;
  border: none;
  background: none;
  font-size: 18px;
  cursor: pointer;
}

.thread__messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bubble {
  max-width: 65%;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
  position: relative;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
}

.bubble--in {
  align-self: flex-start;
  background: var(--bubble-in);
  border-top-left-radius: 0;
}

.bubble--out {
  align-self: flex-end;
  background: var(--bubble-out);
  border-top-right-radius: 0;
}

.bubble__text {
  margin: 0 0 4px;
  white-space: pre-wrap;
  word-break: break-word;
}

.os-badge {
  display: inline-block;
  background: #d1e7ff;
  color: #0b57d0;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 10px;
  text-decoration: none;
  margin-bottom: 4px;
}

.bubble__image {
  max-width: 100%;
  border-radius: 6px;
  display: block;
}

.bubble__file {
  display: inline-block;
  color: #0b57d0;
  font-size: 13px;
  text-decoration: underline;
}

.bubble__pending {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

.bubble__meta {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.bubble__error {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--error);
  font-weight: 600;
}

/* ---------- Composer ---------- */

.composer {
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding: 10px 16px;
}

.composer__error {
  color: var(--error);
  font-size: 13px;
  margin: 0 0 6px;
}

.composer__row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.composer__closed-notice {
  flex: 1;
  margin: 0;
  padding: 10px 12px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.4;
}

.composer__text {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 14px;
}

.composer__send {
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 20px;
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
}

.composer__send:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ---------- Responsivo (briefing: "janela de 380px de largura") ---------- */

@media (max-width: 720px) {
  .conversations {
    width: 100%;
    border-right: none;
  }

  .app {
    position: relative;
  }

  .conversations,
  .thread {
    width: 100%;
  }

  /* Num telão só cabe uma coluna por vez — alterna lista/thread em vez
     de espremer as duas (o briefing pede "continua utilizável no
     celular", não as duas colunas lado a lado). */
  .conversations--hidden-mobile {
    display: none;
  }

  /* Sem position:fixed aqui: com `.conversations--hidden-mobile`
     tirando a lista do fluxo flex, `.thread` (flex:1, regra base) já
     ocupa sozinha o espaço inteiro de `.app` — inclusive respeitando o
     banner de qualidade acima, que um `position:fixed` cobriria. */

  .thread--hidden-mobile {
    display: none;
  }

  .back-btn {
    display: inline-block;
  }

  .bubble {
    max-width: 85%;
  }
}
