* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #e5ddd5;
  color: #111b21;
}
.hidden { display: none !important; }

/* Login */
.login-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #075e54, #128c7e);
}
.login-card {
  background: #fff;
  padding: 40px 32px;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-card h1 {
  margin: 0;
  font-size: 22px;
  color: #075e54;
  text-align: center;
}
.login-card .subtitle {
  margin: 0 0 8px;
  text-align: center;
  color: #667781;
  font-size: 13px;
}
.login-card input {
  padding: 12px 14px;
  border: 1px solid #d1d7db;
  border-radius: 8px;
  font-size: 14px;
}
.login-card button {
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: #00a884;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.login-card button:hover { background: #06997a; }
.login-card .error { color: #d9534f; font-size: 13px; text-align: center; min-height: 16px; margin: 0; }

/* App layout */
.app-screen {
  display: flex;
  height: 100vh;
}
.sidebar {
  width: 340px;
  min-width: 280px;
  background: #fff;
  border-right: 1px solid #d1d7db;
  display: flex;
  flex-direction: column;
}
.sidebar-header {
  background: #075e54;
  color: #fff;
  padding: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-header button {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}
.sidebar-header button:hover { background: rgba(255,255,255,0.25); }

.contact-list { overflow-y: auto; flex: 1; }
.contact-item {
  padding: 12px 16px;
  border-bottom: 1px solid #f0f2f5;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.contact-item:hover { background: #f5f6f6; }
.contact-item.active { background: #e9edef; }
.contact-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.contact-name { font-weight: 600; font-size: 14.5px; }
.contact-time { font-size: 11.5px; color: #667781; }
.contact-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.contact-preview {
  font-size: 13px;
  color: #667781;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.channel-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
  white-space: nowrap;
}
.channel-badge.oficial { background: #d9fdd3; color: #075e54; }
.channel-badge.segundo { background: #e2e8ff; color: #3949ab; }
.channel-badge.desconhecido { background: #eee; color: #666; }

.thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Crect width='60' height='60' fill='%23e5ddd5'/%3E%3C/svg%3E");
}
.thread-header {
  background: #f0f2f5;
  padding: 16px 20px;
  font-weight: 600;
  border-bottom: 1px solid #d1d7db;
}
.thread-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bubble {
  max-width: 60%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 1px rgba(0,0,0,0.08);
  position: relative;
}
.bubble.in {
  align-self: flex-start;
  background: #fff;
  border-top-left-radius: 2px;
}
.bubble.out {
  align-self: flex-end;
  background: #d9fdd3;
  border-top-right-radius: 2px;
}
.bubble .meta {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  align-items: center;
  margin-top: 3px;
  font-size: 10.5px;
  color: #667781;
}
.ticks { display: inline-flex; }
.ticks svg { width: 15px; height: 11px; }
.tick-gray path { fill: #8696a0; }
.tick-blue path { fill: #53bdeb; }
.tick-fail { color: #d9534f; font-weight: 700; }

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #667781;
  font-size: 14px;
}
