/* ============================================================
   WHISPR — design system
   Theme: vibrant black pouring into ash grey, diagonal from the
   top-left corner. Accent: warm ember/amber glow (deliberately NOT
   WhatsApp green). Chrome: iOS-style — large titles, translucent
   blurred tab bar, bubble tails, SF-style type stack.
   ============================================================ */

:root {
  /* --- Ash/black gradient system --- */
  --bg-gradient: radial-gradient(ellipse 140% 100% at 0% 0%, #2b2b2e 0%, #141416 35%, #000000 70%);
  --bg-elevated: #1c1c1ecc;      /* translucent charcoal, for blurred surfaces */
  --bg-elevated-solid: #1c1c1e;
  --bg-input: #2c2c2e;
  --border: #3a3a3c;
  --text: #f2f2f7;
  --text-dim: #98989f;

  /* --- Accent: ember/amber, not green --- */
  --accent: #E3A94B;
  --accent-dim: #4a3a1f;
  --accent-glow: rgba(227, 169, 75, 0.35);
  --live: #ff9f43;               /* unread/live indicator */
  --danger: #ff453a;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 9px;

  --font-display: -apple-system, "SF Pro Display", "Segoe UI", "Inter", sans-serif;
  --font-body: -apple-system, "SF Pro Text", "Segoe UI", "Inter", sans-serif;
}

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

html, body {
  margin: 0; padding: 0; height: 100%;
  background: #000;
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg-gradient);
  background-attachment: fixed;
}

a { color: var(--accent); text-decoration: none; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.1rem;
  font-weight: 600;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
button:active { transform: scale(0.96); }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary { background: var(--accent); color: #1a1206; box-shadow: 0 2px 14px var(--accent-glow); }
.btn-primary:hover { opacity: 0.92; }
.btn-primary:disabled { opacity: 0.5; box-shadow: none; }
.btn-secondary { background: var(--bg-input); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-ghost { background: transparent; color: var(--text-dim); }

input, textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.8rem 0.95rem;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
}

/* ============ App shell ============ */
.app-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}

/* iOS-style large title nav bar */
.ios-navbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 0.6rem 1.1rem 0.7rem;
  background: var(--bg-elevated);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-bottom: 1px solid var(--border);
}
.ios-navbar .nav-row {
  display: flex; align-items: center; justify-content: space-between;
}
.ios-navbar .large-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 2rem;
  letter-spacing: -0.02em;
  margin: 0.15rem 0 0;
}
.ios-navbar .nav-action { color: var(--accent); font-size: 1rem; font-weight: 600; background: none; padding: 0.2rem; }
.ios-search {
  margin-top: 0.6rem;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.8rem;
  display: flex; align-items: center; gap: 0.4rem;
  color: var(--text-dim);
  font-size: 0.9rem;
}
.ios-search input { background: transparent; border: none; padding: 0; font-size: 0.9rem; }

.content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 6.5rem;
}

/* iOS-style translucent blurred tab bar */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  background: var(--bg-elevated);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border-top: 0.5px solid var(--border);
  padding: 0.55rem 0 env(safe-area-inset-bottom, 0.55rem);
  z-index: 30;
}
.bottom-nav a {
  flex: 1; text-align: center;
  font-size: 0.68rem; font-weight: 500;
  color: var(--text-dim);
  padding: 0.3rem 0;
  display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
  transition: color 0.15s ease;
}
.bottom-nav a.active { color: var(--accent); }
.bottom-nav svg { width: 24px; height: 24px; }
.bottom-nav .icon-wrap { position: relative; }
.bottom-nav .badge {
  position: absolute; top: -3px; right: -6px;
  background: var(--danger); color: #fff;
  font-size: 0.6rem; font-weight: 700;
  min-width: 15px; height: 15px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}

/* ============ Ash particle animation (subtle, ambient) ============ */
.ash-layer {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden;
}
.ash-mote {
  position: absolute;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(227,169,75,0.55) 0%, rgba(227,169,75,0) 70%);
  animation: ashDrift linear infinite;
  opacity: 0;
}
@keyframes ashDrift {
  0% { transform: translate(0, 0) scale(0.6); opacity: 0; }
  10% { opacity: 0.7; }
  90% { opacity: 0.3; }
  100% { transform: translate(-40px, 420px) scale(1.1); opacity: 0; }
}

/* ============ Auth screens (WhatsApp-style step flow) ============ */
.auth-wrap {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  flex: 1; padding: 2rem 1.5rem; text-align: center; position: relative; z-index: 1;
}
.auth-card { width: 100%; max-width: 380px; }
.auth-card .app-mark {
  width: 68px; height: 68px; border-radius: 20px;
  background: linear-gradient(135deg, #3a3a3c, #000);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 800; font-size: 1.8rem; color: var(--accent);
  margin: 0 auto 1.2rem;
  box-shadow: 0 8px 30px var(--accent-glow);
}
.auth-card h1 { font-family: var(--font-display); font-size: 1.7rem; font-weight: 800; margin-bottom: 0.3rem; }
.auth-card p.tagline { color: var(--text-dim); font-size: 0.9rem; margin-top: 0; margin-bottom: 1.8rem; line-height: 1.4; }
.auth-card form { display: flex; flex-direction: column; gap: 0.85rem; }
.auth-toggle { margin-top: 1.2rem; font-size: 0.85rem; color: var(--text-dim); }
.error-msg { color: var(--danger); font-size: 0.85rem; min-height: 1.1em; }
.otp-input {
  text-align: center; letter-spacing: 0.35em; font-size: 1.3rem; font-weight: 700;
  padding-left: 0.35em; /* visually recenters against the letter-spacing */
}
.resend-row { font-size: 0.82rem; color: var(--text-dim); margin-top: 0.4rem; }
.resend-row button { background: none; padding: 0; color: var(--accent); font-size: 0.82rem; font-weight: 600; }
.resend-row button:disabled { color: var(--text-dim); }
.install-hint { margin-top: 1.6rem; font-size: 0.75rem; color: var(--text-dim); border-top: 1px dashed var(--border); padding-top: 1rem; }

/* ============ Chat list ============ */
.list-item {
  display: flex; align-items: center; gap: 0.85rem;
  padding: 0.7rem 1.1rem;
  border-bottom: 0.5px solid var(--border);
  animation: rowIn 0.25s ease;
}
@keyframes rowIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, #3a3a3c, #17171a);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--accent);
  flex-shrink: 0; overflow: hidden; position: relative;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.online-dot {
  position: absolute; bottom: -1px; right: -1px;
  width: 13px; height: 13px; border-radius: 50%;
  background: #34c759; border: 2.5px solid var(--bg-elevated-solid);
}

.list-item .meta { flex: 1; min-width: 0; }
.list-item .meta .name { font-weight: 600; font-size: 1rem; }
.list-item .meta .preview { color: var(--text-dim); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .time { font-size: 0.75rem; color: var(--text-dim); }
.list-item .unread-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 6px var(--accent-glow); }

.add-contact-bar { display: flex; gap: 0.5rem; padding: 0.9rem 1.1rem; border-bottom: 0.5px solid var(--border); }
.add-contact-bar input { flex: 1; }

/* ============ Conversation ============ */
.chat-header {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.7rem 1rem;
  border-bottom: 0.5px solid var(--border);
  position: sticky; top: 0; z-index: 20;
  background: var(--bg-elevated);
  backdrop-filter: blur(20px) saturate(160%);
}
.chat-header .avatar { width: 40px; height: 40px; }
.chat-header .name { font-weight: 700; font-size: 1rem; }
.chat-header .lock { color: var(--text-dim); font-size: 0.72rem; display: flex; align-items: center; gap: 0.25rem; }

.messages { display: flex; flex-direction: column; gap: 0.35rem; padding: 1rem; padding-bottom: 9rem; }

@keyframes bubbleIn { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }

.bubble {
  max-width: 78%; padding: 0.55rem 0.85rem 0.6rem;
  border-radius: 18px; font-size: 0.95rem; line-height: 1.35;
  position: relative; word-wrap: break-word;
  animation: bubbleIn 0.2s ease;
}
.bubble.mine {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent) 0%, #b8801f 100%);
  color: #1a1206;
  border-bottom-right-radius: 5px;
}
.bubble.theirs {
  align-self: flex-start;
  background: var(--bg-input);
  border: 0.5px solid var(--border);
  border-bottom-left-radius: 5px;
}
.bubble .meta-row { display: flex; gap: 0.4rem; align-items: center; margin-top: 0.25rem; justify-content: flex-end; }
.bubble.theirs .meta-row { justify-content: flex-start; }
.bubble .meta-row .stamp { font-size: 0.65rem; opacity: 0.7; }
.bubble .meta-row .edited-tag { font-size: 0.65rem; opacity: 0.7; font-style: italic; }
.bubble .msg-actions { display: none; gap: 0.4rem; margin-top: 0.35rem; }
.bubble.mine:hover .msg-actions { display: flex; }
.bubble .msg-actions button { padding: 0.15rem 0.5rem; font-size: 0.68rem; color: #1a1206; }
.read-receipt { font-size: 0.68rem; opacity: 0.7; }
.read-receipt.read { opacity: 1; }

@keyframes sendPop { 0% { transform: scale(1); } 45% { transform: scale(0.85); } 100% { transform: scale(1); } }
.btn-primary.pop { animation: sendPop 0.2s ease; }

.typing-dots { display: inline-flex; align-items: center; gap: 3px; }
.typing-dots span { width: 5px; height: 5px; border-radius: 50%; background: var(--live); animation: typingBounce 1.1s infinite ease-in-out; }
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-4px); opacity: 1; } }

.composer {
  position: fixed; bottom: 3.9rem; left: 0; right: 0;
  max-width: 720px; margin: 0 auto;
  display: flex; gap: 0.6rem; align-items: flex-end;
  padding: 0.7rem 0.9rem;
  border-top: 0.5px solid var(--border);
  background: var(--bg-elevated);
  backdrop-filter: blur(20px) saturate(160%);
  z-index: 25;
}
.composer textarea { resize: none; max-height: 6rem; border-radius: 20px; transition: height 0.12s ease; overflow-y: auto; }
.composer button { flex-shrink: 0; border-radius: 50%; width: 42px; height: 42px; padding: 0; display: flex; align-items: center; justify-content: center; }

/* ============ Feed ============ */
.feed-upload-bar { padding: 1rem 1.1rem; border-bottom: 0.5px solid var(--border); }
.feed-upload-bar label.upload-btn {
  display: flex; align-items: center; gap: 0.5rem; justify-content: center;
  background: var(--bg-input); border: 1px dashed var(--border);
  padding: 0.8rem 1rem; border-radius: var(--radius-md); color: var(--text-dim); font-size: 0.85rem;
}
.feed-upload-bar input[type=file] { display: none; }

.feed-post { border-bottom: 0.5px solid var(--border); padding: 1rem 1.1rem; animation: rowIn 0.25s ease; }
.feed-post .post-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.6rem; }
.feed-post .post-head .name { font-weight: 600; font-size: 0.9rem; }
.feed-post .post-head .time { font-size: 0.72rem; color: var(--text-dim); }
.feed-post video { width: 100%; border-radius: var(--radius-md); background: #000; max-height: 480px; }
.feed-post .caption { margin-top: 0.6rem; font-size: 0.88rem; }
.feed-post .post-actions { display: flex; gap: 0.6rem; margin-top: 0.6rem; }
.feed-post .post-actions button { font-size: 0.72rem; padding: 0.3rem 0.6rem; }

.empty-state { text-align: center; color: var(--text-dim); padding: 3.5rem 1.5rem; font-size: 0.9rem; }

/* ============ Skeleton loaders ============ */
.skeleton-line, .skeleton-block, .skeleton-avatar {
  background: linear-gradient(90deg, var(--bg-input) 25%, var(--border) 37%, var(--bg-input) 63%);
  background-size: 400% 100%;
  animation: skeletonLoading 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
.skeleton-line { height: 0.8rem; margin-bottom: 0.45rem; }
.skeleton-avatar { width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0; }
@keyframes skeletonLoading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.skeleton-list-item { display: flex; align-items: center; gap: 0.85rem; padding: 0.7rem 1.1rem; border-bottom: 0.5px solid var(--border); }

/* ============ Profile ============ */
.profile-header { display: flex; flex-direction: column; align-items: center; padding: 2rem 1rem 1rem; }
.profile-header .avatar { width: 96px; height: 96px; font-size: 1.8rem; margin-bottom: 0.8rem; }
.profile-form { padding: 0 1.2rem; display: flex; flex-direction: column; gap: 1rem; }
.field-label { font-size: 0.75rem; color: var(--text-dim); margin-bottom: 0.3rem; display: block; text-transform: uppercase; letter-spacing: 0.04em; }
.save-row { display: flex; gap: 0.7rem; padding: 1.2rem; }
.save-row button { flex: 1; }

.toast {
  position: fixed; bottom: 6rem; left: 50%; transform: translate(-50%, 10px);
  background: var(--bg-elevated-solid); border: 1px solid var(--border);
  padding: 0.6rem 1.1rem; border-radius: 20px; font-size: 0.82rem;
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease, transform 0.25s ease; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 720px) {
  .app-shell { border-left: 0.5px solid var(--border); border-right: 0.5px solid var(--border); }
}

/* ============================================================
   ANDROID (Material) theme overrides
   Scoped to html.platform-android, set by js/platform.js before
   paint. iOS and desktop keep the blurred/large-title chrome above
   as the default; this block makes Android look genuinely
   different — flat opaque surfaces, left-aligned compact titles,
   filled circular FAB-style send button, Roboto-leaning type.
   ============================================================ */
html.platform-android {
  --font-display: "Roboto", "Segoe UI", "Inter", sans-serif;
  --font-body: "Roboto", "Segoe UI", "Inter", sans-serif;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
}

/* Flat, opaque nav — no iOS-style blur/translucency */
html.platform-android .ios-navbar,
html.platform-android .chat-header,
html.platform-android .composer,
html.platform-android .bottom-nav {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  background: var(--bg-elevated-solid);
}

/* Compact, left-aligned title instead of iOS large-title */
html.platform-android .ios-navbar .large-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0.2rem 0 0.4rem;
}
html.platform-android .ios-navbar .nav-action {
  color: var(--accent);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 0.82rem;
}

/* Material-style elevated cards instead of hairline-divided rows */
html.platform-android .list-item,
html.platform-android .feed-post {
  border-bottom: none;
  margin: 0.4rem 0.7rem;
  border-radius: var(--radius-md);
  background: var(--bg-elevated-solid);
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* Buttons: flatter, less glow, Material "filled button" feel */
html.platform-android .btn-primary {
  box-shadow: none;
  border-radius: var(--radius-sm);
}
html.platform-android button:active {
  transform: scale(0.98);
  opacity: 0.85;
}

/* Bubbles: slightly less rounded, flatter, no gradient on sent bubbles */
html.platform-android .bubble {
  border-radius: 10px;
}
html.platform-android .bubble.mine {
  background: var(--accent);
  border-bottom-right-radius: 3px;
}
html.platform-android .bubble.theirs {
  border-bottom-left-radius: 3px;
}

/* Send button: circular filled FAB rather than iOS's simple circle-arrow */
html.platform-android .composer button#send-btn {
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

/* Search bar: Material-style pill, less iOS-rounded-square */
html.platform-android .ios-search {
  border-radius: 24px;
}

/* Inputs: Material underline-leaning style instead of iOS boxed fields */
html.platform-android input,
html.platform-android textarea {
  border-radius: var(--radius-sm);
  border: none;
  border-bottom: 2px solid var(--border);
  background: transparent;
  padding-left: 0.3rem;
}
html.platform-android input:focus-visible,
html.platform-android textarea:focus-visible {
  border-bottom-color: var(--accent);
  outline: none;
}
html.platform-android .composer textarea {
  border: 1px solid var(--border);
  background: var(--bg-input);
  padding-left: 0.95rem;
  border-radius: 20px;
}
