/* ==========================================================================
   Views — dialer, history, settings, and the call stage
   ========================================================================== */

/* ---------- extension badge (dialer head) ---------- */
.ext-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 13px 7px 7px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.ext-avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 14px;
  font-weight: 750;
}
.ext-meta strong { display: block; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ext-meta small { display: block; color: var(--ink-3); font-size: 11px; }

/* ---------- dialer ---------- */
.dialer {
  display: grid;
  gap: var(--s-4);
  padding: clamp(18px, 3vw, 26px);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.dial-display { position: relative; display: flex; align-items: center; }
.dial-input {
  width: 100%;
  height: 76px;
  padding: 0 52px 0 var(--s-4);
  border: 1px solid transparent;
  border-radius: var(--r-lg);
  background: var(--surface-inset);
  color: var(--ink);
  font-size: clamp(30px, 6.6vw, 40px);
  font-weight: 650;
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
  caret-color: var(--accent);
  text-align: center;
  transition: border-color var(--fast), box-shadow var(--fast);
}
.dial-input::placeholder {
  color: var(--ink-4);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0;
}
.dial-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.dial-backspace {
  position: absolute;
  right: 10px;
  width: 38px;
  height: 38px;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--ink-3);
}
.dial-backspace:hover { background: var(--surface-3); }

.dial-hint { margin-top: -6px; color: var(--ink-3); font-size: 12.5px; text-align: center; }
.dial-actions { margin-top: 2px; }

.quick { display: grid; gap: var(--s-3); }

/* ---------- history ---------- */
.history { display: grid; gap: var(--s-2); }
.history-day {
  padding: var(--s-3) 2px 2px;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.history-item {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: transform var(--fast), border-color var(--fast);
}
.history-item:hover { border-color: var(--accent); transform: translateY(-1px); }
.history-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--ink-3);
}
.history-icon .icon { width: 16px; height: 16px; }
.history-item[data-kind="outbound"] .history-icon { background: var(--accent-soft); color: var(--accent); }
.history-item[data-kind="inbound"] .history-icon { background: var(--ok-soft); color: var(--ok); }
.history-item[data-kind="missed"] .history-icon { background: var(--danger-soft); color: var(--danger); }
.history-num {
  display: block;
  font-size: 15.5px;
  font-weight: 660;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-item[data-kind="missed"] .history-num { color: var(--danger); }
.history-sub { display: block; color: var(--ink-3); font-size: 12px; }
.history-time { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }

.empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: var(--s-7) var(--s-4);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  text-align: center;
}
.empty-icon { width: 26px; height: 26px; color: var(--ink-4); margin-bottom: 4px; }
.empty p { font-weight: 620; }
.empty small { color: var(--ink-3); max-width: 34ch; }

/* ---------- settings ---------- */
.info { display: grid; gap: 1px; border-radius: var(--r-sm); overflow: hidden; background: var(--line); }
.info > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: 11px 13px;
  background: var(--surface-2);
}
.info dt { color: var(--ink-3); font-size: 13px; }
.info dd { font-size: 13.5px; font-weight: 620; text-align: right; overflow-wrap: anywhere; }

.fineprint {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1.6;
}
.fineprint .icon { width: 15px; height: 15px; flex: none; margin-top: 2px; }

/* ==========================================================================
   Call stage
   ========================================================================== */
.call-stage {
  --level: 0;
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: var(--s-4);
  background: var(--overlay);
  backdrop-filter: blur(6px);
  animation: fade-in .2s var(--ease) both;
}
@keyframes fade-in { from { opacity: 0; } }

.call-card {
  display: grid;
  gap: var(--s-4);
  width: min(420px, 100%);
  max-height: calc(100dvh - 2 * var(--s-4));
  overflow-y: auto;
  padding: var(--s-5);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: call-in .3s var(--ease) both;
}
@keyframes call-in { from { opacity: 0; transform: translateY(18px) scale(.97); } }

.call-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.call-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 640;
}
.call-tag .icon { width: 14px; height: 14px; }
.call-stage[data-dir="inbound"] .call-tag { background: var(--ok-soft); color: var(--ok); }
.call-timer {
  color: var(--ink-3);
  font-size: 14px;
  font-weight: 640;
  font-variant-numeric: tabular-nums;
}

.call-identity { display: grid; justify-items: center; gap: 4px; text-align: center; }
.call-avatar {
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  margin-bottom: 6px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 30px;
  font-weight: 700;
}
.call-stage[data-state="ringing"] .call-avatar { animation: ring-pulse 1.6s var(--ease) infinite; }
@keyframes ring-pulse {
  0%   { box-shadow: 0 0 0 0 var(--accent-ring); }
  70%  { box-shadow: 0 0 0 18px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.call-party {
  font-size: clamp(26px, 6vw, 32px);
  font-weight: 720;
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.call-state { color: var(--ink-3); font-size: 13.5px; }

/* live audio wave */
.call-wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 26px;
  opacity: .35;
  transition: opacity var(--base);
}
.call-stage[data-state="talking"] .call-wave { opacity: 1; }
.call-wave i {
  width: 4px;
  height: calc(6px + var(--level) * 20px * var(--f, 1));
  border-radius: var(--r-pill);
  background: var(--accent);
  transition: height .09s linear;
}
.call-wave i:nth-child(1), .call-wave i:nth-child(9) { --f: .45; }
.call-wave i:nth-child(2), .call-wave i:nth-child(8) { --f: .7; }
.call-wave i:nth-child(3), .call-wave i:nth-child(7) { --f: .95; }
.call-wave i:nth-child(4), .call-wave i:nth-child(6) { --f: 1.15; }
.call-wave i:nth-child(5) { --f: 1.3; }

.call-tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-2); }
.tool {
  display: grid;
  gap: 5px;
  place-items: center;
  padding: 12px 4px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 620;
  transition: color var(--fast), background var(--fast), border-color var(--fast);
}
.tool:hover:not(:disabled) { color: var(--ink); border-color: var(--line-strong); }
.tool:disabled { opacity: .4; }
.tool[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
#btn-mute[aria-pressed="true"] { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

.call-panel {
  display: grid;
  gap: var(--s-3);
  padding: var(--s-4);
  border-radius: var(--r-md);
  background: var(--surface-inset);
  animation: view-in .2s var(--ease) both;
}
.call-panel-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.dtmf-echo {
  color: var(--ink);
  font-size: 14px;
  font-weight: 660;
  letter-spacing: .12em;
  font-variant-numeric: tabular-nums;
  text-transform: none;
}

.call-primary { display: flex; gap: var(--s-2); }

@media (max-width: 560px) {
  .call-stage { padding: 0; place-items: stretch; }
  .call-card {
    width: 100%;
    max-height: none;
    min-height: 100dvh;
    align-content: center;
    border: 0;
    border-radius: 0;
    padding: calc(var(--s-5) + env(safe-area-inset-top)) var(--s-5)
             calc(var(--s-5) + env(safe-area-inset-bottom));
  }
  .call-avatar { width: 96px; height: 96px; font-size: 34px; }
}

@media (max-height: 620px) and (min-width: 561px) {
  .call-avatar { width: 62px; height: 62px; font-size: 24px; margin-bottom: 0; }
  .call-wave { display: none; }
}
