* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #ffffff;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.header {
  background: #ffffff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
}
.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #0084ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
  position: relative;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 12px;
  height: 12px;
  background: #31a24c;
  border-radius: 50%;
  border: 2px solid #ffffff;
}
.header-info h1 {
  font-size: 17px;
  font-weight: 600;
  color: #000000;
  display: flex;
  align-items: center;
  gap: 4px;
}
#headerNameText {
  color: #000000;
}
.header-info p {
  font-size: 12px;
  color: #31a24c;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #ffffff;
}
.messages::-webkit-scrollbar { display: none; }

.message-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  max-width: 100%;
}
.message-row.user { flex-direction: row-reverse; }
.message-row.admin { flex-direction: row; }

.bubble-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #0084ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
  margin-bottom: 2px;
}
.bubble-avatar.hidden { visibility: hidden; }

.bubble {
  max-width: 72%;
  border-radius: 20px;
  font-size: 15px;
  line-height: 1.4;
  word-break: break-word;
}
.bubble:not(:has(img)) {
  padding: 9px 13px;
}
.bubble:has(img) {
  margin-top: 4px;
  margin-bottom: 4px;
}
.message-row.user .bubble {
  background: #0084ff;
  color: white;
  border-bottom-right-radius: 5px;
}
.message-row.admin .bubble {
  background: #f0f0f0;
  color: #000000;
  border-bottom-left-radius: 5px;
}
.message-row.user + .message-row.user .bubble { border-top-right-radius: 5px; }
.message-row.admin + .message-row.admin .bubble { border-top-left-radius: 5px; }

.bubble img {
  max-width: 200px;
  border-radius: 12px;
  display: block;
}
.input-area {
  background: #ffffff;
  padding: 10px 10px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 9px;
  border-top: 1px solid #e0e0e0;
  flex-shrink: 0;
}
.gallery-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  color: #0084ff;
}
.gallery-btn svg { width: 28px; height: 28px; }

.input-wrap {
  flex: 1;
  background: #f0f0f0;
  border-radius: 22px;
  display: flex;
  align-items: center;
  padding: 0 15px;
  min-height: 40px;
}
.input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 15px;
  color: #000000;
  padding: 9px 0;
  font-family: inherit;
}
.input-wrap input::placeholder { color: #999; }

.send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #0084ff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}
.send-btn:active { background: #006edb; }
.send-btn svg {
  width: 19px;
  height: 19px;
  fill: white;
  margin-left: 2px;
}

/* LOGIN SCREEN */
.login-screen {
  position: fixed;
  inset: 0;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  z-index: 100;
}
.login-screen.hidden { display: none; }

.login-logo {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.login-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.login-screen h2 {
  font-size: 22px;
  font-weight: 700;
  color: #000000;
  margin-bottom: 0.4rem;
  text-align: center;
}
.login-screen p {
  font-size: 14px;
  color: #666;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  text-align: center;
}
.login-input {
  width: 100%;
  background: #f0f0f0;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 16px;
  color: #000000;
  outline: none;
  font-family: inherit;
  margin-bottom: 1rem;
}
.login-input::placeholder { color: #999; }
.login-input:focus { border-color: #0084ff; }
.login-btn {
  width: 100%;
  background: #0084ff;
  color: white;
  border: none;
  border-radius: 100px;
  padding: 6px 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-btn:active { background: #006edb; }
.login-error {
  font-size: 13px;
  color: #ff4444;
  margin-top: 0.75rem;
  min-height: 18px;
  text-align: center;
}

/* IMAGE PREVIEW */
.img-preview {
  display: none;
  padding: 8px 10px 0;
  background: #ffffff;
}
.img-preview.show { display: flex; align-items: center; gap: 8px; }
.img-preview img {
  height: 60px;
  border-radius: 8px;
  object-fit: cover;
}
.img-preview-remove {
  background: #ff4444;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  color: white;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.text-logo {
  width: 300px;
  margin-bottom: 0.4rem;
}

.settings-btn {
  margin-left: auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #0084ff;
}
.settings-btn svg {
  width: 24px;
  height: 24px;
}

/* SETTINGS POPUP */
.settings-popup {
  position: fixed;
  top: 72px;
  right: 12px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  padding: 8px 0;
  z-index: 999;
  min-width: 160px;
  border: 1px solid #e0e0e0;
}
.settings-popup.hidden { display: none; }

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  font-size: 15px;
  color: #000000;
  cursor: pointer;
  gap: 16px;
}

.settings-divider {
  height: 1px;
  background: #e0e0e0;
  margin: 0 12px;
}

.toggle {
  width: 44px;
  height: 24px;
  background: #e0e0e0;
  border-radius: 100px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle.on { background: #0084ff; }
.toggle-circle {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: left 0.2s;
}
.toggle.on .toggle-circle { left: 22px; }

/* LOGOUT */
.logout-text {
  color: #ff4444;
  font-size: 15px;
}

