/* AI COLLABORATION SECURE CHAT - mobile first styles */
* { box-sizing: border-box; }
:root {
  --bg: #0f172a;
  --panel: #ffffff;
  --panel-dark: #111827;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #0f766e;
  --brand-dark: #0b5e57;
  --danger: #b91c1c;
  --ok: #15803d;
  --bubble-me: #0f766e;
  --bubble-them: #f3f4f6;
}
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f3f4f6;
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.center { text-align: center; }

/* Auth and setup screens */
.auth-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 430px;
  background: var(--panel);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
.auth-card h1 { font-size: 22px; margin: 0 0 4px 0; text-align: center; }
.auth-card .sub { text-align: center; color: var(--muted); margin: 0 0 20px 0; font-size: 14px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #fff;
}
.field input:focus, .field textarea:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
.btn {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}
.btn:hover { background: var(--brand-dark); }
.btn:disabled { background: #9ca3af; cursor: not-allowed; }
.btn-secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid #d1d5db;
}
.btn-small { width: auto; padding: 8px 14px; font-size: 14px; }
.btn-danger { background: var(--danger); }
.error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 14px;
}
.notice {
  background: #f0fdfa;
  color: #134e4a;
  border: 1px solid #99f6e4;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 14px;
}
.install-box {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
.install-box h2 { font-size: 16px; margin: 0 0 8px 0; }
.install-box ol { margin: 0 0 10px 20px; padding: 0; font-size: 14px; color: #374151; }
.install-box li { margin-bottom: 4px; }

/* App shell */
.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; background: #fff; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg);
  color: #fff;
}
.topbar h1 { font-size: 16px; margin: 0; }
.topbar .who { font-size: 13px; color: #cbd5e1; }
.topbar button {
  background: transparent;
  color: #fff;
  border: 1px solid #475569;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
}
.main { flex: 1; display: flex; min-height: 0; }
.sidebar {
  width: 300px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  background: #f9fafb;
}
.sidebar h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 0; padding: 14px 14px 8px 14px; }
.contact-list { overflow-y: auto; flex: 1; }
.contact {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.contact.active { background: #e0f2f1; }
.contact .name { font-weight: 700; }
.contact .meta { font-size: 13px; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #9ca3af; margin-top: 6px; flex-shrink: 0; }
.dot.online { background: #22c55e; }
.unread {
  margin-left: auto;
  background: var(--brand);
  color: #fff;
  border-radius: 999px;
  min-width: 22px;
  height: 22px;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
}
.chat-header .name { font-weight: 700; font-size: 17px; }
.chat-header .status { font-size: 13px; color: var(--muted); }
.chat-header .status.online { color: var(--ok); }
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f9fafb;
}
.message { max-width: 78%; padding: 10px 12px; border-radius: 14px; line-height: 1.45; word-wrap: break-word; }
.message.me { align-self: flex-end; background: var(--bubble-me); color: #fff; }
.message.them { align-self: flex-start; background: var(--bubble-them); color: var(--text); }
.message .time { display: block; font-size: 11px; opacity: 0.75; margin-top: 4px; }
.message .locked { font-size: 12px; opacity: 0.85; }
.empty-state { text-align: center; color: var(--muted); padding: 40px 20px; }
.composer { border-top: 1px solid var(--line); padding: 12px; background: #fff; }
.composer .row { display: flex; gap: 8px; }
.composer textarea {
  flex: 1;
  resize: none;
  min-height: 48px;
  max-height: 120px;
  padding: 11px 12px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
}
.send-btn {
  width: auto;
  padding: 0 18px;
  border: none;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}
.send-btn:disabled { background: #9ca3af; cursor: not-allowed; }
.send-status { font-size: 13px; color: #92400e; margin-top: 8px; }
.send-status.ok { color: var(--ok); }

/* Panels and dialogs */
.panel {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.panel-card {
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 20px;
}
.panel-card h2 { margin-top: 0; }
.panel-card .close-row { display: flex; justify-content: space-between; align-items: center; }
.invite-form { display: grid; gap: 10px; margin: 12px 0; }
.invite-form input { padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 10px; width: 100%; }
.member-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.member-row .actions { display: flex; gap: 6px; }

/* Mobile: member view has no sidebar, admin gets a list on top */
@media (max-width: 720px) {
  .main { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--line); max-height: 38vh; }
  .sidebar.admin-collapsed { display: none; }
  .contact-list { max-height: 30vh; }
  .message { max-width: 88%; }
  .topbar h1 { font-size: 15px; }
  .auth-card { padding: 22px 18px; }
}
@media (min-width: 721px) {
  .panel { align-items: center; }
  .panel-card { border-radius: 16px; }
}
