/* Pronet Call — iOS-style visual layer (loaded after the base styles).
   Apple system colours, SF on Apple devices (IBM Plex Sans Arabic elsewhere), grouped lists, translucent bars,
   round keypad, full-screen call screen, iMessage-style bubbles, bottom tab bar on phones. */

:root {
  --bg: #f2f2f7;
  --bg-grad: none;
  --surface: #ffffff;
  --surface-2: rgba(118, 118, 128, .12);
  --surface-3: rgba(118, 118, 128, .2);
  --text: #000000;
  --text-2: rgba(60, 60, 67, .72);
  --text-3: rgba(60, 60, 67, .48);
  --line: rgba(60, 60, 67, .16);
  --accent: #007aff;
  --accent-soft: rgba(0, 122, 255, .12);
  --green: #34c759;
  --green-soft: rgba(52, 199, 89, .15);
  --red: #ff3b30;
  --red-soft: rgba(255, 59, 48, .12);
  --amber: #ff9500;
  --amber-soft: rgba(255, 149, 0, .14);
  --amber-soft-bg: #fff4e0;
  --key: #e5e5ea;
  --key-press: #c7c7cc;
  --bar: rgba(249, 249, 249, .82);
  --bubble-them: #e9e9eb;
  --shadow: 0 0 0 .5px rgba(0, 0, 0, .04), 0 1px 3px rgba(0, 0, 0, .04);
  --radius: 14px;
  --tabbar-h: 58px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --surface: #1c1c1e; --surface-2: rgba(118, 118, 128, .24); --surface-3: rgba(118, 118, 128, .36);
    --text: #ffffff; --text-2: rgba(235, 235, 245, .7); --text-3: rgba(235, 235, 245, .42); --line: rgba(84, 84, 88, .55);
    --accent: #0a84ff; --accent-soft: rgba(10, 132, 255, .2); --green: #30d158; --green-soft: rgba(48, 209, 88, .2);
    --red: #ff453a; --red-soft: rgba(255, 69, 58, .2); --amber: #ff9f0a; --amber-soft: rgba(255, 159, 10, .2); --amber-soft-bg: #2b2112;
    --key: #333335; --key-press: #5a5a5e; --bar: rgba(22, 22, 24, .84); --bubble-them: #26252a;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --surface: #1c1c1e; --surface-2: rgba(118, 118, 128, .24); --surface-3: rgba(118, 118, 128, .36);
  --text: #ffffff; --text-2: rgba(235, 235, 245, .7); --text-3: rgba(235, 235, 245, .42); --line: rgba(84, 84, 88, .55);
  --accent: #0a84ff; --accent-soft: rgba(10, 132, 255, .2); --green: #30d158; --green-soft: rgba(48, 209, 88, .2);
  --red: #ff453a; --red-soft: rgba(255, 69, 58, .2); --amber: #ff9f0a; --amber-soft: rgba(255, 159, 10, .2); --amber-soft-bg: #2b2112;
  --key: #333335; --key-press: #5a5a5e; --bar: rgba(22, 22, 24, .84); --bubble-them: #26252a;
  --shadow: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Arabic", "IBM Plex Sans Arabic", system-ui, "Segoe UI", Tahoma, sans-serif;
  background: var(--bg); background-image: none; font-size: 16px; letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased;
}

/* ---------- buttons, inputs ---------- */
.btn-primary { border-radius: 12px; height: 50px; font-size: 17px; font-weight: 600; background: var(--accent); }
.btn-sec { border: 0; background: var(--surface-2); color: var(--accent); font-weight: 600; border-radius: 10px; }
.btn-sec.red { color: var(--red); background: var(--red-soft); }
.input { border: 0; background: var(--surface-2); border-radius: 12px; height: 50px; font-size: 17px; }
.input:focus { box-shadow: 0 0 0 2px var(--accent); border-color: transparent; }
.icon-btn { border: 0; background: var(--surface-2); color: var(--accent); border-radius: 50%; }
.icon-btn:hover { background: var(--surface-3); color: var(--accent); }
.chip { border: 0; background: var(--surface-2); font-size: 13px; height: 32px; }
.icon-close { color: var(--text-3); border-radius: 50%; background: var(--surface-2); }

/* ---------- login ---------- */
.login-wrap { background: var(--bg); }
.login { border: 0; box-shadow: none; background: transparent; padding: 24px 8px; max-width: 380px; }
.login .brand { flex-direction: column; text-align: center; gap: 14px; margin-bottom: 30px; }
.login .logo { width: 84px; height: 84px; border-radius: 19px; background: url(/icons/icon.svg) center/cover; box-shadow: 0 10px 30px -10px rgba(75, 47, 209, .55); }
.login .logo svg { display: none; }
.login .brand h1 { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.login .brand p { font-size: 15px; }
.login .field label { font-size: 13px; color: var(--text-3); font-weight: 500; margin: 0 4px 6px; }
.login .input { background: var(--surface); }

/* ---------- top bar (translucent, hairline) ---------- */
.topbar { height: 56px; background: var(--bar); border-bottom: .5px solid var(--line); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); }
.topbar .logo { width: 32px; height: 32px; border-radius: 8px; background: url(/icons/icon.svg) center/cover; box-shadow: none; }
.topbar .logo svg { display: none; }
.topbar h1 { font-size: 17px; font-weight: 600; }

/* ---------- cards → iOS grouped sections ---------- */
.panel { border: 0; border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head h2 { color: var(--text-3); text-transform: none; font-weight: 500; font-size: 13px; }
.seg { background: var(--surface-2); border: 0; border-radius: 9px; padding: 2px; gap: 0; }
.seg button { height: 32px; border-radius: 7px; font-weight: 600; color: var(--text); }
.seg button.on { background: var(--surface); box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 3px 1px rgba(0, 0, 0, .04); }
:root[data-theme="dark"] .seg button.on { background: #636366; }
.stat { border: 0; background: var(--surface-2); border-radius: 12px; }
.logout { border: 0; background: var(--surface-2); color: var(--accent); border-radius: 12px; height: 44px; font-size: 15px; font-weight: 500; }
.logout:hover { background: var(--surface-3); color: var(--accent); border: 0; }
#logoutBtn { color: var(--red); }
.camp-box { border: 0; background: var(--surface-2); border-radius: 12px; }
.camp-select { border: 0; border-radius: 9px; }
.camp-start { border-radius: 10px; }

/* ---------- keypad (iPhone) ---------- */
.dialer { padding: 18px 22px 22px; }
.display input { font-size: 36px; font-weight: 400; letter-spacing: .5px; }
.display input::placeholder { font-size: 20px; color: var(--text-3); }
.display .icon-btn { background: none; color: var(--text-3); }
.pad { grid-template-columns: repeat(3, 78px); justify-content: center; gap: 16px 26px; }
.key { width: 78px; height: 78px; border-radius: 50%; border: 0; background: var(--key); transition: background .25s; }
.key:hover { background: var(--key); }
.key:active { transform: none; background: var(--key-press); transition: none; }
.key b { font-size: 34px; font-weight: 400; line-height: 1; }
.key small { font-size: 9.5px; font-weight: 600; letter-spacing: 2px; color: var(--text); opacity: .9; }
.call-row { margin-top: 20px; }
.call-btn { width: 78px; height: 78px; background: var(--green); box-shadow: none; }
.call-btn svg { width: 32px; height: 32px; fill: #fff; stroke: none; }
.call-btn:disabled { background: var(--green); opacity: .35; color: #fff; }
.hint { font-size: 13px; }
.dtmf .key { width: 64px; height: 64px; }
.dtmf .pad { grid-template-columns: repeat(3, 64px); gap: 12px 22px; }

/* ---------- in-call: dark, blurred, round translucent controls ---------- */
.incall .ctrl i { border: 0; background: var(--surface-2); width: 70px; height: 70px; }
.incall .ctrl.on i { background: var(--text); color: var(--surface); }
.hang-btn { width: 74px; height: 74px; box-shadow: none; }
.hang-btn svg { fill: #fff; stroke: none; }
.peer-avatar { background: linear-gradient(180deg, #a1a1aa, #6e6e76); color: #fff; }

/* ---------- lists (recents) ---------- */
.hist-list { padding: 0; }
.hist-item { border-radius: 0; padding: 11px 16px; position: relative; gap: 12px; }
.hist-item + .hist-item::before { content: ""; position: absolute; top: 0; left: 0; right: 64px; border-top: .5px solid var(--line); }
.hist-item:hover { background: transparent; }
.hist-icon { border-radius: 50%; }
.hist-num { font-size: 16px; }
.hist-call { opacity: 1; color: var(--accent); }
.tabs button { font-size: 15px; border-radius: 7px; }
.tabs button.on { background: var(--surface-2); }

/* ---------- overlays & sheets ---------- */
.overlay { background: rgba(0, 0, 0, .4); backdrop-filter: blur(4px); }
.incoming { border: 0; border-radius: 22px; }
.check, .report, .wrap { border: 0; border-radius: 16px; }
.toast { top: calc(12px + env(safe-area-inset-top)); bottom: auto; border-radius: 999px; padding: 11px 20px; background: var(--bar); color: var(--text);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); box-shadow: 0 8px 30px rgba(0, 0, 0, .18); font-weight: 600; }
.ch-sheet-box { border: 0; border-radius: 16px; }

/* ---------- chat (iMessage) ---------- */
.chat-view { background: var(--bg); }
.ch-side { background: var(--surface); border-left: .5px solid var(--line); }
.ch-top { border-bottom: 0; padding: 14px 16px 6px; }
.ch-top b { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.ch-add { padding: 4px 16px 10px; }
.ch-add .input { height: 38px; font-size: 16px; border-radius: 10px; }
.ch-add .btn-primary { height: 38px; border-radius: 10px; }
.ch-sec { color: var(--text-3); font-size: 13px; font-weight: 500; text-transform: none; }
.ch-item { border-radius: 0; position: relative; padding: 10px 12px; }
.ch-open:hover, .ch-open.on { background: var(--surface-2); border-radius: 12px; }
.ch-n { background: var(--accent); }
.ch-head { background: var(--bar); border-bottom: .5px solid var(--line); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); }
.ch-msgs { gap: 4px; padding: 14px 12px; }
.ch-b { border-radius: 19px; padding: 7px 13px; font-size: 16px; line-height: 1.35; max-width: min(78%, 440px); }
.ch-b.mine { background: var(--accent); border-bottom-right-radius: 19px; border-bottom-left-radius: 6px; }
.ch-b.theirs { background: var(--bubble-them); border: 0; border-bottom-left-radius: 19px; border-bottom-right-radius: 6px; }
.ch-foot { font-size: 11px; }
.ch-comp { background: var(--bar); border-top: .5px solid var(--line); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); }
.ch-comp textarea { border-radius: 19px; border: .5px solid var(--line); background: var(--surface); min-height: 38px; padding: 8px 14px; font-size: 16px; }
.ch-ic { border: 0; background: transparent; color: var(--accent); width: 38px; height: 38px; }
.ch-send { background: var(--accent); color: #fff; border-radius: 50%; transform: none; }
.ch-trust, .ch-e2e { background: var(--amber-soft-bg); border-bottom: .5px solid var(--line); }
.ch-sys { background: transparent; color: var(--text-3); font-size: 12px; }
.ch-lockbar { background: transparent; border-bottom: 0; padding: 0 16px 10px; }
.ch-lockbar #chUnlock { background: var(--green); border-radius: 12px; height: 44px; font-size: 16px; }
.ch-lockbar #chLogout { border-radius: 12px; height: 44px; background: var(--surface-2); color: var(--red); }

/* ---------- bottom tab bar (phones) ---------- */
.tabbar { display: none; }
.large-title { display: none; }
@media (max-width: 720px) {
  .main { padding: 4px 16px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); gap: 14px; align-content: start; }
  .topbar { height: 50px; padding: 0 12px; }
  .topbar .brand { display: none; }
  .top-actions { width: 100%; justify-content: space-between; }
  .large-title { display: block; order: -2; font-size: 32px; font-weight: 700; letter-spacing: -.02em; padding: 8px 2px 0; }
  body[data-tab="keypad"] .large-title { display: none; }           /* the iPhone keypad has no title */
  #chatBtn { display: none; }                                         /* chats live in the tab bar */
  .top-actions { gap: 6px; }
  html, body { overflow-x: hidden; }
  .chip .chip-text { display: none; }
  #phoneChip .chip-text { display: inline; font-size: 12.5px; }
  .chip { padding: 0 9px; height: 30px; flex-shrink: 0; }
  .topbar { overflow: hidden; }
  #themeBtn { width: 30px; height: 30px; margin-inline-start: auto; }

  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; z-index: 28; left: 0; right: 0; bottom: 0;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--bar); border-top: .5px solid var(--line); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  }
  .tabbar button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: #999; font-size: 10.5px; font-weight: 500; }
  .tabbar button svg { width: 26px; height: 26px; stroke-width: 1.8; }
  .tabbar button.on { color: var(--accent); }
  .tabbar button.on svg { stroke-width: 2.2; }
  .tabbar .tb-badge { position: absolute; top: 4px; left: calc(50% - 22px); min-width: 18px; height: 18px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; font-style: normal; font-weight: 600; display: grid; place-items: center; padding: 0 5px; }
  .tabbar .tb-badge:empty { display: none; }

  /* one screen per tab */
  body[data-tab="keypad"] .agent-col, body[data-tab="keypad"] .hist-col,
  body[data-tab="recents"] .agent-col, body[data-tab="recents"] .phone-col,
  body[data-tab="me"] .phone-col, body[data-tab="me"] .hist-col { display: none; }
  body.sip-call .agent-col, body.sip-call .hist-col { display: none; }
  body.sip-call .phone-col { display: block; }
  body.sip-call .tabbar, body.phone-locked .tabbar { display: none; }
  body.sip-call .large-title { display: none; }

  /* keypad sits on the page like the iPhone Phone app */
  .phone-col .dialer { background: transparent; box-shadow: none; padding: 6px 0 0; }
  .display { height: 72px; }
  .phone-lock { background: color-mix(in srgb, var(--bg) 90%, transparent); }

  /* recents and "me" as inset grouped lists */
  .history { background: var(--surface); }
  .agent { background: var(--surface); }

  /* full-screen call like iOS */
  .incall { position: fixed; inset: 0; z-index: 26; border-radius: 0; padding: calc(70px + env(safe-area-inset-top)) 24px calc(40px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, #3a3d46 0%, #1b1c20 60%, #0f1013 100%); color: #fff; display: flex; flex-direction: column; align-items: center; overflow: auto; }
  .incall.hidden { display: none; }
  .incall .peer-num { font-size: 34px; font-weight: 400; }
  .incall .call-state { color: rgba(255, 255, 255, .7); font-size: 17px; }
  .incall .call-state.live { color: rgba(255, 255, 255, .85); font-size: 17px; font-weight: 500; }
  .incall .call-state .dial-t { color: #fff; }
  .incall .ctrls { gap: 20px 22px; margin: auto 0 28px; grid-template-columns: repeat(3, 76px); justify-content: center; }
  .incall .ctrl { color: #fff; font-size: 12.5px; }
  .incall .ctrl i { width: 76px; height: 76px; background: rgba(255, 255, 255, .16); color: #fff; backdrop-filter: blur(10px); }
  .incall .ctrl.on i { background: #fff; color: #000; }
  .incall .ctrl svg { width: 28px; height: 28px; }
  .incall .quality { background: rgba(255, 255, 255, .12); color: rgba(255, 255, 255, .8); }
  .incall .dtmf .key { background: rgba(255, 255, 255, .16); color: #fff; }
  .incall .dtmf .key small { color: #fff; }
  .incall .mon-btns3 button { background: rgba(255, 255, 255, .14); border: 0; color: #fff; }
  .incall .mon-btns3 button.on { background: #fff; color: #000; }
  .incall .transfer .input { background: rgba(255, 255, 255, .14); color: #fff; }

  /* chat as the "Chats" tab: list sits above the tab bar; inside a conversation the bar hides */
  body[data-tab="chat"]:not(.phone-locked) .chat-view:not(.in-convo) { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  body[data-tab="chat"] #chClose { display: none; }
  .chat-view.in-convo ~ .tabbar { display: none; }
  .ch-sheet { place-items: end center; padding: 0; }
  .ch-sheet-box { width: 100%; border-radius: 14px 14px 0 0; padding-bottom: calc(18px + env(safe-area-inset-bottom)); animation: sheetUp .28s cubic-bezier(.2, .9, .3, 1); }
  .ch-sheet-box::before { content: ""; display: block; width: 36px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: -8px auto 4px; }
}
@keyframes sheetUp { from { transform: translateY(100%); } }

.ch-dev-btn { display: grid; place-items: center; color: var(--accent); }
.ch-dev-btn svg { width: 18px; height: 18px; }
.ch-top .ch-me { order: 3; margin-inline-start: 0; }
@media (max-width: 720px) {
  body[data-tab="chat"] .agent-col, body[data-tab="chat"] .hist-col, body[data-tab="chat"]:not(.sip-call) .phone-col { display: none; }
}

/* chat line icons */
.ch-ic svg { width: 24px; height: 24px; stroke-width: 1.9; }
.ch-head .ch-ic { width: 36px; height: 36px; }
.ch-back { background: none; color: var(--accent); width: 34px; }
.ch-back svg { width: 24px; height: 24px; stroke-width: 2.4; }
#chShield .sh-ok { display: none; }
#chShield[data-state="ok"] { color: var(--green); } #chShield[data-state="ok"] .sh-ok { display: inline; }
#chShield[data-state="bad"] { color: var(--amber); }
#chTimer { display: inline-flex; align-items: center; gap: 2px; width: auto; padding: 0 6px; color: var(--accent); }
#chTimer.hidden { display: none; }
#chTimer svg { width: 20px; height: 20px; }
#chTimerLbl { font-size: 11px; font-weight: 700; }
#chAttach .fill-soft { fill: var(--surface-2); stroke: none; }
#chAttach svg { width: 30px; height: 30px; }
.ch-send svg { width: 20px; height: 20px; stroke-width: 2.6; }
#chMic.rec { background: var(--red); color: #fff; border-radius: 50%; }

/* iPhone notch / Dynamic Island: keep content out of the status-bar area (no effect where there is no inset) */
.topbar { padding-top: env(safe-area-inset-top); height: calc(56px + env(safe-area-inset-top)); }
.ch-side { padding-top: env(safe-area-inset-top); }
.ch-head { padding-top: calc(12px + env(safe-area-inset-top)); }
.login-wrap { padding-top: calc(24px + env(safe-area-inset-top)); }
.overlay { padding-top: calc(16px + env(safe-area-inset-top)); }
@media (max-width: 720px) {
  .topbar { height: calc(50px + env(safe-area-inset-top)); }
  .chat-view.in-convo .ch-side { padding-top: 0; }
}
@media (min-width: 721px) { .ch-head { padding-top: 12px; } .ch-side { padding-top: 0; } .chat-view { padding-top: env(safe-area-inset-top); } }

.update-bar { position: fixed; z-index: 45; left: 12px; right: 12px; top: calc(10px + env(safe-area-inset-top)); padding: 12px 16px; border-radius: 14px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 14px; text-align: center; text-decoration: none; box-shadow: 0 8px 24px rgba(0,0,0,.25); }

/* phone sign-in removed: no lock chip / lock overlay / chat lock bar */
#phoneChip, #phoneLock, .ch-lockbar { display: none !important; }
.login-who { margin: 0 4px 14px; font-size: 14px; color: var(--text-2); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.login-who button { color: var(--accent); font-weight: 600; margin-inline-start: auto; }

/* caller ID picker */
.cli-pill { display: flex; align-items: center; gap: 6px; margin: -6px auto 14px; padding: 6px 14px; border-radius: 999px; background: var(--surface-2); font-size: 13px; color: var(--text-2); }
.cli-pill b { color: var(--accent); font-weight: 700; }
.cli-pill i { font-style: normal; color: var(--text-3); font-size: 11px; }
.cli-pill.hidden { display: none; }
.cli-list { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow: auto; }
.cli-opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 14px; border-radius: 12px; background: var(--surface-2); font-size: 16px; text-align: start; }
.cli-opt.on { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.cli-opt small { color: var(--text-3); font-size: 12px; font-weight: 400; }
.cli-confirm { display: flex; flex-direction: column; gap: 10px; text-align: center; font-size: 15px; }
.cli-confirm small { color: var(--text-3); }
