/* public/styles.css — Safari Chat Lab */

:root {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --text: #0b0b0d;
  --text-secondary: #6b6b70;
  --accent: #007aff;
  --bubble-mine: #007aff;
  --bubble-mine-text: #ffffff;
  --bubble-theirs: #e9e9eb;
  --bubble-theirs-text: #0b0b0d;
  --danger: #ff3b30;
  --success: #34c759;
  --warning: #ffcc00;
  --border: rgba(0,0,0,0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0d;
    --surface: #1c1c1e;
    --text: #f2f2f7;
    --text-secondary: #9a9aa0;
    --bubble-theirs: #2c2c2e;
    --bubble-theirs-text: #f2f2f7;
    --border: rgba(255,255,255,0.1);
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", sans-serif;
  overscroll-behavior: none;
}

body {
  height: 100dvh;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.screen {
  height: 100dvh;
  width: 100%;
  display: flex;
  flex-direction: column;
}

/* ---------- Install banner ---------- */
.install-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--accent);
  color: #fff;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}

.install-banner button {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 18px;
  line-height: 1;
  padding: 0 6px;
}

/* ---------- Login ---------- */
#login-screen {
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.08);
}

.login-card h1 {
  font-size: 22px;
  margin: 0 0 4px;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 0 0 20px;
}

#login-form label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

#login-form input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  font-size: 16px; /* prevent iOS auto-zoom on focus */
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

#login-submit {
  width: 100%;
  padding: 12px;
  margin-top: 6px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
}

#login-submit:active {
  opacity: 0.8;
}

.error-text {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  margin-bottom: 0;
}

/* ---------- Chat ---------- */
#chat-screen {
  height: 100dvh;
}

.chat-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  flex-shrink: 0;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.room-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.ws-indicator {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}
.ws-green { background: var(--success); }
.ws-yellow { background: var(--warning); }
.ws-red { background: var(--danger); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.online-count {
  color: var(--text-secondary);
}

.icon-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text);
}

.online-users {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.online-users .pill {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.typing-indicator {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.message-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 78%;
}

.msg-row.mine {
  align-self: flex-end;
  align-items: flex-end;
}

.msg-row.theirs {
  align-self: flex-start;
  align-items: flex-start;
}

.msg-sender {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.msg-bubble {
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.35;
  word-break: break-word;
  white-space: pre-wrap;
}

.msg-row.mine .msg-bubble {
  background: var(--bubble-mine);
  color: var(--bubble-mine-text);
  border-bottom-right-radius: 4px;
}

.msg-row.theirs .msg-bubble {
  background: var(--bubble-theirs);
  color: var(--bubble-theirs-text);
  border-bottom-left-radius: 4px;
}

.msg-meta {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.composer {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  padding: 10px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

#composer-input {
  flex: 1;
  font-size: 16px; /* prevent iOS auto-zoom */
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

#composer-send {
  padding: 10px 18px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
}

/* ---------- Diagnostics drawer ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  display: flex;
  align-items: flex-end;
}

.drawer {
  width: 100%;
  max-height: 85dvh;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.drawer-header h2 {
  font-size: 16px;
  margin: 0;
}

.drawer-body {
  padding: 14px 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.diag-fields {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  font-size: 12px;
  margin: 0 0 16px;
}

.diag-fields dt {
  color: var(--text-secondary);
}

.diag-fields dd {
  margin: 0;
  word-break: break-all;
}

.diag-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.diag-actions button {
  flex: 1 1 45%;
  padding: 10px;
  font-size: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.diag-output {
  font-size: 11px;
  background: var(--bg);
  border-radius: 10px;
  padding: 10px;
  max-height: 160px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
