/* styles.css */

/* --- Base layout --- */
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f6fb;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

.chat-container {
  background: #ffffff;
  width: 100%;
  max-width: 480px;
  height: 90vh;
  border-radius: 24px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* --- Header --- */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: #fff;
}

.santa-avatar {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: #fff;
  position: relative;
  overflow: hidden;
}

.santa-avatar::before {
  content: "🎅";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
}

.chat-header-text {
  flex: 1;
}

.chat-header-text h1 {
  margin: 0;
  font-size: 1.2rem;
}

.chat-header-text .status {
  margin: 2px 0 0;
  font-size: 0.8rem;
  opacity: 0.9;
}

/* Header actions */
.chat-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.header-btn {
  font-size: 0.75rem;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(243, 244, 246, 0.8);
  background: rgba(248, 250, 252, 0.95);
  cursor: pointer;
  color: #111827;
}

.header-btn.secondary {
  background: rgba(248, 250, 252, 0.7);
}

.header-btn:hover {
  background: #e5e7eb;
}

.hidden {
  display: none !important;
}

/* Caller selector in header */
.caller-selector {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-right: 8px;
  font-size: 0.75rem;
}

.caller-selector label {
  color: #fee2e2;
}

.caller-selector select {
  font-size: 0.8rem;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #fecaca;
  background: #fff;
}

/* --- Messages area --- */
.messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  background: radial-gradient(circle at top, #fee2e2 0, #f9fafb 42%, #eef2ff 100%);
}

.message {
  max-width: 80%;
  padding: 10px 12px;
  border-radius: 16px;
  margin-bottom: 8px;
  font-size: 0.9rem;
  line-height: 1.4;
  word-wrap: break-word;
}

.message.santa {
  background: #fef3c7;
  border-bottom-left-radius: 4px;
}

.message.user {
  background: #e0f2fe;
  border-bottom-right-radius: 4px;
  margin-left: auto;
}

/* Offline state message */
.offline-text {
  text-align: center;
  font-size: 0.95rem;
  color: #4b5563;
  margin-bottom: 12px;
}

.offline-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 40px;
}

.offline-text {
  text-align: center;
  font-size: 0.95rem;
  color: #4b5563;
  margin: 0;
}

.offline-btn {
  padding: 12px 28px;
  font-size: 0.95rem;
  border-radius: 999px;
}


/* --- Chat input --- */
.chat-input {
  padding: 10px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  background: #f9fafb;
}

.chat-input input[type="text"] {
  flex: 1;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  font-size: 0.9rem;
  font-family: inherit;
}

.chat-input button {
  border-radius: 999px;
  border: none;
  padding: 10px 14px;
  margin-left: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}

.chat-input #sendBtn {
  background: #2563eb;
  color: #fff;
}

.chat-input #sendBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Mic button */
.mic-button {
  background: #10b981;
  color: white;
  border-radius: 999px;
  width: 48px;
  height: 48px;
  border: none;
  font-size: 20px;
  cursor: pointer;
  margin-left: 10px;
  transition: transform 0.2s ease;
}

.mic-button.recording {
  background: red;
  color: white;
  transform: scale(1.15);
}

/* --- Modal --- */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
}

.modal-content {
  position: relative;
  z-index: 60;
  background: #ffffff;
  border-radius: 16px;
  padding: 20px 24px;
  width: 100%;
  max-width: 380px;
  max-height: 90vh;     /* NEW: keep it inside the viewport */
  overflow-y: auto;     /* NEW: scroll if content is tall */
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  box-sizing: border-box;
}


.modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  border: none;
  background: transparent;
  font-size: 1.1rem;
  cursor: pointer;
}

/* --- Auth views --- */
.auth-view {
  display: block;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  color: #4b5563;
}

.auth-form input,
.auth-form textarea {
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  font-size: 0.9rem;
  font-family: inherit;
}

.auth-form textarea {
  resize: vertical;
}

.primary-btn {
  border: none;
  border-radius: 999px;
  padding: 10px 14px;
  background: #2563eb;
  color: #ffffff;
  font-size: 0.9rem;
  cursor: pointer;
  margin-top: 6px;
}

.primary-btn:hover {
  background: #1d4ed8;
}

.secondary-btn {
  border-radius: 999px;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  font-size: 0.8rem;
  cursor: pointer;
}

.secondary-btn:hover {
  background: #e5e7eb;
}

.link-btn {
  border: none;
  background: transparent;
  color: #2563eb;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
}

.link-btn.danger {
  color: #b91c1c;
}

.auth-switch {
  margin-top: 10px;
  font-size: 0.8rem;
  color: #4b5563;
}

.auth-error {
  margin-top: 8px;
  font-size: 0.8rem;
  color: #b91c1c;
}

.auth-success {
  margin-top: 8px;
  font-size: 0.8rem;
  color: #15803d;
}

.password-rules {
  font-size: 0.75rem;
  color: #6b7280;
}

.verify-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.subtext {
  font-size: 0.8rem;
  color: #6b7280;
  margin-top: 4px;
}

/* --- Multi-caller profile styles --- */
.caller-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.caller-pill {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f3f4f6;
  font-size: 0.8rem;
}

.caller-pill span {
  font-weight: 500;
}

.caller-pill button {
  border: none;
  background: transparent;
  font-size: 0.75rem;
  color: #2563eb;
  cursor: pointer;
}

.profile-divider {
  margin: 12px 0;
  border: none;
  border-top: 1px solid #e5e7eb;
}

.hint-text {
  margin-top: 8px;
  font-size: 0.75rem;
  color: #6b7280;
}

/* --- Scrollbar --- */
.messages::-webkit-scrollbar {
  width: 6px;
}

.messages::-webkit-scrollbar-thumb {
  background: #cbd5f5;
  border-radius: 999px;
}
