/* DroneHQ Shell Utility Panels v31
   Scope:
   - Header utility polish for Location, Calendar, Bell, and Help icons.
   - Calendar and Notifications dock header date/time placement.
   - Location opens a docked panel instead of the large map modal.
   This patch does not change crawler/status/API, Preflight, Fleet, database, OAuth, or email behavior. */

:root {
  --dronehq-utility-box-size: 44px;
  --dronehq-location-dock-width: 360px;
  --dronehq-location-dock-gap: 14px;
}

/* Keep header utilities visually consistent: Location | Calendar | Bell | Help. */
.app-shell-header [data-location-button],
.app-shell-header [data-operating-location-button],
.app-shell-header [data-calendar-utility-button],
.app-shell-header [data-calendar-menu-toggle],
.app-shell-header [data-dhq-calendar-toggle],
.app-shell-header .shell-calendar-utility,
.app-shell-header .app-shell-calendar-button,
.app-shell-header .dhq-calendar-icon-button,
.app-shell-header [data-notifications-toggle],
.app-shell-header [data-notification-toggle],
.app-shell-header [data-dhq-notifications-toggle],
.app-shell-header [data-shell-notifications],
.app-shell-header [data-open-notifications],
.app-shell-header .shell-notifications-trigger,
.app-shell-header .shell-notification-button,
.app-shell-header .app-shell-notifications-button,
.app-shell-header .dhq-notifications-button,
.app-shell-header button[aria-label*="Notification" i],
.app-shell-header a[aria-label*="Notification" i],
.app-shell-header [data-help-open],
.app-shell-header [data-help-toggle],
.app-shell-header [data-help-button],
.app-shell-header [data-shell-help],
.app-shell-header .help-trigger,
.app-shell-header .app-help-trigger,
.app-shell-header .shell-help-trigger,
.app-shell-header button[aria-label*="Help" i],
.app-shell-header a[aria-label*="Help" i] {
  width: var(--dronehq-utility-box-size) !important;
  min-width: var(--dronehq-utility-box-size) !important;
  max-width: var(--dronehq-utility-box-size) !important;
  height: var(--dronehq-utility-box-size) !important;
  min-height: var(--dronehq-utility-box-size) !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 1px solid rgba(67, 176, 255, 0.42) !important;
  border-radius: 12px !important;
  background: rgba(8, 27, 50, 0.94) !important;
  box-shadow: 0 0 0 1px rgba(38, 156, 255, 0.05), 0 0 18px rgba(32, 169, 255, 0.10) !important;
  color: var(--primary, #38bdf8) !important;
  display: inline-grid !important;
  place-items: center !important;
  gap: 0 !important;
  text-decoration: none !important;
  cursor: pointer !important;
  position: relative !important;
  overflow: visible !important;
}

.app-shell-header [data-location-button]:hover,
.app-shell-header [data-calendar-utility-button]:hover,
.app-shell-header [data-calendar-menu-toggle]:hover,
.app-shell-header [data-dhq-calendar-toggle]:hover,
.app-shell-header [data-notifications-toggle]:hover,
.app-shell-header [data-notification-toggle]:hover,
.app-shell-header [data-help-open]:hover,
.app-shell-header [data-help-toggle]:hover,
.app-shell-header [data-help-button]:hover,
.app-shell-header button[aria-label*="Notification" i]:hover,
.app-shell-header button[aria-label*="Help" i]:hover,
.app-shell-header .is-active {
  border-color: rgba(83, 196, 255, 0.82) !important;
  background: rgba(12, 43, 74, 0.98) !important;
  box-shadow: 0 0 0 1px rgba(65, 190, 255, 0.24), 0 0 22px rgba(32, 169, 255, 0.20) !important;
}

/* Location off/unavailable: whole marker button goes red. */
.app-shell-header [data-location-button].location-status-unavailable,
.app-shell-header [data-location-button][data-location-status="unavailable"],
.app-shell-header [data-location-button][data-location-status="off"],
.app-shell-header [data-location-button].is-location-off,
.app-shell-header [data-location-button][aria-invalid="true"] {
  color: var(--danger, #ff5d73) !important;
  border-color: color-mix(in srgb, var(--danger, #ff5d73) 72%, transparent) !important;
  background: color-mix(in srgb, var(--danger, #ff5d73) 16%, rgba(8, 27, 50, 0.94)) !important;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--danger, #ff5d73) 24%, transparent), 0 0 18px color-mix(in srgb, var(--danger, #ff5d73) 18%, transparent) !important;
}

/* Header utility icon sizing. */
.app-shell-header [data-location-button] svg,
.app-shell-header [data-calendar-utility-button] svg,
.app-shell-header [data-calendar-menu-toggle] svg,
.app-shell-header [data-dhq-calendar-toggle] svg,
.app-shell-header [data-notifications-toggle] svg,
.app-shell-header [data-notification-toggle] svg,
.app-shell-header [data-help-open] svg,
.app-shell-header [data-help-toggle] svg,
.app-shell-header button[aria-label*="Notification" i] svg,
.app-shell-header button[aria-label*="Help" i] svg {
  width: 20px !important;
  height: 20px !important;
  min-width: 20px !important;
  color: currentColor !important;
  display: block !important;
}

/* Hide text labels inside icon-only utilities without hiding profile/system text. */
.app-shell-header [data-location-button] :is(.shell-utility-label, .shell-location-label, [data-location-label]),
.app-shell-header [data-calendar-utility-button] :is(.shell-utility-label, .shell-calendar-label),
.app-shell-header [data-notifications-toggle] :is(.shell-utility-label, .notification-label, .notifications-label),
.app-shell-header [data-help-open] :is(.shell-utility-label, .help-label),
.app-shell-header [data-help-toggle] :is(.shell-utility-label, .help-label) {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Notification badge on the bell. */
.dhq-shell-notification-count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .22);
  background: #ff5c7a;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 900;
  line-height: 17px;
  text-align: center;
  box-shadow: 0 0 12px rgba(255, 92, 122, .32);
}

/* Calendar header: title stays left; date/time line is centered below the title bar. */
.dhq-calendar-dock-v21__head {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 34px !important;
  grid-template-rows: auto auto !important;
  align-items: start !important;
  gap: 0.25rem 0.75rem !important;
}

.dhq-calendar-dock-v21__head > div:first-child {
  grid-column: 1 !important;
  grid-row: 1 !important;
  text-align: left !important;
  min-width: 0 !important;
}

.dhq-calendar-dock-v21__head .dhq-calendar-dock-v21__close {
  grid-column: 2 !important;
  grid-row: 1 !important;
  justify-self: end !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  line-height: 1 !important;
}

.dhq-calendar-dock-v21__subtle[data-calendar-v21-today-label],
.dhq-calendar-dock-v31__date-line {
  grid-column: 1 / -1 !important;
  grid-row: 2 !important;
  justify-self: center !important;
  width: 100% !important;
  max-width: calc(100% - 76px) !important;
  text-align: center !important;
  font-size: 0.74rem !important;
  line-height: 1.2 !important;
  color: #bfd2e8 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

/* Notifications header: title left; date/time centered; Mark/X right. */
.dhq-notifications-dock-v23__head {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  grid-template-rows: auto auto !important;
  align-items: start !important;
  gap: 0.25rem 0.75rem !important;
}

.dhq-notifications-dock-v23__head > div:first-child {
  grid-column: 1 !important;
  grid-row: 1 !important;
  text-align: left !important;
  min-width: 0 !important;
}

.dhq-notifications-dock-v23__head-actions {
  grid-column: 2 !important;
  grid-row: 1 !important;
  justify-self: end !important;
  align-items: center !important;
}

.dhq-notifications-dock-v23__subtle[data-notifications-v23-date],
.dhq-notifications-dock-v31__date-line {
  grid-column: 1 / -1 !important;
  grid-row: 2 !important;
  justify-self: center !important;
  width: 100% !important;
  max-width: calc(100% - 76px) !important;
  text-align: center !important;
  font-size: 0.74rem !important;
  line-height: 1.2 !important;
  color: #bfd2e8 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.dhq-notifications-dock-v23__close,
.dhq-calendar-dock-v21__close {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box !important;
  padding: 0 !important;
  text-align: center !important;
}

/* Calendar month controls: keep Today small so it does not collide with arrows. */
.dhq-calendar-dock-v29__month-nav {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 46px !important;
  align-items: center !important;
  gap: 0.35rem !important;
}

.dhq-calendar-dock-v29__month-controls {
  min-width: 0 !important;
  display: grid !important;
  grid-template-columns: 30px minmax(64px, 1fr) 30px !important;
  gap: 0.28rem !important;
  align-items: center !important;
}

.dhq-calendar-dock-v29__today-btn,
.dhq-calendar-dock-v21__today-pill {
  width: 46px !important;
  min-width: 46px !important;
  max-width: 46px !important;
  min-height: 24px !important;
  height: 24px !important;
  padding: 0 0.25rem !important;
  font-size: 0.62rem !important;
  line-height: 1 !important;
}

/* Location dock panel: replaces the large map modal when v31 is active. */
.dhq-location-dock-v31 {
  position: fixed;
  top: var(--app-header-height, var(--shell-header-height, 72px));
  right: var(--dronehq-location-dock-gap);
  bottom: var(--dronehq-location-dock-gap);
  width: min(var(--dronehq-location-dock-width), calc(100vw - 24px));
  z-index: 1196;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(94, 166, 255, 0.28);
  border-radius: 16px;
  background: rgba(7, 22, 43, 0.98);
  color: #eaf3ff;
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.38);
  overflow: hidden;
}

.dhq-location-dock-v31[hidden] {
  display: none !important;
}

.dhq-location-dock-v31__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 0.75rem;
  align-items: start;
  padding: 0.92rem 1rem 0.78rem;
  border-bottom: 1px solid rgba(94, 166, 255, 0.2);
  background: rgba(9, 30, 58, 0.78);
}

.dhq-location-dock-v31__eyebrow {
  margin: 0 0 0.16rem;
  color: #4fc3ff;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.dhq-location-dock-v31__title {
  margin: 0;
  color: #ffffff;
  font-size: 1.18rem;
  font-weight: 800;
  line-height: 1.15;
}

.dhq-location-dock-v31__close {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(125, 190, 255, 0.42);
  background: rgba(15, 47, 82, 0.86);
  color: #dbeafe;
  font-size: 1.06rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.dhq-location-dock-v31__body {
  padding: 0.92rem 1rem 1rem;
  overflow: auto;
}

.dhq-location-dock-v31__section {
  padding: 0.78rem 0;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
}

.dhq-location-dock-v31__section:first-child {
  border-top: 0;
  padding-top: 0;
}

.dhq-location-dock-v31__section h4 {
  margin: 0 0 0.45rem;
  color: #f5f9ff;
  font-size: 0.82rem;
  font-weight: 800;
}

.dhq-location-dock-v31__card {
  border: 1px solid rgba(94, 166, 255, 0.18);
  border-radius: 13px;
  padding: 0.74rem;
  background: rgba(8, 25, 48, 0.6);
}

.dhq-location-dock-v31__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.54rem 0;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
}

.dhq-location-dock-v31__row:first-child {
  border-top: 0;
  padding-top: 0;
}

.dhq-location-dock-v31__label {
  color: #cbd9ea;
  font-size: 0.76rem;
  font-weight: 800;
}

.dhq-location-dock-v31__value {
  color: #eaf3ff;
  font-size: 0.76rem;
  text-align: right;
  overflow-wrap: anywhere;
}

.dhq-location-dock-v31__status {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  color: #5ff0b3;
  font-size: 0.76rem;
  font-weight: 900;
}

.dhq-location-dock-v31__status::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
}

.dhq-location-dock-v31.is-off .dhq-location-dock-v31__status {
  color: #ff7a8f;
}

.dhq-location-dock-v31__note {
  margin: 0.72rem 0 0;
  color: #9fb2c8;
  font-size: 0.76rem;
  line-height: 1.38;
}

.dhq-location-dock-v31__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: #eaf3ff;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.dhq-location-dock-v31__toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.dhq-location-dock-v31__switch {
  width: 48px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid rgba(125, 190, 255, 0.34);
  background: rgba(15, 47, 82, 0.86);
  position: relative;
}

.dhq-location-dock-v31__switch::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 4px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  transform: translateY(-50%);
  background: #9fb2c8;
  box-shadow: 0 0 10px rgba(159, 178, 200, .24);
  transition: left 140ms ease, background 140ms ease;
}

.dhq-location-dock-v31__toggle input:checked + .dhq-location-dock-v31__switch {
  border-color: rgba(52, 211, 153, 0.42);
  background: rgba(16, 185, 129, 0.16);
}

.dhq-location-dock-v31__toggle input:checked + .dhq-location-dock-v31__switch::after {
  left: 24px;
  background: #5ff0b3;
  box-shadow: 0 0 12px rgba(95, 240, 179, .38);
}

/* Hide the old large Operating Location modal while v31 dock panel is open. */
body.dronehq-location-docked-open :is(
  [data-operating-location-modal],
  [data-location-modal],
  .operating-location-modal,
  .location-modal,
  .dhq-operating-location-modal,
  .dhq-location-modal,
  #operating-location-modal,
  #location-modal
):not(#dhq-location-dock-v31) {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Wide screens: reserve workspace room like Help/Calendar/Notifications. */
@media (min-width: 1180px) {
  body.dronehq-location-docked-open {
    --dronehq-location-dock-space: min(var(--dronehq-location-dock-width), 31vw);
  }

  body.dronehq-location-docked-open main,
  body.dronehq-location-docked-open .app-main,
  body.dronehq-location-docked-open .shell-main,
  body.dronehq-location-docked-open .page-main,
  body.dronehq-location-docked-open .workspace-main,
  body.dronehq-location-docked-open .dashboard-main,
  body.dronehq-location-docked-open .app-content,
  body.dronehq-location-docked-open .shell-content,
  body.dronehq-location-docked-open .page-content,
  body.dronehq-location-docked-open .content-shell,
  body.dronehq-location-docked-open .dashboard-shell,
  body.dronehq-location-docked-open .settings-shell,
  body.dronehq-location-docked-open .preflight-workspace,
  body.dronehq-location-docked-open .fleet-shell {
    padding-right: calc(var(--dronehq-location-dock-space) + var(--dronehq-location-dock-gap)) !important;
    transition: padding-right 160ms ease;
  }

  .dhq-location-dock-v31 {
    width: var(--dronehq-location-dock-space);
    max-width: var(--dronehq-location-dock-space);
  }
}

@media (max-width: 1179px) {
  body.dronehq-location-docked-open main,
  body.dronehq-location-docked-open .app-main,
  body.dronehq-location-docked-open .shell-main,
  body.dronehq-location-docked-open .page-main,
  body.dronehq-location-docked-open .workspace-main,
  body.dronehq-location-docked-open .dashboard-main,
  body.dronehq-location-docked-open .app-content,
  body.dronehq-location-docked-open .shell-content,
  body.dronehq-location-docked-open .page-content {
    padding-right: 0 !important;
  }

  .dhq-location-dock-v31 {
    max-width: min(380px, calc(100vw - 24px));
  }
}
