/* ==========================================================================
   ULTRAGIS ECOSYSTEM HEADER — INTEGRATED EXECUTIVE TOPBAR FOR MORROS
   Barra corporativa unificada de 52px com seletor de ecossistema e telemetria
   ========================================================================== */

/* 1. Reset de Layout Global */
html, body {
  overflow-x: hidden;
}

body {
  padding-top: 52px !important;
  box-sizing: border-box !important;
}

/* 2. Barra Superior Unificada (52px) */
.app-header {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  height: 52px !important;
  min-height: 52px !important;
  background: linear-gradient(135deg, #071c30 0%, #0e3b65 60%, #092542 100%) !important;
  color: #FFFFFF !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 0 16px !important;
  box-shadow: 0 2px 14px rgba(7, 28, 48, 0.50) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14) !important;
  z-index: 5000 !important;
  box-sizing: border-box !important;
  gap: 12px;
}

/* 3. Ajustes do Shell, Sidebar e Workspace */
.app-shell {
  min-height: calc(100vh - 52px) !important;
}

.sidebar {
  top: 52px !important;
  height: calc(100vh - 52px) !important;
  z-index: 2000 !important;
}

.workspace-wrapper {
  margin-left: var(--sidebar-w, 270px) !important;
  min-height: calc(100vh - 52px) !important;
  position: relative !important;
}

.workspace-wrapper::before {
  top: 52px !important;
}

.workspace-content {
  padding-top: 1.25rem !important;
}

/* Oculta qualquer topbar interna antiga no workspace */
.workspace-wrapper > .topbar,
.topbar {
  display: none !important;
}

/* 4. Grupo Esquerdo */
.app-header .header-left-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  min-width: 0;
}

.app-header .mobile-menu-btn {
  display: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #E2E8F0;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.app-header .brand-section {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.app-header .brand-logo-badge {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: #FFFFFF;
  user-select: none;
}

.app-header .brand-logo-img {
  height: 28px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
  display: block;
}

.app-header .brand-badge-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
}

.app-header .badge-live {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: rgba(249, 115, 22, 0.22);
  color: #FDBA74;
  border: 1px solid rgba(249, 115, 22, 0.45);
  padding: 1px 5px;
  border-radius: 9999px;
  line-height: 1.2;
  white-space: nowrap;
}

.app-header .badge-update-date {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 7.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.68);
  letter-spacing: 0.2px;
  white-space: nowrap;
  line-height: 1.1;
}

/* Divisor Vertical */
.app-header .header-v-divider {
  width: 1px;
  height: 22px;
  background: rgba(255, 255, 255, 0.18);
  margin: 0 6px;
  flex-shrink: 0;
}

/* Breadcrumb Dinâmico */
.app-header .view-breadcrumb {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  max-width: 320px;
}

.app-header .view-breadcrumb h2 {
  font-size: 12.5px;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: 0.2px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.app-header .view-breadcrumb p {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.68);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

/* 5. Seletor de Sistemas UltraGIS */
.app-header .system-switcher-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin: 0 4px;
  z-index: 5020;
  flex-shrink: 0;
}

.app-header .system-switcher-trigger {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #E2E8F0;
  height: 28px;
  padding: 0 9px;
  border-radius: 6px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  white-space: nowrap;
}

.app-header .system-switcher-trigger:hover,
.app-header .system-switcher-wrapper.open .system-switcher-trigger {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.35);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.app-header .system-switcher-trigger .switcher-icon {
  font-size: 13px;
  color: #38BDF8;
  transition: transform 0.2s ease;
}

.app-header .system-switcher-trigger:hover .switcher-icon {
  transform: rotate(90deg);
}

.app-header .system-switcher-trigger .switcher-active-name {
  color: #F8FAFC;
  letter-spacing: 0.2px;
}

.app-header .system-switcher-trigger .switcher-chevron {
  font-size: 10px;
  color: #94A3B8;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.app-header .system-switcher-wrapper.open .system-switcher-trigger .switcher-chevron {
  transform: rotate(180deg);
  color: #38BDF8;
}

/* Popover Flutuante */
.app-header .system-switcher-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 290px;
  background: #0B2540;
  background: linear-gradient(180deg, #0e3357 0%, #092036 100%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.25);
  padding: 8px;
  display: none;
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 5050;
  box-sizing: border-box;
}

.app-header .system-switcher-wrapper.open .system-switcher-popover {
  display: block;
  opacity: 1;
  transform: translateY(0) scale(1);
}

.app-header .switcher-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 6px;
}

.app-header .popover-header-title {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #94A3B8;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.app-header .popover-header-title i {
  color: #38BDF8;
  font-size: 12px;
}

.app-header .switcher-options-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.app-header .switcher-option-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  text-decoration: none;
  color: inherit;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  transition: all 0.16s ease;
  position: relative;
}

.app-header .switcher-option-card:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.18);
  transform: translateX(2px);
}

.app-header .switcher-option-card.active {
  background: rgba(14, 165, 233, 0.14);
  border-color: rgba(56, 189, 248, 0.35);
}

.app-header .option-icon-box {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.app-header .icon-ultragis {
  background: rgba(56, 189, 248, 0.18);
  color: #38BDF8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.app-header .icon-abast {
  background: rgba(16, 185, 129, 0.18);
  color: #34D399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.app-header .icon-macro {
  background: rgba(168, 85, 247, 0.18);
  color: #C084FC;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.app-header .icon-morros {
  background: rgba(249, 115, 22, 0.18);
  color: #FB923C;
  border: 1px solid rgba(249, 115, 22, 0.3);
}

.app-header .option-details {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.app-header .option-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.app-header .option-name {
  font-size: 11.5px;
  font-weight: 700;
  color: #F1F5F9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-header .switcher-option-card:hover .option-name {
  color: #FFFFFF;
}

.app-header .option-status-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
}

.app-header .badge-active {
  background: #10B981;
  color: #FFFFFF;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.app-header .badge-link {
  background: rgba(255, 255, 255, 0.08);
  color: #94A3B8;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.app-header .option-desc {
  font-size: 10px;
  color: #94A3B8;
  line-height: 1.25;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-header .option-ext-icon {
  font-size: 12px;
  color: #64748B;
  transition: all 0.16s ease;
  flex-shrink: 0;
}

.app-header .switcher-option-card:hover .option-ext-icon {
  color: #38BDF8;
  transform: translate(1px, -1px);
}

/* 6. Grupo Direito: Telemetria & Busca */
.app-header .topbar-telemetry {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  flex-shrink: 0 !important;
}

.app-header .telemetry-pill {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #FCA5A5;
  font-size: 10.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.3px;
  transition: all 0.2s ease;
  white-space: nowrap;
  user-select: none;
}

.app-header .telemetry-pill:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.55);
}

.app-header .telemetry-dot.pulse-red {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #EF4444;
  box-shadow: 0 0 8px #EF4444;
  animation: pulseRed 1.8s infinite;
}

@keyframes pulseRed {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.app-header .btn-telemetry-map {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #38BDF8;
}

.app-header .btn-telemetry-map:hover {
  background: rgba(56, 189, 248, 0.22);
  border-color: rgba(56, 189, 248, 0.5);
  color: #FFFFFF;
}

.app-header .btn-telemetry-map svg,
.app-header .btn-telemetry-map i {
  width: 13px;
  height: 13px;
}

.app-header .portal-global-search {
  position: relative;
  display: flex;
  align-items: center;
}

.app-header .portal-global-search input {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #FFFFFF;
  font-family: inherit;
  font-size: 11px;
  border-radius: 6px;
  padding: 4px 28px 4px 10px;
  height: 28px;
  width: 170px;
  outline: none;
  transition: all 0.2s ease;
}

.app-header .portal-global-search input:focus {
  background: rgba(255, 255, 255, 0.14);
  border-color: #38BDF8;
  width: 210px;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.3);
}

.app-header .portal-global-search input::placeholder {
  color: #94A3B8;
}

.app-header .portal-global-search button {
  position: absolute;
  right: 6px;
  background: transparent;
  border: none;
  color: #94A3B8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
}

.app-header .portal-global-search button:hover {
  color: #38BDF8;
}

.app-header .portal-global-search button svg {
  width: 12px;
  height: 12px;
}

/* 7. Responsividade */
@media (max-width: 1200px) {
  .app-header .view-breadcrumb {
    max-width: 180px;
  }
}

@media (max-width: 1024px) {
  .app-header .mobile-menu-btn {
    display: inline-flex !important;
  }
  .app-header .view-breadcrumb {
    display: none;
  }
  .app-header .header-v-divider {
    display: none;
  }
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .workspace-wrapper {
    margin-left: 0 !important;
  }
  .workspace-wrapper::before {
    left: 0 !important;
  }
}

@media (max-width: 768px) {
  .app-header {
    padding: 0 10px !important;
  }
  .app-header .telemetry-pill#topRainChip {
    display: none;
  }
  .app-header .system-switcher-trigger .switcher-active-name {
    display: none;
  }
  .app-header .portal-global-search input {
    width: 110px;
  }
  .app-header .portal-global-search input:focus {
    width: 140px;
  }
}


/* Tag OPERAÇÃO INVERNO: reduzida e sem efeito de fundo */
.brand-status-tag {
  background: transparent !important;
  background-color: transparent !important;
  padding: 1px 6px !important;
  font-size: 0.56rem !important;
  line-height: 1.2 !important;
  border: 1px solid rgba(56, 189, 248, 0.22) !important;
  box-shadow: none !important;
  text-shadow: none !important;
  margin-top: 4px !important;
}
