* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0b141a;
  font-family: "Segoe UI", Helvetica, Arial, sans-serif;
}

.phone {
  position: relative;
  width: 100%;
  max-width: 460px;
  height: 100vh;
  max-height: 900px;
  display: flex;
  flex-direction: column;
  background: #efeae2;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

@media (min-width: 500px) {
  .phone {
    height: 90vh;
    border-radius: 12px;
  }
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #075e54;
  color: #fff;
  padding: 10px 16px;
  flex-shrink: 0;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  flex-shrink: 0;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: left center;
}

.contact-name {
  font-size: 16px;
  font-weight: 600;
}

.contact-status {
  font-size: 12px;
  color: #d9fdd3;
}

.panel-toggle {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.85;
  padding: 4px;
  display: flex;
}

.panel-toggle:hover {
  opacity: 1;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 8%;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background-color: #efeae2;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.35)),
    repeating-linear-gradient(45deg, rgba(0,0,0,0.02) 0 2px, transparent 2px 40px),
    repeating-linear-gradient(-45deg, rgba(0,0,0,0.02) 0 2px, transparent 2px 40px);
}

.bubble-row {
  display: flex;
  margin: 3px 0;
}

.bubble-row.user { justify-content: flex-end; }
.bubble-row.assistant { justify-content: flex-start; }

.bubble {
  max-width: 78%;
  padding: 7px 9px 8px 9px;
  border-radius: 8px;
  font-size: 14.2px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-wrap: break-word;
  position: relative;
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

.bubble.user {
  background: #d9fdd3;
  border-top-right-radius: 0;
}

.bubble.assistant {
  background: #fff;
  border-top-left-radius: 0;
}

.bubble .timestamp {
  display: block;
  text-align: right;
  font-size: 10.5px;
  color: #667781;
  margin-top: 3px;
  margin-left: 8px;
  float: right;
}

.typing-dots {
  display: inline-flex;
  gap: 3px;
  padding: 4px 2px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9aa5aa;
  animation: typing-bounce 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #f0f2f5;
  flex-shrink: 0;
}

#text-input {
  flex: 1;
  padding: 10px 16px;
  border-radius: 21px;
  border: none;
  outline: none;
  font-size: 14.5px;
  background: #fff;
}

.composer button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #00a884;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

/* Painel interno retrátil — simula o que a equipe da CoopAnest veria
   quando um atendimento é encaminhado. Escondido por padrão; abre com o
   botão no cabeçalho, nunca aparece sozinho pro paciente. */
.panel-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 5;
}

.panel-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.team-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 85%;
  max-width: 340px;
  background: #f7f4f0;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.25);
  transform: translateX(100%);
  transition: transform 0.28s ease;
  z-index: 6;
  display: flex;
  flex-direction: column;
}

.team-panel.open {
  transform: translateX(0);
}

.team-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  background: #128c7e;
  color: #fff;
  padding: 14px 16px;
}

.team-panel-title {
  font-size: 15px;
  font-weight: 600;
}

.team-panel-subtitle {
  font-size: 11.5px;
  color: #d9fdd3;
  margin-top: 3px;
  line-height: 1.3;
}

.panel-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
  flex-shrink: 0;
}

.handoff-list {
  list-style: none;
  margin: 0;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.handoff-card {
  background: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  border-left: 3px solid #25d366;
}

.handoff-card.needs-attention {
  border-left-color: #e8622c;
}

.handoff-card .handoff-name {
  font-weight: 600;
  font-size: 14px;
  color: #111b21;
}

.handoff-card .handoff-meta {
  font-size: 12px;
  color: #667781;
  margin-top: 2px;
}

.handoff-card .handoff-tag {
  display: inline-block;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #075e54;
  background: #d9fdd3;
  border-radius: 10px;
  padding: 2px 8px;
}

.handoff-card.needs-attention .handoff-tag {
  color: #a13e0f;
  background: #fde3d3;
}

.handoff-empty {
  padding: 24px 20px;
  text-align: center;
  color: #667781;
  font-size: 13px;
  line-height: 1.5;
}
