/* MFL Inbox — mobile PWA. Single-column, palette matches the MFL rebrand
   (navy #093c44, gold #f8b600, orange #f58f47). Safe-area aware for iOS notches. */
:root {
  --navy: #093c44;
  --navy-800: #072e34;
  --gold: #f8b600;
  --orange: #f58f47;
  --cream: #fff8ec;
  --bg: #eef1f2;
  --card: #ffffff;
  --line: #dbe2e4;
  --ink: #10262b;
  --muted: #6b7a7e;
  --in-bubble: #ffffff;
  --out-bubble: #cfe9ea;
  --danger: #b91c1c;
  --sat: env(safe-area-inset-top);
  --sab: env(safe-area-inset-bottom);
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body { overscroll-behavior-y: none; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 13.5px; }
[hidden] { display: none !important; }

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

/* ── App bar ─────────────────────────────────────────────────────────── */
.appbar {
  display: flex; align-items: center; gap: 12px;
  background: var(--navy); color: #fff;
  padding: calc(var(--sat) + 12px) 16px 12px;
  position: sticky; top: 0; z-index: 5;
}
.appbar-title { font-weight: 800; font-size: 18px; letter-spacing: .3px; flex: 1; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--gold); color: var(--navy); font-weight: 800; font-size: 13px;
}
.iconbtn {
  background: transparent; border: none; color: #fff; font-size: 26px; line-height: 1;
  width: 40px; height: 40px; cursor: pointer; display: flex; align-items: center;
  justify-content: center; text-decoration: none; border-radius: 8px;
}
.iconbtn:active { background: rgba(255,255,255,.12); }

/* ── List controls ───────────────────────────────────────────────────── */
.list-controls { background: var(--navy); padding: 0 12px 10px; }
.search-wrap { padding-bottom: 10px; }
#search-input {
  width: 100%; border: none; border-radius: 12px; padding: 11px 14px;
  font-size: 15px; font-family: inherit; background: rgba(255,255,255,.14); color: #fff;
}
#search-input::placeholder { color: rgba(255,255,255,.6); }
.filters { display: flex; gap: 6px; background: rgba(255,255,255,.10); padding: 4px; border-radius: 12px; }
.seg {
  flex: 1; border: none; background: transparent; color: rgba(255,255,255,.8);
  font-family: inherit; font-weight: 600; font-size: 13.5px; padding: 8px 6px;
  border-radius: 9px; cursor: pointer;
}
.seg.active { background: #fff; color: var(--navy); }

/* ── Notifications banner ────────────────────────────────────────────── */
.notif-banner {
  display: flex; align-items: center; gap: 10px;
  background: var(--cream); color: var(--navy);
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.notif-text { flex: 1; font-size: 13.5px; font-weight: 600; }
.notif-enable {
  border: none; background: var(--navy); color: #fff; font-family: inherit;
  font-weight: 700; font-size: 13px; padding: 8px 14px; border-radius: 999px; cursor: pointer;
}
.notif-dismiss { border: none; background: transparent; color: var(--muted); font-size: 16px; cursor: pointer; padding: 4px 6px; }

/* ── Conversation list ───────────────────────────────────────────────── */
.list-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.conv-list { list-style: none; margin: 0; padding: 0; }
.conv-wrap { position: relative; overflow: hidden; background: var(--card); }
.conv-actions { position: absolute; top: 0; right: 0; bottom: 0; display: flex; }
.swipe-action {
  border: none; width: 92px; color: #fff; font-family: inherit; font-weight: 700;
  font-size: 12.5px; line-height: 1.15; white-space: pre-line; cursor: pointer; padding: 0 8px;
}
.swipe-action.to-read { background: var(--orange); }
.swipe-action.to-unread { background: var(--navy); }
.conv {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px;
  background: var(--card); border-bottom: 1px solid var(--line); cursor: pointer;
  position: relative; transition: transform .18s ease; touch-action: pan-y; will-change: transform;
}
.conv:active { background: #f2f6f7; }
.conv-avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  background: var(--cream); color: var(--navy); font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}
.conv-main { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.conv-name { font-weight: 700; font-size: 15px; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 12px; color: var(--muted); flex: none; }
.conv-sub { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-top: 2px; }
.conv-preview { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.conv-preview.unread { color: var(--ink); font-weight: 600; }
.conv-line { font-size: 11px; color: var(--muted); }
.badge {
  background: var(--orange); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 20px; height: 20px; border-radius: 999px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.badge.dot { min-width: 10px; width: 10px; height: 10px; padding: 0; }

/* ── Thread ──────────────────────────────────────────────────────────── */
.thread-appbar { align-items: center; }
.thread-head { flex: 1; min-width: 0; }
.thread-name { font-weight: 800; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-sub { font-size: 12px; color: rgba(255,255,255,.7); }
.read-toggle {
  flex: none; border: 1px solid rgba(255,255,255,.35); background: transparent; color: #fff;
  font-family: inherit; font-weight: 600; font-size: 12.5px; padding: 6px 11px;
  border-radius: 999px; cursor: pointer; white-space: nowrap;
}
.read-toggle:active { background: rgba(255,255,255,.14); }
.tabs { display: flex; background: var(--navy-800); }
.tab {
  flex: 1; border: none; background: transparent; color: rgba(255,255,255,.7);
  font-family: inherit; font-weight: 600; font-size: 14px; padding: 12px; cursor: pointer;
  border-bottom: 3px solid transparent;
}
.tab.active { color: #fff; border-bottom-color: var(--gold); }
.thread-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 12px calc(var(--sab) + 14px); }
.messages { display: flex; flex-direction: column; gap: 8px; }

.msg { max-width: 78%; padding: 9px 12px; border-radius: 16px; font-size: 15px; line-height: 1.35; word-wrap: break-word; }
.msg.in { align-self: flex-start; background: var(--in-bubble); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.out { align-self: flex-end; background: var(--out-bubble); border-bottom-right-radius: 5px; }
.msg img { max-width: 100%; border-radius: 10px; margin-top: 6px; display: block; }
.msg-meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.day-sep { text-align: center; font-size: 11.5px; color: var(--muted); margin: 10px 0 2px; }

/* call cards (Transcripts tab) */
.callcard { align-self: stretch; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.callcard .call-top { display: flex; justify-content: space-between; font-size: 13.5px; font-weight: 600; color: var(--navy); }
.callcard .call-missed { color: var(--danger); }
.callcard audio { width: 100%; margin-top: 8px; }
.callcard .call-actions { display: flex; gap: 8px; margin-top: 8px; }
.call-transcript { margin-top: 8px; max-height: 220px; overflow-y: auto; font-size: 13px; background: #f6f9f9; border-radius: 10px; padding: 8px; }
.call-transcript .spk { font-weight: 700; }

/* ── Composer ────────────────────────────────────────────────────────── */
.composer {
  flex: none; background: var(--card); border-top: 1px solid var(--line);
  padding: 8px 10px calc(var(--sab) + 8px); display: flex; flex-direction: column; gap: 8px;
}
.composer-from { display: flex; align-items: center; gap: 8px; }
.small { font-size: 12px; }
#from-line {
  flex: 1; font-family: inherit; font-size: 13px; color: var(--navy);
  border: 1px solid var(--line); border-radius: 9px; padding: 7px 9px; background: #fff; max-width: 100%;
}
.composer-main { display: flex; align-items: flex-end; gap: 8px; }
.composer-icon {
  flex: none; border: 1px solid var(--line); background: #fff; border-radius: 999px;
  width: 40px; height: 40px; font-size: 19px; cursor: pointer;
}
#composer-text {
  flex: 1; resize: none; font-family: inherit; font-size: 15px; line-height: 1.3;
  border: 1px solid var(--line); border-radius: 18px; padding: 9px 14px; max-height: 120px;
}
.composer-send {
  flex: none; border: none; background: var(--navy); color: #fff; font-family: inherit;
  font-weight: 700; font-size: 14px; padding: 10px 16px; border-radius: 999px; cursor: pointer;
}
.composer-send:disabled { opacity: .5; }
.composer-error { color: var(--danger); font-size: 12.5px; }
.previews { display: flex; gap: 8px; flex-wrap: wrap; }
.preview { position: relative; width: 56px; height: 56px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.preview img { width: 100%; height: 100%; object-fit: cover; }
.preview button {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%;
  border: none; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; line-height: 1; cursor: pointer;
}

/* ── Sign-in ─────────────────────────────────────────────────────────── */
.signin { align-items: center; justify-content: center; background: var(--navy); }
.signin-card { text-align: center; color: #fff; padding: 24px; max-width: 340px; }
.signin-card h1 { margin: 12px 0 6px; font-weight: 800; }
.signin-card .muted { color: rgba(255,255,255,.8); margin-bottom: 22px; }
.signin-card strong { color: var(--gold); }
#gsi-button { display: flex; justify-content: center; min-height: 44px; }

/* ── Buttons / sheet ─────────────────────────────────────────────────── */
.btn { font-family: inherit; font-weight: 600; font-size: 15px; border-radius: 12px; border: 1px solid var(--line); background: #fff; color: var(--navy); padding: 13px; cursor: pointer; width: 100%; }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ghost { background: transparent; border-color: var(--line); }
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; z-index: 20; }
.sheet-card { background: #fff; width: 100%; border-radius: 18px 18px 0 0; padding: 20px 18px calc(var(--sab) + 20px); display: flex; flex-direction: column; gap: 10px; }
.empty, .loading { padding: 40px 20px; text-align: center; font-size: 14px; }

/* ── Line picker (account sheet) ─────────────────────────────────────── */
.lines-picker { border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px; }
.lines-picker > summary { font-weight: 600; color: var(--navy); cursor: pointer; padding: 6px 0; list-style: revert; }
.lines-list { max-height: 44vh; overflow-y: auto; margin: 6px 0 10px; display: flex; flex-direction: column; }
.line-opt { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); font-size: 14px; color: var(--ink); }
.line-opt:last-child { border-bottom: none; }
.line-opt input { width: 20px; height: 20px; flex: none; accent-color: var(--navy); }
.line-opt .line-nm { font-weight: 600; }
.line-opt .line-ph { color: var(--muted); font-size: 12.5px; }
