/* Helios agent panel as an installable app (agent-app.js, docs/AGENT_APP.md).
   Lagoon tokens only, so light and dark both work. Phones (<= 640 px) get
   a one-handed layout: the most used controls in a dock at the bottom of the
   screen, within thumb reach, and sheets that slide up from the bottom. */

/* ---------- installed app: respect the notch and the home indicator ---------- */
body.agent-panel {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
@media (display-mode: standalone) {
  body.agent-panel { padding-top: env(safe-area-inset-top); }
  .ag-head { margin-top: 10px; }
}

/* ---------- banner: network, line and update news ---------- */
.app-banner {
  max-width: 1240px; margin: 12px auto 0; padding: 8px 8px 8px 18px; border-radius: var(--radius-md);
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-weight: 800; font-size: 15px;
  background: var(--call-soft); color: var(--call-text); box-sizing: border-box; width: calc(100% - 32px);
}
.app-banner.hidden { display: none; }
.app-banner-text { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.app-banner.tone-ok { background: var(--ok-soft); color: var(--ok-text); }
.app-banner.tone-warn { background: var(--warn-soft); color: var(--warn-text); }
.app-banner.tone-bad { background: var(--bad-soft); color: var(--bad-text); }
.app-banner button.ghost { color: inherit; }

/* ---------- sign-in additions ---------- */
.app-mic { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.app-mic.hidden { display: none; }
.app-help, .app-install {
  margin-top: 12px; padding: 14px 16px; border-radius: var(--radius-md); background: var(--warn-soft); color: var(--warn-text);
}
.app-install { background: var(--accent-soft); color: var(--accent-strong); margin: 0 0 16px; }
.app-help p { margin: 6px 0 0; }
.app-steps { margin: 8px 0; padding-left: 22px; }
.app-steps li { margin: 4px 0; }
#installBtn { margin: 6px 0 0; }
.app-quick-more { justify-content: space-between; margin-top: 12px; }
#quickCard, #loginCard { max-width: 520px; width: 100%; justify-self: center; box-sizing: border-box; }

/* ---------- supervisor message ---------- */
.app-msg { border: 2px solid var(--coral); }
.app-msg-text { font-size: 18px; font-weight: 800; margin: 0 0 12px; overflow-wrap: anywhere; }

/* ---------- sheets (bottom sheets on phones, dialogs on desktops) ---------- */
.app-backdrop { position: fixed; inset: 0; background: rgba(6, 20, 20, 0.45); z-index: 60; }
.app-backdrop.hidden, .app-sheet.hidden, .app-dock.hidden { display: none; }
.app-sheet {
  position: fixed; z-index: 61; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(520px, calc(100% - 32px)); max-height: calc(100% - 48px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--panel); color: var(--text); border-radius: var(--radius); box-shadow: var(--shadow-lift);
  padding: 18px 20px 20px; box-sizing: border-box;
}
.app-sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.app-sheet-head h2 { flex: 1; margin: 0; font-size: 19px; }
.app-sheet-head button { min-width: 44px; min-height: 44px; color: var(--text); }
.app-sheet h3 { font-size: 16px; margin: 18px 0 6px; }
.app-sheet .sub { margin: 4px 0 8px; }
.app-account { margin-top: 18px; }
.app-limits { margin-top: 18px; }
.app-limits summary { cursor: pointer; font-weight: 800; min-height: 44px; display: flex; align-items: center; }
.app-version { margin-top: 14px; font-size: 13px; }
.app-version:empty { display: none; }
.app-reasons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 8px; }
.app-reasons button { min-height: 60px; font-size: 17px; }
.app-keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 8px; }
.app-keypad button { min-height: 60px; font-size: 24px; border-radius: 20px; }
.app-keyecho { display: block; min-height: 32px; font-size: 22px; text-align: center; letter-spacing: 2px; }
/* The transfer picker moved into its sheet. */
#xferRow.app-in-sheet { margin: 0; background: transparent; padding: 0; }

/* ---------- dock (phones only) ---------- */
.app-dock { display: none; }

@media (max-width: 640px) {
  /* Room under the content for the dock and the home indicator. */
  body.app-has-dock { padding-bottom: calc(108px + env(safe-area-inset-bottom)); }
  .app-dock {
    position: fixed; z-index: 50; left: 0; right: 0; bottom: 0;
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px;
    padding: 10px calc(10px + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left));
    background: var(--panel); box-shadow: 0 -4px 22px rgba(15, 42, 42, 0.14); border-radius: 24px 24px 0 0;
  }
  .app-dbtn {
    min-height: 64px; padding: 6px 4px; border-radius: 18px; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 2px; font-size: 13px; font-weight: 800; line-height: 1.15; min-width: 0;
  }
  .app-dicon { font-size: 20px; line-height: 1; }
  .app-dlabel { overflow-wrap: anywhere; text-align: center; }
  .app-dbtn.wide { min-height: 68px; font-size: 17px; flex-direction: row; gap: 8px; }
  .app-dbtn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
  .app-dbtn.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok-text); }
  .app-dbtn.danger { color: var(--on-strong); }
  .app-dbtn.primary .app-dicon, .app-dbtn.danger .app-dicon { color: inherit; }

  /* Bottom sheets. */
  .app-sheet {
    left: 0; right: 0; top: auto; bottom: 0; transform: none; width: 100%; max-height: 88vh;
    border-radius: 24px 24px 0 0; padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }

  /* Compact header: state on the left, the App menu on the right. The dock
     has Ready and Break, the App sheet has Change PIN and Log out. */
  body.app-has-dock .ag-head .ag-pause,
  body.app-has-dock .ag-head #resumeBtn,
  body.app-has-dock .ag-head #pinBtn,
  body.app-has-dock .ag-head #logoutBtn { display: none; }
  .ag-head { margin: calc(8px + env(safe-area-inset-top, 0px)) 10px 0; }
  .ag-top { flex: 1 1 auto; }
  .ag-top #appBtn { margin-left: auto; min-height: 44px; }
  .ag-stats { font-size: 14px; flex: 1 1 auto; }
  .ag-main { padding: 12px 10px 24px; gap: 12px; }
  .ag-work, .ag-col { gap: 12px; }
  .card { padding: 16px; border-radius: 22px; }
  .app-banner { width: calc(100% - 20px); }

  /* The call card: the dock has the controls, so the card is the lead. */
  body.app-has-dock #callActions,
  body.app-has-dock #xferRow:not(.app-in-sheet),
  body.app-has-dock #dtmfRow { display: none; }
  .ag-name { font-size: 22px; }
  .ag-avatar { width: 48px; height: 48px; font-size: 18px; }
  .ag-fields { gap: 6px; }

  /* Wrap-up: big outcome buttons, two per row. */
  .ag-dispos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .ag-dispos button { min-height: 52px; margin: 0; white-space: normal; }
  body.app-has-dock #disposeBtn { display: none; }

  /* Callbacks: each one a comfortable row. */
  .ag-cblist li { padding: 12px 0; flex-wrap: wrap; }
}

/* Phones: the sheet slides up (never fades, so it is always opaque). */
@media (max-width: 640px) and (prefers-reduced-motion: no-preference) {
  .app-sheet:not(.hidden) { animation: app-up .18s ease-out; }
  @keyframes app-up { from { transform: translateY(40px); } to { transform: none; } }
}
