* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f0f4f8;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

#chat-wrapper {
  width: 100%;
  max-width: 800px;
  height: 90vh;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#chat-header {
  background: #1a3a5c;
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

#chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #2e75b6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}

#chat-info {
  flex: 1;
}

#chat-name {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

#chat-status {
  font-size: 12px;
  opacity: 0.75;
  margin-top: 2px;
}

/* ── Status dot ── */
#status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  transition: background 0.3s;
}

.status-green {
  background: #4ade80;
  box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6);
  animation: pulse-green 2.5s infinite;
}

.status-yellow {
  background: #fbbf24;
  box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.6);
  animation: pulse-yellow 1s infinite;
}

.status-red {
  background: #f87171;
  box-shadow: none;
  animation: none;
}

@keyframes pulse-green {
  0%   { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6); }
  70%  { box-shadow: 0 0 0 6px rgba(74, 222, 128, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

@keyframes pulse-yellow {
  0%   { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.7); }
  70%  { box-shadow: 0 0 0 5px rgba(251, 191, 36, 0); }
  100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0); }
}

/* ── Clear button ── */
#clear-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  color: white;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
  margin-left: auto;
}

#clear-btn:hover { background: rgba(255,255,255,0.22); }

/* ── Messages ── */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user {
  background: #1a3a5c;
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.message.agent {
  background: #f0f4f8;
  color: #1a1a2e;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.message.typing {
  background: #f0f4f8;
  align-self: flex-start;
  padding: 14px 18px;
}

.typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  background: #2e75b6;
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}

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

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

/* ── File preview ── */
#file-preview {
  background: #e8f0f8;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #1a3a5c;
}

#file-name { flex: 1; font-weight: 500; }

#file-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: #666;
  font-size: 16px;
  padding: 0 4px;
}

/* ── Input area ── */
#chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid #e8ecf0;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: white;
}

#file-label {
  cursor: pointer;
  color: #2e75b6;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s;
  flex-shrink: 0;
}

#file-label:hover { background: #e8f0f8; }

#chat-input {
  flex: 1;
  border: 1px solid #dde3ea;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  resize: none;
  outline: none;
  font-family: inherit;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.5;
  transition: border-color 0.2s;
}

#chat-input:focus { border-color: #2e75b6; }

#send-btn {
  background: #1a3a5c;
  color: white;
  border: none;
  border-radius: 10px;
  width: 42px;
  height: 42px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}

#send-btn:hover { background: #2e75b6; }
#send-btn:disabled { background: #ccc; cursor: not-allowed; }

/* ── Confirm overlay ── */
#confirm-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 10;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
}

#confirm-overlay.visible { display: flex; }

#confirm-box {
  background: white;
  border-radius: 12px;
  padding: 24px 28px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  max-width: 280px;
}

#confirm-box p {
  font-size: 15px;
  color: #1a1a2e;
  margin-bottom: 20px;
  line-height: 1.5;
}

#confirm-box div {
  display: flex;
  gap: 10px;
  justify-content: center;
}

#confirm-yes {
  background: #dc2626;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 22px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

#confirm-yes:hover { background: #b91c1c; }

#confirm-no {
  background: #f0f4f8;
  color: #1a1a2e;
  border: none;
  border-radius: 8px;
  padding: 8px 22px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

#confirm-no:hover { background: #dde3ea; }

#chat-wrapper { position: relative; }

@media (max-width: 600px) {
  body { padding: 0; }
  #chat-wrapper { height: 100vh; border-radius: 0; }
  #confirm-overlay { border-radius: 0; }
  .message { max-width: 88%; }
}
