/* vAvtobyse 2.9.19 — one bus brand across logos and presence states. */
:root {
  --vav-brand-bus: url("brand/vavtobyse-bus-icon-master.png?v=brand-bus-lastseen-v33-20260812");
}

/* Title and modal marks keep their existing frame, but always use the master bus. */
html[data-theme] .qip-logo {
  color: transparent !important;
  font-size: 0 !important;
  text-shadow: none !important;
  background-image: var(--vav-brand-bus) !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  background-size: calc(100% - 4px) calc(100% - 4px) !important;
}

/* The welcome screen uses the same asset instead of a different bus emoji. */
.vav-welcome-bus {
  display: block !important;
  width: 50px !important;
  height: 50px !important;
  object-fit: contain !important;
}

/* Presence keeps one yellow bus; the small badge communicates the state. */
.bus-presence {
  --vav-status-color: #607d8b;
  position: relative !important;
  display: inline-grid !important;
  place-items: center !important;
  overflow: visible !important;
  border-radius: 7px !important;
}
.bus-presence.bus-green { --vav-status-color: #42b95c; }
.bus-presence.bus-yellow { --vav-status-color: #e1ad35; }
.bus-presence.bus-blue,
.bus-presence.bus-cyan { --vav-status-color: #3d9ee8; }
.bus-presence.bus-purple { --vav-status-color: #9167d8; }
.bus-presence.bus-orange { --vav-status-color: #e27d36; }
.bus-presence.bus-red { --vav-status-color: #db4d49; }
.bus-presence.bus-gray { --vav-status-color: #69757c; }

.bus-presence .brand-bus-status-image {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  object-fit: contain !important;
  border: 0 !important;
  border-radius: 6px !important;
  background: transparent !important;
  box-shadow: none !important;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.38)) !important;
  image-rendering: auto !important;
  pointer-events: none !important;
}

.bus-presence::after {
  content: '•';
  position: absolute;
  right: -4px;
  bottom: -4px;
  z-index: 2;
  width: 13px;
  height: 13px;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  border: 2px solid var(--th-panel,#273035);
  border-radius: 50%;
  background: var(--vav-status-color);
  color: #fff;
  font: 900 9px/1 Arial,sans-serif;
  text-shadow: 0 1px rgba(0,0,0,.28);
}
.bus-presence[data-status-icon="available"]::after { content: '✓'; }
.bus-presence[data-status-icon="work"]::after { content: 'W'; font-size: 7px; }
.bus-presence[data-status-icon="home"]::after { content: '⌂'; }
.bus-presence[data-status-icon="sleep"]::after { content: 'Z'; font-size: 7px; }
.bus-presence[data-status-icon="road"]::after { content: '➜'; font-size: 7px; }
.bus-presence[data-status-icon="dnd"]::after { content: '−'; font-size: 10px; }
.bus-presence[data-status-icon="offline"]::after { content: ''; }

/* Status picker and connection indicator use the same master bus. */
html[data-theme] .status-preset::before,
html[data-theme] .connection-bus-mini {
  -webkit-mask: none !important;
  mask: none !important;
  background-color: transparent !important;
  background-image:
    radial-gradient(circle, var(--status-bus-color,#607d8b) 0 48%, #f4ead4 51% 64%, transparent 67%),
    var(--vav-brand-bus) !important;
  background-repeat: no-repeat !important;
  background-position: right bottom, center !important;
  background-size: 11px 11px, contain !important;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.32)) !important;
  image-rendering: auto !important;
}
html[data-theme] .status-preset[data-tone="green"] { --status-bus-color: #42b95c; }
html[data-theme] .status-preset[data-tone="yellow"] { --status-bus-color: #e1ad35; }
html[data-theme] .status-preset[data-tone="blue"],
html[data-theme] .status-preset[data-tone="cyan"] { --status-bus-color: #3d9ee8; }
html[data-theme] .status-preset[data-tone="purple"] { --status-bus-color: #9167d8; }
html[data-theme] .status-preset[data-tone="orange"] { --status-bus-color: #e27d36; }
html[data-theme] .status-preset[data-tone="red"] { --status-bus-color: #db4d49; }
html[data-theme] .status-preset[data-tone="gray"] { --status-bus-color: #69757c; }

/* Last seen must stay readable without widening the mobile header. */
html[data-theme] .chat-subtitle {
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

@media (max-width: 620px) {
  .vav-welcome-bus { width: 42px !important; height: 42px !important; }
  .bus-presence::after { right: -3px; bottom: -3px; }
}

/* V34 — unmistakable availability and a calmer, modern chat header. */
.bus-presence.is-online {
  border: 2px solid #49d36b !important;
  background: linear-gradient(145deg,rgba(73,211,107,.34),rgba(20,92,47,.54)) !important;
  box-shadow: 0 0 0 3px rgba(73,211,107,.13),0 3px 9px rgba(0,0,0,.25) !important;
}
.bus-presence.is-offline {
  border: 2px solid #e05454 !important;
  background: linear-gradient(145deg,rgba(224,84,84,.32),rgba(103,29,31,.55)) !important;
  box-shadow: 0 0 0 3px rgba(224,84,84,.12),0 3px 9px rgba(0,0,0,.25) !important;
}
.bus-presence.is-offline .brand-bus-status-image {
  opacity: .72 !important;
  filter: grayscale(.42) drop-shadow(0 1px 1px rgba(0,0,0,.4)) !important;
}
.bus-presence-wrap.with-text {
  min-width: 0 !important;
  padding: 3px 8px 3px 5px !important;
  border: 1px solid color-mix(in srgb,var(--vav-presence-color,#748087) 52%,transparent) !important;
  border-radius: 999px !important;
  background: color-mix(in srgb,var(--vav-presence-color,#748087) 12%,transparent) !important;
}
.bus-presence-wrap.with-text[data-online="true"] { --vav-presence-color: #49d36b; }
.bus-presence-wrap.with-text[data-online="false"] { --vav-presence-color: #e05454; }

html[data-theme] body.vav-shell-mode .chat-header {
  grid-template-columns: 50px minmax(0,1fr) auto !important;
  min-height: 72px !important;
  padding: 9px 12px !important;
  gap: 12px !important;
  align-items: center !important;
  overflow: hidden !important;
}
html[data-theme] body.vav-shell-mode .chat-header-main {
  display: grid !important;
  min-width: 0 !important;
  gap: 5px !important;
  overflow: hidden !important;
}
html[data-theme] body.vav-shell-mode .chat-title-line {
  display: flex !important;
  min-width: 0 !important;
  align-items: center !important;
  gap: 10px !important;
}
html[data-theme] body.vav-shell-mode .chat-title {
  min-width: 0 !important;
  max-width: none !important;
  flex: 0 1 auto !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  font-size: 17px !important;
  line-height: 1.2 !important;
}
html[data-theme] body.vav-shell-mode #chatPresence {
  min-width: 0 !important;
  flex: 0 1 auto !important;
}
html[data-theme] body.vav-shell-mode #chatPresence .bus-presence-label {
  max-width: 150px !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  font-size: 11px !important;
  font-weight: 750 !important;
}
html[data-theme] body.vav-shell-mode .chat-subtitle {
  margin: 0 !important;
  color: var(--th-muted,#aeb1ae) !important;
  font-size: 11px !important;
  line-height: 1.25 !important;
}
html[data-theme] body.vav-shell-mode .chat-header-actions {
  display: flex !important;
  align-items: center !important;
  gap: 7px !important;
}
html[data-theme] body.vav-shell-mode .chat-header-actions .chat-voice-call-button {
  width: auto !important;
  min-width: 108px !important;
  height: 42px !important;
  min-height: 42px !important;
  padding: 0 13px !important;
  border-radius: 12px !important;
}
html[data-theme] body.vav-shell-mode .chat-header-actions .chat-info-button {
  width: 42px !important;
  min-width: 42px !important;
  height: 42px !important;
  min-height: 42px !important;
  padding: 0 !important;
  border-radius: 12px !important;
}
html[data-theme] body.vav-shell-mode .chat-info-text { display: none !important; }

@media (max-width: 820px) {
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-header {
    grid-template-columns: 38px 42px minmax(0,1fr) auto !important;
    min-height: calc(62px + env(safe-area-inset-top)) !important;
    padding: calc(6px + env(safe-area-inset-top)) 5px 6px !important;
    gap: 5px !important;
  }
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-header .avatar-large {
    width: 42px !important;
    min-width: 42px !important;
    height: 42px !important;
  }
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-header-main { gap: 3px !important; }
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-title-line { gap: 6px !important; }
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-title {
    max-width: none !important;
    font-size: 15px !important;
  }
  html.vav-mobile-layout[data-theme] body.vav-shell-mode #chatPresence .bus-presence-wrap.with-text {
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
  }
  html.vav-mobile-layout[data-theme] body.vav-shell-mode #chatPresence .bus-presence-label { display: none !important; }
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-title-line .bus-presence {
    width: 28px !important;
    min-width: 28px !important;
    height: 30px !important;
    flex-basis: 28px !important;
  }
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-subtitle {
    font-size: 10px !important;
    line-height: 1.2 !important;
  }
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-header-actions { gap: 4px !important; }
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-header-actions .chat-voice-call-button,
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-header-actions .chat-info-button {
    width: 38px !important;
    min-width: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
    padding: 0 !important;
    border-radius: 11px !important;
  }
}

@media (max-width: 390px) {
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-header {
    grid-template-columns: 34px 38px minmax(0,1fr) auto !important;
    gap: 4px !important;
    padding-left: 4px !important;
    padding-right: 4px !important;
  }
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-header .avatar-large {
    width: 38px !important;
    min-width: 38px !important;
    height: 38px !important;
  }
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-header-actions .chat-voice-call-button,
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-header-actions .chat-info-button {
    width: 35px !important;
    min-width: 35px !important;
    height: 35px !important;
    min-height: 35px !important;
  }
}

/* UI_STABILITY_V39_CHAT_HEADER_START */
/* Final geometry guard: long names and status badges shrink only their text,
   never the avatar or action buttons. Visual sizes remain the approved V38. */
html[data-theme] body.vav-shell-mode .chat-header-main,
html[data-theme] body.vav-shell-mode .chat-title-line,
html[data-theme] body.vav-shell-mode .chat-title,
html[data-theme] body.vav-shell-mode .chat-subtitle {
  min-width: 0 !important;
}

html[data-theme] body.vav-shell-mode .chat-title,
html[data-theme] body.vav-shell-mode .chat-subtitle {
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

html[data-theme] body.vav-shell-mode #chatPresence,
html[data-theme] body.vav-shell-mode .chat-header-actions,
html[data-theme] body.vav-shell-mode .chat-header .avatar-large,
html[data-theme] body.vav-shell-mode .mobile-back-button {
  flex-shrink: 0 !important;
}

@media (max-width: 820px) {
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-header-main {
    overflow: hidden !important;
  }

  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-title-line {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow: hidden !important;
  }

  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-title {
    flex: 1 1 auto !important;
  }

  html.vav-mobile-layout[data-theme] body.vav-shell-mode #chatPresence {
    flex: 0 0 auto !important;
  }
}
/* UI_STABILITY_V39_CHAT_HEADER_END */

/* V38 — only the account header icon and the chat-presence badge. */
html[data-theme] #accountModal .modal-titlebar > .qip-logo {
  display: inline-grid !important;
  place-items: center !important;
  background-image: none !important;
  background-color: rgba(216,172,73,.12) !important;
  border-color: rgba(216,172,73,.34) !important;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.035) !important;
}
html[data-theme] #accountModal .modal-titlebar > .qip-logo::before {
  content: '' !important;
  display: block !important;
  width: 19px !important;
  height: 19px !important;
  background: var(--th-accent,#d8ac49) !important;
  -webkit-mask: url("ui-icons/profile.svg") center/contain no-repeat !important;
  mask: url("ui-icons/profile.svg") center/contain no-repeat !important;
}
html[data-theme] body.vav-shell-mode #chatPresence .bus-presence::after {
  content: none !important;
  display: none !important;
}

/* V35 — one presence language in chat lists, contacts and the active chat. */
html[data-theme] body.vav-shell-mode #conversationList .conversation-item[data-presence-online="true"] {
  --vav-row-presence: 73,211,107;
}
html[data-theme] body.vav-shell-mode #conversationList .conversation-item[data-presence-online="false"] {
  --vav-row-presence: 224,84,84;
}
html[data-theme] body.vav-shell-mode #conversationList .conversation-item[data-presence-online] .conversation-avatar-shell .avatar {
  box-sizing: border-box !important;
  border: 2px solid rgb(var(--vav-row-presence)) !important;
  box-shadow: 0 0 0 3px rgba(var(--vav-row-presence),.14),0 3px 9px rgba(0,0,0,.26) !important;
}
html[data-theme] body.vav-shell-mode #conversationList .conversation-bus-presence {
  display: inline-flex !important;
  flex: 0 0 auto !important;
  box-sizing: border-box !important;
  padding: 2px !important;
  border: 1px solid rgba(var(--vav-row-presence,105,117,124),.72) !important;
  border-radius: 10px !important;
  background: rgba(var(--vav-row-presence,105,117,124),.12) !important;
  box-shadow: 0 0 0 2px rgba(var(--vav-row-presence,105,117,124),.07) !important;
  line-height: 0 !important;
}

/* Old mobile rules add pseudo-icons to every secondary button. Keep one real icon per action. */
html[data-theme] body.vav-shell-mode .chat-header-actions .chat-voice-call-button::before,
html[data-theme] body.vav-shell-mode .chat-header-actions .chat-voice-call-button::after,
html[data-theme] body.vav-shell-mode .chat-header-actions .chat-info-button::before,
html[data-theme] body.vav-shell-mode .chat-header-actions .chat-info-button::after {
  content: none !important;
  display: none !important;
}

@media (max-width: 820px) {
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-header {
    grid-template-columns: 36px 40px minmax(0,1fr) 76px !important;
    min-height: calc(60px + env(safe-area-inset-top)) !important;
    gap: 4px !important;
    padding: calc(6px + env(safe-area-inset-top)) 5px 6px !important;
    align-items: center !important;
  }
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .mobile-back-button {
    width: 36px !important;
    min-width: 36px !important;
    height: 36px !important;
    justify-self: center !important;
    align-self: center !important;
  }
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-header .avatar-large {
    width: 40px !important;
    min-width: 40px !important;
    height: 40px !important;
    justify-self: center !important;
  }
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-header-main {
    width: 100% !important;
    align-self: center !important;
  }
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-title-line {
    width: 100% !important;
    gap: 4px !important;
  }
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-title-line .bus-presence {
    width: 24px !important;
    min-width: 24px !important;
    height: 26px !important;
    flex-basis: 24px !important;
  }
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-header-actions {
    display: grid !important;
    grid-template-columns: repeat(2,36px) !important;
    width: 76px !important;
    min-width: 76px !important;
    gap: 4px !important;
    align-items: center !important;
    justify-content: end !important;
    align-self: center !important;
  }
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-header-actions .chat-voice-call-button,
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-header-actions .chat-info-button {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 36px !important;
    min-width: 36px !important;
    height: 36px !important;
    min-height: 36px !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1 !important;
  }
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-header-actions .chat-voice-call-image,
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-header-actions .chat-info-image {
    display: block !important;
    width: 20px !important;
    height: 20px !important;
    margin: 0 !important;
    transform: none !important;
  }
}

@media (max-width: 390px) {
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-header {
    grid-template-columns: 34px 36px minmax(0,1fr) 70px !important;
    gap: 3px !important;
    padding-left: 4px !important;
    padding-right: 4px !important;
  }
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .mobile-back-button,
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-header-actions .chat-voice-call-button,
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-header-actions .chat-info-button {
    width: 34px !important;
    min-width: 34px !important;
    height: 34px !important;
    min-height: 34px !important;
  }
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-header .avatar-large {
    width: 36px !important;
    min-width: 36px !important;
    height: 36px !important;
  }
  html.vav-mobile-layout[data-theme] body.vav-shell-mode .chat-header-actions {
    grid-template-columns: repeat(2,34px) !important;
    width: 70px !important;
    min-width: 70px !important;
    gap: 2px !important;
  }
}
