html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #eef3f7;
}

header {
  flex: 0 0 auto;
}

.app-view-tabs {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 48px;
  padding: 6px 14px;
  border-top: 1px solid #d8e1e8;
  border-bottom: 1px solid #cbd7e0;
  background: #ffffff;
  box-shadow: 0 2px 7px rgba(11, 29, 51, 0.09);
  overflow-x: auto;
  z-index: 900;
}

.app-view-tab {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 7px 15px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #edf2f6;
  color: #40556a;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.03em;
  cursor: pointer;
}

.app-view-tab:hover {
  background: #dfe8ef;
}

.app-view-tab.active {
  border-color: #0066b3;
  background: #0066b3;
  color: #ffffff;
}

.app-mode-badge {
  flex: 0 0 auto;
  margin-left: auto;
  padding: 7px 11px;
  border-radius: 999px;
  background: #e4f6ec;
  color: #12643a;
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}

.app-workspace {
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.app-sidebar {
  position: relative;
  min-width: 0;
  overflow-y: auto;
  border-right: 1px solid #cbd7e0;
  background: #f7f9fb;
}

.app-view-panel {
  min-height: 100%;
  padding: 12px;
  box-sizing: border-box;
}

.app-view-panel[hidden] {
  display: none !important;
}

.app-panel-heading {
  margin: 0 0 5px;
  color: #0b1d33;
  font-size: 15px;
  font-weight: 900;
}

.app-panel-description {
  margin: 0 0 13px;
  color: #65788b;
  font-size: 11px;
  line-height: 1.45;
}

.app-module-card {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #d7e1e8;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 2px 7px rgba(11, 29, 51, 0.07);
}

.app-module-card-title {
  margin-bottom: 9px;
  color: #0b1d33;
  font-size: 12px;
  font-weight: 900;
}

.app-placeholder {
  padding: 16px;
  border: 1px dashed #aebdca;
  border-radius: 10px;
  background: #ffffff;
  color: #526577;
  font-size: 12px;
  line-height: 1.55;
}

.app-placeholder strong {
  display: block;
  margin-bottom: 6px;
  color: #0b1d33;
  font-size: 13px;
}

.app-main {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #dce6ec;
}

.app-main #map {
  width: 100% !important;
  height: 100% !important;
  min-height: 400px;
}

/* Panel sesji umieszczony w bocznym panelu */

.app-sidebar .training-panel {
  gap: 10px;
  padding: 12px;
  border: 1px solid #d7e1e8;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 2px 7px rgba(11, 29, 51, 0.07);
}

.app-sidebar .training-panel-header {
  align-items: flex-start;
  flex-direction: column;
}

.app-sidebar .training-panel-subtitle {
  display: block;
  margin: 3px 0 0;
}

.app-sidebar .training-timer {
  width: 100%;
  box-sizing: border-box;
}

.app-sidebar .training-controls {
  align-items: stretch;
  flex-direction: column;
}

.app-sidebar #training-name,
.app-sidebar #training-date {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.app-sidebar .training-button {
  width: 100%;
}

.app-sidebar .training-state {
  border-radius: 7px;
  text-align: center;
}

.app-sidebar .training-events {
  align-items: stretch;
  flex-direction: column;
  overflow: visible;
}

.app-sidebar .training-event {
  white-space: normal;
}

/* Sterowanie symulatorem */

.app-sidebar .simulator-controls {
  align-items: stretch;
  flex-direction: column;
}

.app-sidebar .simulator-button {
  width: 100%;
  box-sizing: border-box;
}

.app-sidebar #simulator-state,
.app-sidebar #selected-start {
  display: block;
  width: 100%;
  box-sizing: border-box;
  border-radius: 7px;
  text-align: center;
}

/* Edytor trasy */

.app-sidebar .course-editor {
  gap: 10px;
  padding: 12px;
  border: 1px solid #d7e1e8;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 2px 7px rgba(11, 29, 51, 0.07);
}

.app-sidebar .course-editor-header {
  align-items: flex-start;
  flex-direction: column;
}

.app-sidebar .course-editor-session {
  display: block;
  margin: 4px 0 0;
}

.app-sidebar .course-status {
  display: block;
  width: 100%;
  box-sizing: border-box;
  border-radius: 7px;
  text-align: center;
}

.app-sidebar .course-editor-controls {
  align-items: stretch;
  flex-direction: column;
}

.app-sidebar .course-button {
  width: 100%;
}

@media (max-width: 900px) {
  .app-view-tabs {
    padding-left: 8px;
    padding-right: 8px;
  }

  .app-mode-badge {
    display: none;
  }

  .app-workspace {
    grid-template-columns: 1fr;
    grid-template-rows:
      minmax(155px, 36vh)
      minmax(300px, 1fr);
  }

  .app-sidebar {
    border-right: 0;
    border-bottom: 1px solid #cbd7e0;
  }

  .app-view-panel {
    min-height: auto;
  }
}

/* =========================================================
   Górne dane wiatru i trackerów – widok komputerowy
   ========================================================= */

@media (min-width: 821px) {
  .app-view-tabs {
    position: relative;
    overflow: visible;
  }

  .desktop-status-tools {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-left: auto;
  }

  .app-mode-badge {
    margin-left: 0;
  }

  .desktop-status-widget {
    position: relative;
    flex: 0 0 auto;
  }

  .desktop-status-summary {
    min-height: 34px;
    padding: 8px 12px;
    border: 1px solid #cbd7e0;
    border-radius: 8px;
    background: #f5f8fa;
    color: #31465f;
    box-sizing: border-box;
    font-size: 10px;
    font-weight: 900;
    line-height: 16px;
    white-space: nowrap;
    cursor: pointer;
    list-style: none;
    user-select: none;
  }

  .desktop-status-summary::-webkit-details-marker {
    display: none;
  }

  .desktop-status-summary::after {
    margin-left: 8px;
    color: #718397;
    content: "▾";
  }

  .desktop-status-widget[open]
  .desktop-status-summary {
    border-color: #0066b3;
    background: #e8f3fb;
    color: #0066b3;
  }

  .desktop-status-widget[open]
  .desktop-status-summary::after {
    content: "▴";
  }

  .desktop-wind-summary {
    min-width: 142px;
  }

  .desktop-trackers-summary {
    min-width: 112px;
  }

  .desktop-status-popover {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 2200;
    padding: 10px;
    border: 1px solid #cbd7e0;
    border-radius: 12px;
    background: #ffffff;
    box-shadow:
      0 8px 28px rgba(11, 29, 51, 0.24);
  }

  .desktop-wind-popover {
    min-width: 290px;
  }

  .desktop-trackers-popover {
    min-width: 205px;
  }

  .desktop-status-popover .wind-control,
  .desktop-status-popover .tracker-legend {
    position: static !important;
    display: block !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  .desktop-status-popover
  .tracker-legend {
    padding: 2px !important;
  }

  .desktop-status-popover
  .wind-control {
    padding: 2px !important;
  }

  body.desktop-controls-relocated
  .leaflet-control-container
  .wind-control,
  body.desktop-controls-relocated
  .leaflet-control-container
  .tracker-legend {
    display: none !important;
  }
}

@media (min-width: 821px) and (max-width: 1180px) {
  .app-mode-badge {
    display: none;
  }

  .app-view-tab {
    padding-right: 10px;
    padding-left: 10px;
  }

  .desktop-status-summary {
    padding-right: 9px;
    padding-left: 9px;
  }
}

/* =========================================================
   LIVE i RACE LAB
   ========================================================= */

.live-simulator-quick-card {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.live-simulator-status {
  padding: 8px 10px;
  border-radius: 8px;
  background: #edf2f6;
  color: #526577;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.live-simulator-status.running {
  background: #e4f6ec;
  color: #12643a;
}

.live-simulator-actions {
  display: grid;
  grid-template-columns:
    repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.live-action-button {
  min-height: 40px;
  padding: 7px 8px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  font-size: 10px;
  font-weight: 900;
  cursor: pointer;
}

.live-action-button.start {
  background: #16834b;
}

.live-action-button.stop {
  background: #c23b32;
}

.live-action-button.lab {
  background: #0066b3;
}

.live-action-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.race-lab-intro {
  margin-bottom: 12px;
  border-style: solid;
  background: #f4f9fc;
}

@media (max-width: 1050px) and (min-width: 821px) {
  .live-simulator-actions {
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   Globalny instrument wiatru
   ========================================================= */

.wind-instrument-compass {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border: 1px solid #9db0bf;
  border-radius: 50%;
  background:
    linear-gradient(
      to bottom,
      transparent 48%,
      #d3dde4 49%,
      #d3dde4 51%,
      transparent 52%
    ),
    linear-gradient(
      to right,
      transparent 48%,
      #d3dde4 49%,
      #d3dde4 51%,
      transparent 52%
    ),
    #ffffff;
}

.wind-instrument-compass::before {
  position: absolute;
  top: 1px;
  color: #65788b;
  content: "N";
  font-size: 6px;
  font-weight: 900;
}

.wind-instrument-arrow {
  display: inline-block;
  color: #0077b6;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  transform-origin: center;
  transition: transform 300ms ease;
}

.wind-instrument-values {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  min-width: 54px;
}

.wind-instrument-direction {
  color: #0b1d33;
  font-size: 14px;
  line-height: 1.05;
}

.wind-instrument-speed {
  color: #0066b3;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.1;
}

@media (min-width: 821px) {
  .desktop-wind-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 130px;
    padding: 4px 10px;
  }

  .desktop-wind-summary::after {
    margin-left: 2px;
  }
}


/* OPTIWAKE GLOBAL WIND INSTRUMENT */

.wind-instrument-compass {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border: 1px solid #9db0bf;
  border-radius: 50%;
  background:
    linear-gradient(
      to bottom,
      transparent 48%,
      #d3dde4 49%,
      #d3dde4 51%,
      transparent 52%
    ),
    linear-gradient(
      to right,
      transparent 48%,
      #d3dde4 49%,
      #d3dde4 51%,
      transparent 52%
    ),
    #ffffff;
}

.wind-instrument-compass::before {
  position: absolute;
  top: 1px;
  color: #65788b;
  content: "N";
  font-size: 6px;
  font-weight: 900;
}

.wind-instrument-arrow {
  display: inline-block;
  color: #0077b6;
  font-size: 23px;
  font-weight: 900;
  line-height: 1;
  transform-origin: center;
  transition: transform 300ms ease;
}

.wind-instrument-values {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  min-width: 55px;
}

.wind-instrument-direction {
  color: #0b1d33;
  font-size: 14px;
  line-height: 1.05;
}

.wind-instrument-speed {
  color: #0066b3;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.1;
}

@media (min-width: 821px) {
  .desktop-wind-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 132px;
    padding: 4px 10px;
  }

  .desktop-wind-summary::after {
    margin-left: 2px;
  }
}
