/* =========================================================
   CallEase – calls.css
   ========================================================= */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --green: #16a34a;
  --green-dark: #15803d;
  --green-soft: #dcfce7;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --radius: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #60a5fa;
    --primary-soft: #1e293b;
    --green-soft: #052e1a;
    --amber: #fbbf24;
    --amber-soft: #3a2a07;
    --red-soft: #3b0d0d;
    --bg: #0b1220;
    --card: #111a2e;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --border: #1f2a44;
    --shadow: none;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
}

button, input { font: inherit; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(10px + env(safe-area-inset-top)) 16px 12px;
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
  color: #fff;
  box-shadow: 0 2px 12px rgba(29, 78, 216, .25);
}
.topbar__main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1200px;
  margin: 0 auto;
}
.topbar__brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar__logo {
  width: 40px; height: 40px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, .18);
}
.topbar__logo svg { width: 20px; height: 20px; }
.topbar__text { min-width: 0; }
.topbar__title { margin: 0; font-size: 1.1rem; font-weight: 700; line-height: 1.2; }
.topbar__user {
  margin: 0; font-size: .8rem; opacity: .85;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar__actions { display: flex; gap: 8px; }
.topbar__actions form { margin: 0; }

.icon-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0; border-radius: 12px;
  background: rgba(255, 255, 255, .18);
  color: #fff;
  cursor: pointer;
}
.icon-btn:active { background: rgba(255, 255, 255, .32); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.is-loading svg { animation: spin .8s linear infinite; }
.icon-btn:disabled { cursor: wait; }

/* ---------- Search ---------- */
.searchbar {
  position: relative;
  display: block;
  max-width: 1200px;
  margin: 12px auto 0;
}
.searchbar svg {
  position: absolute; left: 14px; top: 50%;
  width: 18px; height: 18px;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.searchbar input {
  width: 100%; height: 46px;
  padding: 0 14px 0 42px;
  border: 0; border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font-size: 16px; /* prevents iPhone zoom */
  outline: none;
  box-shadow: inset 0 0 0 2px transparent;
}
.searchbar input:focus { box-shadow: inset 0 0 0 2px #93c5fd; }

/* ---------- Main ---------- */
.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 12px calc(28px + env(safe-area-inset-bottom));
}

.summary {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; flex-wrap: wrap;
}
.summary__count { font-weight: 700; font-size: 1rem; }
.summary__pills { display: flex; gap: 6px; flex-wrap: wrap; }

.pill {
  padding: 4px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 700;
}
.pill--yes { background: var(--green-soft); color: var(--green); }
.pill--no { background: var(--red-soft); color: var(--red); }

.status { margin: 4px 0 12px; color: var(--muted); font-size: .8rem; }
.status.is-error { color: var(--red); font-weight: 600; }

/* ---------- Cards grid ---------- */
.records { display: grid; gap: 12px; }

@media (min-width: 640px) {
  .wrap { padding: 20px 20px 32px; }
  .records { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .records { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.card {
  display: flex; flex-direction: column; gap: 12px;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: opacity .2s, border-color .2s;
}

/* Call status on card */
.card.is-connected { opacity: .6; }
.card.is-missed {
  border-color: #fca5a5;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, .12), var(--shadow);
}

.card__top { display: flex; align-items: flex-start; gap: 12px; }
.avatar {
  width: 44px; height: 44px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700; font-size: 1.1rem;
}
.card__id { flex: 1; min-width: 0; }
.card__name { margin: 0; font-size: 1.05rem; font-weight: 700; overflow-wrap: anywhere; }
.card__meta { margin: 2px 0 0; font-size: .85rem; color: var(--muted); overflow-wrap: anywhere; }
.card__row { font-size: .72rem; color: var(--muted); white-space: nowrap; padding-top: 3px; }

.status-tag {
  border: 0; cursor: pointer; white-space: nowrap;
  padding: 5px 10px; border-radius: 999px;
  font-size: .75rem; font-weight: 700;
}
.status-tag--yes { background: var(--green-soft); color: var(--green); }
.status-tag--no { background: var(--red-soft); color: var(--red); }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  max-width: 100%;
  padding: 5px 10px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary);
  font-size: .78rem; font-weight: 600;
  overflow-wrap: anywhere;
}
.chip b { font-weight: 500; opacity: .8; }
.chip--warn { background: var(--amber-soft); color: var(--amber); }

/* Call buttons */
.card__calls { display: grid; gap: 8px; }
.card__calls.has-two { grid-template-columns: 1fr 1fr; }

.call-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 56px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--green); color: #fff;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(22, 163, 74, .3);
  transition: transform .1s, background .15s;
}
.call-btn:hover { background: var(--green-dark); }
.call-btn:active { transform: scale(.97); background: var(--green-dark); }
.call-btn__num {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 1.05rem; letter-spacing: .3px;
}
.call-btn__num svg { width: 18px; height: 18px; flex-shrink: 0; }
.call-btn__label {
  font-size: .68rem; font-weight: 500; opacity: .9;
  text-transform: uppercase; letter-spacing: .5px;
}
.has-two .call-btn__num { font-size: .95rem; }

.no-phone {
  margin: 0; padding: 12px; text-align: center;
  border-radius: 12px; background: var(--amber-soft); color: var(--amber);
  font-size: .9rem; font-weight: 600;
}

/* More details */
.card__more { border-top: 1px dashed var(--border); padding-top: 4px; }
.card__more summary {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0;
  list-style: none; cursor: pointer;
  color: var(--primary); font-size: .85rem; font-weight: 600;
}
.card__more summary::-webkit-details-marker { display: none; }
.card__more summary::after { content: "\25BE"; transition: transform .2s; }
.card__more[open] summary::after { transform: rotate(180deg); }

.fields { margin: 4px 0 4px; display: grid; gap: 8px; }
.fields div {
  display: grid; grid-template-columns: minmax(90px, 38%) 1fr; gap: 10px;
  font-size: .88rem;
}
.fields dt { color: var(--muted); }
.fields dd { margin: 0; overflow-wrap: anywhere; }

/* Empty + loading */
.empty {
  grid-column: 1 / -1;
  margin: 0; padding: 40px 20px;
  text-align: center; color: var(--muted);
  background: var(--card);
  border: 1px dashed var(--border); border-radius: var(--radius);
}
.skeleton {
  height: 180px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--card) 25%, var(--border) 50%, var(--card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Toast */
.toast {
  position: fixed; left: 50%; z-index: 70;
  bottom: calc(20px + env(safe-area-inset-bottom));
  max-width: calc(100% - 32px);
  padding: 10px 18px; border-radius: 999px;
  background: #0f172a; color: #fff;
  font-size: .88rem; text-align: center;
  opacity: 0; pointer-events: none;
  transform: translate(-50%, 20px);
  transition: opacity .25s, transform .25s;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--red); }

/* ---------- Bottom sheet popup (Connected / Not connected) ---------- */
body.sheet-open { overflow: hidden; }

.sheet {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet[hidden] { display: none; }

.sheet__backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, .55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: fadeIn .2s ease;
}

.sheet__panel {
  position: relative;
  width: 100%; max-width: 440px;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  background: var(--card);
  border-radius: 28px 28px 0 0;
  box-shadow: 0 -10px 40px rgba(15, 23, 42, .25);
  animation: slideUp .28s cubic-bezier(.2, .8, .2, 1);
}
.sheet__handle {
  width: 44px; height: 5px;
  margin: 0 auto 16px;
  border-radius: 999px;
  background: var(--border);
}

/* Person row */
.sheet__person {
  display: flex; align-items: center; gap: 12px;
  padding: 12px;
  border-radius: 18px;
  background: var(--bg);
}
.sheet__avatar {
  width: 46px; height: 46px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  font-weight: 800; font-size: 1.15rem;
}
.sheet__person-text { flex: 1; min-width: 0; }
.sheet__eyebrow {
  margin: 0;
  font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted);
}
.sheet__who {
  margin: 2px 0 0;
  font-size: 1.05rem; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sheet__close {
  width: 36px; height: 36px; flex-shrink: 0;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--card); color: var(--muted);
  cursor: pointer;
}
.sheet__close svg { width: 18px; height: 18px; }

.sheet__title { margin: 18px 4px 12px; font-size: 1.2rem; font-weight: 800; }

/* Options */
.sheet__options { display: grid; gap: 10px; }
.sheet__option {
  display: flex; align-items: center; gap: 14px;
  width: 100%; min-height: 74px;
  padding: 12px 14px;
  border: 1.5px solid transparent;
  border-radius: 18px;
  text-align: left;
  cursor: pointer;
  transition: transform .1s, border-color .15s;
}
.sheet__option:active { transform: scale(.98); }
.sheet__option--yes { background: var(--green-soft); color: var(--green); }
.sheet__option--yes:hover { border-color: var(--green); }
.sheet__option--no { background: var(--red-soft); color: var(--red); }
.sheet__option--no:hover { border-color: var(--red); }

.sheet__icon {
  width: 46px; height: 46px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 14px;
  color: #fff;
}
.sheet__option--yes .sheet__icon { background: var(--green); box-shadow: 0 4px 10px rgba(22, 163, 74, .35); }
.sheet__option--no .sheet__icon { background: var(--red); box-shadow: 0 4px 10px rgba(220, 38, 38, .35); }
.sheet__icon svg { width: 22px; height: 22px; }

.sheet__text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.sheet__text strong { font-size: 1.02rem; font-weight: 800; }
.sheet__text small { font-size: .8rem; font-weight: 500; color: var(--muted); }
.sheet__chev { width: 20px; height: 20px; flex-shrink: 0; opacity: .55; }

/* Footer */
.sheet__footer { display: flex; justify-content: center; gap: 8px; margin-top: 10px; }
.sheet__link {
  padding: 12px 16px;
  border: 0; border-radius: 12px;
  background: none; color: var(--muted);
  font-size: .92rem; font-weight: 600;
  cursor: pointer;
}
.sheet__link:active { background: var(--bg); }
.sheet__link--danger { color: var(--red); }

@media (min-width: 640px) {
  .sheet { align-items: center; padding: 16px; }
  .sheet__panel { border-radius: 28px; padding-bottom: 20px; animation: popIn .2s ease; }
  .sheet__handle { display: none; }
}

@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }

@media (prefers-color-scheme: dark) {
  .card.is-missed { border-color: #7f1d1d; }
  .status-tag--no, .pill--no, .sheet__option--no { color: #fca5a5; }
  .sheet__option--yes { color: #86efac; }
}

/* ---------- Login ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px;
  padding: 12px 18px;
  border: 0; border-radius: 14px;
  background: var(--primary-dark); color: #fff;
  font-size: 1rem; font-weight: 700;
  cursor: pointer;
  transition: transform .1s, background .15s;
}
.btn:hover { background: #1e40af; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .8; cursor: wait; }
.btn--full { width: 100%; }

.btn__spinner {
  display: none;
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255, 255, 255, .4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn.is-loading .btn__spinner { display: inline-block; }

.login-page {
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center;
  padding: 0 16px calc(24px + env(safe-area-inset-bottom));
  background:
    linear-gradient(160deg, #1d4ed8 0%, #2563eb 55%, transparent 55.2%) no-repeat,
    var(--bg);
  background-size: 100% 340px, auto;
}

.login-hero {
  width: 100%; max-width: 400px;
  padding: calc(48px + env(safe-area-inset-top)) 8px 28px;
  text-align: center;
  color: #fff;
}
.login-hero__logo {
  width: 64px; height: 64px;
  margin: 0 auto 14px;
  display: grid; place-items: center;
  border-radius: 20px;
  background: rgba(255, 255, 255, .18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25);
}
.login-hero__logo svg { width: 30px; height: 30px; }
.login-hero__title { margin: 0; font-size: 1.75rem; font-weight: 800; letter-spacing: .3px; }
.login-hero__sub { margin: 6px 0 0; font-size: .95rem; opacity: .85; }

.login-card {
  width: 100%; max-width: 400px;
  display: grid; gap: 16px;
  padding: 26px 20px 22px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .12);
}
.login-card__title { margin: 0; font-size: 1.3rem; font-weight: 700; }
.login-card__sub { margin: -10px 0 4px; font-size: .9rem; color: var(--muted); }
.login-card__foot { margin: 2px 0 0; text-align: center; font-size: .82rem; color: var(--muted); }

.login-error {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--red-soft); color: var(--red);
  font-size: .88rem; font-weight: 600;
}
.login-error svg { width: 20px; height: 20px; flex-shrink: 0; }

.field { display: grid; gap: 6px; }
.field__label { font-size: .85rem; font-weight: 600; color: var(--muted); }
.field__box {
  position: relative;
  display: flex; align-items: center;
  height: 52px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  transition: border-color .15s, box-shadow .15s;
}
.field__box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .15);
}
.field__box svg {
  width: 20px; height: 20px; flex-shrink: 0;
  margin-left: 14px;
  color: var(--muted);
}
.field__box input {
  flex: 1; min-width: 0; height: 100%;
  padding: 0 12px;
  border: 0; outline: none;
  background: transparent;
  color: var(--text);
  font-size: 16px; /* prevents iPhone zoom */
}
.field__toggle {
  height: 100%;
  padding: 0 14px;
  border: 0; background: none;
  color: var(--primary);
  font-size: .85rem; font-weight: 700;
  cursor: pointer;
}

@media (min-width: 640px) {
  .login-page { justify-content: center; background-size: 100% 46vh, auto; }
  .login-hero { padding-top: 0; }
  .login-card { padding: 30px 28px 24px; }
}

/* ---------- Forgot password pages ---------- */
.login-card--center { text-align: center; }
.login-card--center .login-card__sub { margin-top: -8px; }
.login-card__title--center, .login-card__sub--center { text-align: center; }

.auth-icon {
  width: 58px; height: 58px;
  margin: 0 auto 2px;
  display: grid; place-items: center;
  border-radius: 18px;
  background: var(--primary-soft); color: var(--primary);
}
.auth-icon svg { width: 28px; height: 28px; }
.auth-icon--success { background: var(--green-soft); color: var(--green); }
.auth-icon--danger { background: var(--red-soft); color: var(--red); }

.field__error { font-size: .82rem; font-weight: 600; color: var(--red); }
.field__help { margin: 0; font-size: .78rem; color: var(--muted); }

.login-row { display: flex; justify-content: flex-end; margin-top: -6px; }
.login-link { color: var(--primary); font-size: .9rem; font-weight: 700; text-decoration: none; }
.login-link:hover { text-decoration: underline; }

a.btn { text-decoration: none; }