/* ==========================================================================
   cloud5060 WebRTC Phone — Teams-native light theme
   Matches the visual language of Teams personal apps like the built-in
   Calls app (secondary nav rail + docked dialpad + content pane + table).
   ========================================================================== */

:root{
  --bg:            #ffffff;
  --content-bg:    #f7f8f9;
  --sidepane-bg:   #ffffff;
  --border:        #e2e5ea;
  --border-soft:   #edeff2;

  --text:          #242424;
  --text-heading:  #1b3a57;
  --text-muted:    #616770;
  --text-faint:    #8a93a0;

  --accent:        #5b5fc7;
  --accent-dim:    #464775;
  --accent-glow:   rgba(91,95,199,.18);
#domain{ color: var(--text-faint); }
  --danger:        #d13438;
  --danger-dim:    #a42a2d;
  --warning:       #c98a1a;
  --warning-dim:   #a06f14;
  --success:       #2e8b47;
  --success-dim:   #23723a;
  --info:          #3b6fb6;
  --info-dim:      #2c5590;
  --neutral:       #f1f2f4;
  --neutral-hi:    #e6e8eb;

  --highlight-bg:      #f7dfb4;
  --highlight-border:  #e0a13c;

  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;

  --radius-lg: 10px;
  --radius-md: 8px;
  --radius-sm: 6px;
  --shadow-card: 0 8px 28px -14px rgba(20,30,45,.22), 0 0 0 1px rgba(20,30,45,.04);
}

@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{ animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

*{ box-sizing: border-box; }

/* Belt-and-suspenders against the mobile double-tap-to-zoom bug (rapid
   taps on the keypad getting interpreted as a zoom gesture) — the
   viewport meta tag's user-scalable=no handles most browsers, but some
   Android Chrome versions have needed this too. touch-action:
   manipulation tells the browser these elements only ever get taps, not
   zoom/pan gestures, so it skips the double-tap-zoom detection delay
   entirely rather than just suppressing the zoom after detecting it. */
button, .keypad, .icon-btn{ touch-action: manipulation; }

html, body{
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body{ overflow: hidden; }
a{ color: var(--accent); }

/* -- app shell ---------------------------------------------------------- */
.appshell{
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.topbar{
  display: flex; align-items: center;
  height: 48px; min-height: 48px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.topbar__brand{ display: flex; align-items: center; gap: 10px; }
.topbar__mark{
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(155deg, var(--accent), var(--info));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 12px;
}
.topbar__title{ font-weight: 700; font-size: 15px; color: var(--text-heading); }

/* -- centered panes (sign in / in call) ---------------------------------*/
.pane-center{
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  background: var(--content-bg);
  overflow-y: auto;
}

.card{
  width: 100%; max-width: 380px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 22px;
}

.section-title{
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin: 0 0 12px;
}

/* -- fields ---------------------------------------------------------------*/
.field{ margin-bottom: 12px; text-align: left; }

.signin-error{
  background: #fbe9ea;
  border: 1px solid var(--danger, #d13438);
  color: var(--danger-dim, #a42a2d);
  border-radius: var(--radius-sm, 6px);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.4;
  margin-bottom: 14px;
  text-align: left;
}
.field label{
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
}
input[type="text"], input[type="password"], input[type="tel"], input:not([type]){
  width: 100%;
  background: #fff;
  border: 1px solid #c9ccd1;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input::placeholder{ color: var(--text-faint); }
input:focus{
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* -- buttons ----------------------------------------------------------- */
.btn{
  appearance: none;
  border: 1px solid rgba(0,0,0,.06);
  background: var(--neutral);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  cursor: pointer;
  transition: filter .15s ease, transform .06s ease;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
}
.btn:hover{ filter: brightness(0.97); }
.btn:active{ transform: translateY(1px); }
.btn:focus-visible{ outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-block{ width: 100%; }
.btn-sm{ padding: 7px 10px; font-size: 12px; }

.btn-primary{ background: var(--accent); color: #fff; }
.btn-success{ background: var(--success); color: #fff; }
.btn-danger{ background: var(--danger); color: #fff; }
.btn-warning{ background: #fff2df; color: var(--warning-dim); border-color: #f0dcb2; }
.btn-info{ background: #e8f0fb; color: var(--info-dim); border-color: #cfe0f5; }
.btn-default{ background: #fff; border-color: #c9ccd1; color: var(--text); }
.btn-ghost{ background: transparent; border-color: #c9ccd1; color: var(--text-muted); }

.link-btn, .link-btn-sm{
  background: none; border: none; color: var(--accent);
  cursor: pointer; padding: 4px 0; text-align: left;
}
.link-btn{ font-size: 13px; }
.link-btn-sm{ font-size: 12px; display: block; width: 100%; margin-top: 6px; }

.download-agent-link{
  display: block;
  margin-top: 10px;
  font-size: 10.5px;
  color: var(--text-faint);
  text-decoration: none;
}
.download-agent-link:hover{
  color: var(--text-muted);
  text-decoration: underline;
}
.keypad-toggle{ display: none; } /* only shown on narrow/stacked layouts, see media query */

/* icon buttons (call / backspace / settings) */
.icon-btn{
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid #c9ccd1;
  background: #fff;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: filter .15s ease, transform .06s ease;
}
.icon-btn:hover{ filter: brightness(0.97); }
.icon-btn:active{ transform: translateY(1px); }
.icon-btn--call{ background: var(--success); border-color: var(--success); color: #fff; }
.icon-btn--hangup{
  background: var(--danger); border-color: var(--danger); color: #fff;
  transform: rotate(135deg); /* universal "handset placed down" hang-up convention */
}
.icon-btn--hangup:hover{ filter: brightness(1.05); transform: rotate(135deg); }
.icon-btn--hangup:active{ transform: rotate(135deg) translateY(1px); }
.icon-btn--ghost{ border: none; background: transparent; width: 32px; height: 32px; font-size: 15px; }

/* -- native-Teams-style 3-column Calls shell -----------------------------
   Dialer (left) | History (center) | Speed dial + Contacts (right).
   Replaces the old two-pane .appbody/.sidepane layout — those rules above
   are now unused (left in place rather than risk breaking something by
   deleting; harmless dead CSS). */
.callsapp{
  flex: 1;
  display: grid;
  grid-template-columns: 280px 1fr 690px;
  overflow: hidden;
}

.callsapp__dialer{
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Narrow-width tab switcher — see the media query below for where this
   actually takes effect. Hidden by default (wide-width, 3-column
   layout unchanged from before). */
.callsapp__tabs{
  display: none;
  grid-column: 1 / -1;
  border-bottom: 1px solid var(--border);
}
.callsapp__tab{
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 12px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}
.callsapp__tab.is-active{
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Below this width the fixed 280px + 690px side columns can no longer
   both fit alongside the middle pane at any usable size — this is the
   actual previous bug: at a real Teams personal-tab width, History and
   Contacts weren't just visually cramped, they were being clipped
   completely off-screen by the grid's overflow:hidden with no way to
   reach them at all. Below the breakpoint, switch to one pane at a
   time via the tab bar instead of three fixed-width columns fighting
   for space that doesn't exist. 1300px matches (and replaces) an
   earlier, separate responsive attempt that stacked all three panes
   vertically instead — that approach left History/Contacts reachable
   only by scrolling past whatever was showing above them, which is
   why it's been replaced here rather than left running alongside this. */
@media (max-width: 1300px){
  .callsapp{
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .callsapp__tabs{
    display: flex;
  }
  .callsapp__dialer,
  .callsapp__history,
  .callsapp__speeddial{
    display: none;
    border-right: none;
    min-width: 0;
  }
  .callsapp__dialer.is-active-pane{
    display: flex;
  }
  .callsapp__history.is-active-pane,
  .callsapp__speeddial.is-active-pane{
    display: block;
  }
}

.callsapp__status-line{
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  min-height: 18px;
  margin-bottom: 10px;
}
.callsapp__status-line:empty::before{ content: "—"; color: var(--text-faint); }

.dialer__search{ margin-bottom: 14px; }
.dialer__search input{
  width: 100%;
  background: var(--content-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
}

.callsapp__keypad{ margin: 0 auto 12px; max-width: 260px; }

.callsapp__meta{
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}
.callsapp__row{
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
}
.callsapp__row:last-child{ border-bottom: none; }
.callsapp__row-label{
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-faint);
}
.callsapp__agent-status{
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.callsapp__agent-status .status-dot{
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success);
  flex: none;
}

.callsapp__oncall-row{ background: #f7f8ff; margin: 0 -8px; padding: 8px !important; border-radius: 8px; }
.callsapp__oncall-inline{
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
}
.callsapp__oncall-inline span{
  font-size: 13px; font-weight: 600; color: var(--text-heading);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.icon-btn--sm{ width: 26px; height: 26px; font-size: 11px; flex: none; }

.callsapp__history{
  padding: 20px 24px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
}
.callsapp__history-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.history-filters{ display: flex; gap: 6px; flex-wrap: wrap; }
.filter-pill{
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.filter-pill:hover{ background: var(--content-bg); }
.filter-pill.is-active{
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.callsapp__speeddial{
  padding: 16px;
  overflow-y: auto;
}
.callsapp__speeddial-header{
  margin-top: 22px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.callsapp__speeddial-title{ font-size: 15px; margin: 0; }

/* -- two-pane app body (the "dial" panel) — superseded by .callsapp above,
   kept only because removing it risks nothing but tidies nothing either */
.appbody{
  flex: 1;
  display: flex;
  overflow: hidden;
}

.sidepane{
  width: 300px;
  min-width: 300px;
  background: var(--sidepane-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.navlist{ padding: 8px; }
.navlist__item{
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  text-align: left;
  border: none; background: transparent;
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  color: var(--text);
  cursor: pointer;
  border-left: 3px solid transparent;
}
.navlist__item.is-active{
  background: var(--highlight-bg);
  border-left: 3px solid var(--highlight-border);
  color: var(--text-heading);
}
.navlist__icon{ font-size: 14px; }

.dialpad-dock{
  margin-top: auto;
  border-top: 1px solid var(--border-soft);
  padding: 14px;
}

.readout{ margin-bottom: 10px; }
.readout__row{ display: flex; justify-content: space-between; margin-bottom: 4px; }
.readout__id{ font-size: 11px; color: var(--text-muted); font-weight: 600; }
.readout__screen{
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--text-heading);
  min-height: 22px;
}
.readout__screen:empty::before{ content: "—"; color: var(--text-faint); }

.dock-number{
  text-align: center;
  margin-bottom: 10px;
  background: var(--content-bg);
}

.dockrow{ display: flex; gap: 10px; justify-content: center; margin-bottom: 10px; }
.dockrow--wrap{ flex-wrap: wrap; }
.dockrow .btn{ flex: 1; }

.keypad{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.keypad--dock{ margin: 0 auto 8px; max-width: 260px; }
.keypad .btn{
  aspect-ratio: 1 / 1;
  max-width: 76px;
  max-height: 76px;
  background: #fff;
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}
.keypad .btn:hover{ background: var(--content-bg); }

.advanced{ margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border); }
.advanced-grid{ display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.advanced-grid .field-inline label{
  font-size: 10.5px; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: .05em; margin-bottom: 4px; display: block;
}
.advanced-grid input{ font-size: 13px; padding: 8px 10px; }

.mic-panel{ margin-top: 10px; font-size: 12.5px; color: var(--text-muted); }
.mic-panel select{
  width: 100%; background: #fff; border: 1px solid #c9ccd1;
  color: var(--text); padding: 8px 10px; border-radius: var(--radius-sm); margin-top: 6px;
}

.incoming-caller{ text-align: center; padding: 8px 4px; }
.incoming-caller__label{
  font-size: 11px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-muted); margin-bottom: 8px;
}
.ring-indicator{ display: flex; justify-content: center; gap: 5px; margin-bottom: 10px; }
.ring-indicator span{
  width: 5px; height: 18px; border-radius: 3px;
  background: var(--warning);
  animation: bounce 1s ease-in-out infinite;
  opacity: .4;
}
.ring-indicator span:nth-child(2){ animation-delay: .12s; }
.ring-indicator span:nth-child(3){ animation-delay: .24s; }
.ring-indicator span:nth-child(4){ animation-delay: .36s; }
.ring-indicator span:nth-child(5){ animation-delay: .48s; }
@keyframes bounce{ 0%,100%{ transform: scaleY(.4); opacity:.4; } 50%{ transform: scaleY(1); opacity: 1; } }

/* -- content pane (Microsoft 365 Contacts) -------------------------------*/
.contentpane{
  flex: 1;
  background: var(--content-bg);
  padding: 22px 28px;
  overflow-y: auto;
}
.contentpane__title{
  font-size: 22px; font-weight: 700;
  color: var(--text-heading);
  margin: 0 0 14px;
}
.contentpane__divider{
  height: 1px; background: var(--border);
  margin-bottom: 16px;
}

.searchbar{
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid #c9ccd1;
  border-radius: 18px;
  padding: 7px 12px;
  max-width: 420px;
  margin-bottom: 18px;
}
.searchbar__icon{ color: var(--text-faint); font-size: 14px; }
.searchbar input{ border: none; padding: 2px 0; flex: 1; }
.searchbar input:focus{ box-shadow: none; }
.searchbar .icon-btn{ margin-left: auto; }

.settings-panel{
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  max-width: 420px;
  margin-bottom: 16px;
  font-size: 13px;
}
.settings-panel__row{ display: flex; justify-content: space-between; margin-bottom: 6px; }
.settings-panel__note{ color: var(--text-muted); font-size: 12px; }

.contacts-table{
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 4px;
}
.contacts-table thead th{
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-heading);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.contacts-table tbody td{
  padding: 9px 10px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-soft);
}

.presence-dot{
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 7px;
  vertical-align: middle;
}
.presence-dot--available{ background: var(--success); box-shadow: 0 0 0 2px rgba(46,139,71,.15); }
.presence-dot--busy{ background: var(--danger); box-shadow: 0 0 0 2px rgba(209,52,56,.15); }
.presence-dot--away{ background: var(--warning); box-shadow: 0 0 0 2px rgba(201,138,26,.15); }
.presence-dot--offline{ background: var(--text-faint); }
.presence-dot--unknown{ background: var(--border); }

.empty-state{
  text-align: center;
  font-weight: 700;
  color: var(--text-heading);
  padding: 60px 10px;
}

.blf-list{ display: flex; flex-direction: column; gap: 6px; max-width: 420px; }

.history-list{ display: flex; flex-direction: column; gap: 4px; max-width: 420px; }
.history-row{
  display: flex; align-items: center; gap: 12px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.history-row:hover{ background: var(--content-bg); }
.history-row__icon{
  width: 22px; height: 22px; flex: none;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  background: var(--neutral);
  color: var(--text-muted);
}
.history-row--outbound .history-row__icon{ background: #e8f0fb; color: var(--info-dim); }
.history-row--inbound .history-row__icon{ background: #e8f6ec; color: var(--success-dim); }
.history-row--missed .history-row__icon{ background: #fbe9ea; color: var(--danger-dim); }
.history-row__info{ font-size: 13px; }
.history-row__info b{ font-weight: 600; color: var(--text-heading); }
.history-row__time{ font-size: 11px; color: var(--text-faint); }
.history-empty{ text-align: center; color: var(--text-faint); padding: 30px 10px; font-size: 13px; }
.blf-list .btn{ justify-content: flex-start; text-align: left; }

/* -- speaking-with / in-call -------------------------------------------- */
.speaking-with{ text-align: center; padding: 4px 4px 16px; }
.speaking-with__label{
  font-size: 11px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-muted); margin-bottom: 6px;
}
.speaking-with__name{ font-size: 18px; font-weight: 700; color: var(--text-heading); }

.footer-note{
  text-align: center; color: var(--text-faint); font-size: 11.5px;
  margin-top: 16px;
}
.footer-note b{ color: var(--text-muted); }

.notify-cta{ margin-top: 10px; }

.modal-overlay{
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 30, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 16px;
}
.modal-box{
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 22px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.modal-box__title{ margin: 0 0 10px; font-size: 16px; color: var(--text-heading); }
.modal-box__body{ font-size: 13px; line-height: 1.5; color: var(--text); margin: 0 0 10px; }
.modal-box__body--muted{ color: var(--text-muted); font-size: 12px; }
.modal-box__actions{ display: flex; gap: 8px; margin-top: 14px; }
.modal-box__actions .btn{ flex: 1; }
.modal-box__status{ font-size: 12px; margin-top: 10px; min-height: 16px; }
.modal-box__status--ok{ color: var(--success); }
.modal-box__status--warn{ color: var(--warning-dim); }
.modal-box__status a{ color: var(--accent); font-weight: 600; }

.hide-all{
  position: fixed; inset: 0;
  background: #fff;
  z-index: 99;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
}

.teams-only-block{
  position: fixed; inset: 0;
  background: #fff;
  z-index: 9999; /* above .hide-all (99) and .modal-overlay (999) — must win regardless of what else is happening underneath */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.teams-only-block__box{ max-width: 360px; text-align: center; }
.teams-only-block__box .topbar__brand{ justify-content: center; margin-bottom: 18px; }
.teams-only-block__title{ font-size: 17px; color: var(--text-heading); margin: 0 0 10px; }
.teams-only-block__body{ font-size: 13px; color: var(--text-muted); line-height: 1.5; margin: 0; }
.embed-audio{ display: none; }

.visually-hidden{
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0; padding: 0; margin: -1px;
}

@media (max-width: 720px){
  .appbody{ flex-direction: column; overflow-y: auto; }
  .sidepane{ width: 100%; min-width: 0; border-right: none; border-bottom: 1px solid var(--border); }
  .dialpad-dock{ max-width: 320px; margin-left: auto; margin-right: auto; }
  .contentpane{ padding: 18px; }

  .keypad-toggle{ display: block; text-align: center; }
  #dockExpandable{ display: none; }
  #dockExpandable.is-expanded{ display: block; }
}
