// Shared enterprise UI components for both Admin Command Center and Fleet Portal

.app-shell {
  min-height: 100vh;
  display: flex;
}

// ---------- Sidebar ----------
.app-sidebar {
  width: 264px;
  flex-shrink: 0;
  background: $surface-0;
  border-right: 1px solid rgba(10, 34, 64, 0.08);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: transform 0.2s ease;
  z-index: 1030;

  .brand {
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid rgba(10, 34, 64, 0.08);
    border-top: 3px solid;
    border-image: linear-gradient(90deg, $ensign-saffron 0 33%, #fff 33% 66%, $ensign-green 66% 100%) 1;
    display: flex;
    align-items: center;
    gap: 0.65rem;

    .brand-mark {
      width: 38px;
      height: 38px;
      border-radius: 50%;
      flex-shrink: 0;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .brand-text {
      line-height: 1.1;
      .title { font-weight: 700; font-size: 0.95rem; color: $navy-950; }
      .subtitle { font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: $navy-300; }
    }
  }

  .nav-section-label {
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: $navy-400;
    padding: 0.9rem 1.25rem 0.35rem;
  }

  .nav-link {
    color: $nav-link-color;
    padding: 0.55rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.875rem;
    border-left: 3px solid transparent;

    i { font-size: 1rem; width: 1.1rem; text-align: center; }

    &:hover { background: $surface-50; color: $navy-950; }

    &.active {
      background: rgba(29, 95, 168, 0.1);
      border-left-color: $ensign-saffron;
      color: $primary;
      font-weight: 600;
    }
  }
}

.app-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 40, 0.45);
  z-index: 1025;
}

// ---------- Topbar ----------
.app-topbar {
  background: $surface-0;
  border-bottom: 1px solid rgba(10, 34, 64, 0.08);
  padding: 0.6rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 1020;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-content {
  padding: 1.5rem;
  flex: 1;
}

// ---------- KPI Stat Cards ----------
.stat-card {
  background: $surface-0;
  border: 1px solid rgba(10, 34, 64, 0.08);
  border-radius: $border-radius-lg;
  padding: 1.1rem 1.25rem;
  position: relative;
  overflow: hidden;
  height: 100%;
  box-shadow: $box-shadow-sm;

  .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 0.6rem;
  }

  .stat-value { font-size: 1.65rem; font-weight: 700; color: $navy-950; line-height: 1.1; }
  .stat-label { font-size: 0.75rem; color: $navy-300; text-transform: uppercase; letter-spacing: 0.05em; }
  .stat-trend { font-size: 0.72rem; margin-top: 0.35rem; }
}

// ---------- Status badges ----------
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: 50rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;

  &::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

  &.status-active, &.status-online, &.status-completed { color: $signal-green; background: rgba(28, 138, 83, 0.12); }
  &.status-pending, &.status-warning { color: $signal-amber; background: rgba(184, 121, 10, 0.12); }
  &.status-offline, &.status-critical, &.status-overdue { color: $signal-red; background: rgba(214, 40, 57, 0.12); }
  &.status-progress, &.status-atsea { color: $signal-cyan; background: rgba(15, 143, 174, 0.12); }
  &.status-neutral { color: $navy-300; background: rgba(74, 97, 128, 0.1); }
}

// ---------- Panel / card ----------
.panel {
  background: $card-bg;
  border: 1px solid $card-border-color;
  border-radius: $border-radius-lg;
}

.panel-header {
  padding: 0.9rem 1.15rem;
  border-bottom: 1px solid rgba(10, 34, 64, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

// ---------- GIS Map Workspace ----------
// The floating map controls stay dark for contrast against satellite/aerial map
// tiles, independent of the overall app theme.
.gis-workspace {
  position: relative;
  border-radius: $border-radius-lg;
  overflow: hidden;
  border: 1px solid rgba(10, 34, 64, 0.08);
}

.gis-map-canvas {
  width: 100%;
  height: 640px;
  background: $surface-100;
}

.gis-toolbar {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 5;
  background: rgba(10, 22, 40, 0.92);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: $border-radius;
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  box-shadow: $box-shadow-sm;

  .gis-tool-btn {
    width: 38px;
    height: 38px;
    border-radius: $border-radius-sm;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #dce6f2;
    background: transparent;
    border: 1px solid transparent;

    &:hover { background: $navy-700; }
    &.active { background: $primary; color: #fff; border-color: rgba(255, 255, 255, 0.2); }
  }

  .gis-tool-sep { height: 1px; background: rgba(255, 255, 255, 0.1); margin: 0.15rem 0.35rem; }
}

.gis-panel-floating {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  width: 300px;
  max-height: calc(100% - 24px);
  overflow-y: auto;
  background: rgba(10, 22, 40, 0.94);
  color: #dce6f2;
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: $border-radius;
  box-shadow: $box-shadow-sm;
}

.gis-coord-readout {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 5;
  background: rgba(10, 22, 40, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: $border-radius-sm;
  padding: 0.35rem 0.65rem;
  font-family: 'Consolas', 'SFMono-Regular', monospace;
  font-size: 0.75rem;
  color: $signal-cyan;
}

.zone-color-swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  display: inline-block;
  border: 1px solid rgba(10, 34, 64, 0.2);
}

// ---------- Timeline ----------
.mission-timeline {
  list-style: none;
  padding: 0;
  margin: 0;

  li {
    position: relative;
    padding: 0 0 1.5rem 2rem;
    border-left: 2px solid rgba(10, 34, 64, 0.1);

    &:last-child { border-left-color: transparent; padding-bottom: 0; }

    .tl-dot {
      position: absolute;
      left: -9px;
      top: 0;
      width: 16px;
      height: 16px;
      border-radius: 50%;
      background: $surface-100;
      border: 2px solid $navy-400;
    }

    &.done .tl-dot { background: $signal-green; border-color: $signal-green; }
    &.active .tl-dot { background: $signal-cyan; border-color: $signal-cyan; box-shadow: 0 0 0 4px rgba(15, 143, 174, 0.2); }
    &.pending .tl-dot { background: transparent; }
  }
}

// ---------- Fleet Portal (large-tap, tablet friendly) ----------
.fleet-shell { min-height: 100vh; display: flex; flex-direction: column; }

.fleet-topbar {
  background: $surface-0;
  border-bottom: 1px solid rgba(10, 34, 64, 0.08);
  border-top: 3px solid;
  border-image: linear-gradient(90deg, $ensign-saffron 0 33%, #fff 33% 66%, $ensign-green 66% 100%) 1;
  padding: 0.75rem 1rem;
}

.offline-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  border-radius: 50rem;
  font-size: 0.78rem;
  font-weight: 600;

  &.is-online { background: rgba(28, 138, 83, 0.12); color: $signal-green; }
  &.is-offline { background: rgba(214, 40, 57, 0.12); color: $signal-red; }
}

.fleet-big-card {
  background: $card-bg;
  border: 1px solid rgba(10, 34, 64, 0.08);
  border-radius: $border-radius-lg;
  padding: 1.25rem;
  box-shadow: $box-shadow-sm;
}

.zone-progress-track {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;

  .zone-chip {
    flex: 1 1 auto;
    min-width: 90px;
    text-align: center;
    padding: 0.6rem 0.5rem;
    border-radius: $border-radius-sm;
    font-size: 0.78rem;
    font-weight: 600;
    background: $surface-100;
    border: 1px solid rgba(10, 34, 64, 0.08);
    color: $navy-300;

    &.done { background: rgba(28, 138, 83, 0.12); color: $signal-green; border-color: rgba(28, 138, 83, 0.35); }
    &.current { background: rgba(15, 143, 174, 0.12); color: $signal-cyan; border-color: $signal-cyan; }
    &.pending { opacity: 0.7; }
  }
}

.quick-action-btn {
  width: 100%;
  padding: 1rem;
  border-radius: $border-radius-lg;
  background: $surface-0;
  border: 1px solid rgba(10, 34, 64, 0.08);
  color: $body-color;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
  box-shadow: $box-shadow-sm;

  i { font-size: 1.4rem; color: $signal-cyan; }
  &:hover { background: $surface-50; }
}

// ---------- Zone shape list (Zone Master GIS editor) ----------
.zone-shape-list {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid rgba(10, 34, 64, 0.08);
  border-radius: $border-radius-sm;
}

.zone-shape-row {
  border-bottom: 1px solid rgba(10, 34, 64, 0.06);

  &:last-child { border-bottom: none; }
  &:hover { background: $surface-50; }
  &.active { background: rgba(29, 95, 168, 0.08); }
}

// Utility
.text-heading { color: $navy-950 !important; }
.text-navy-300 { color: $navy-300 !important; }
.bg-navy-800 { background-color: $surface-100 !important; }
.bg-navy-850 { background-color: $surface-50 !important; }
.border-navy { border-color: rgba(10, 34, 64, 0.08) !important; }

@media (max-width: 991.98px) {
  .app-sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-100%);
    box-shadow: $box-shadow;
  }
  .app-sidebar.show { transform: translateX(0); }
  .app-sidebar-backdrop.show { display: block; }
}
