/* mobile.css */
@media (max-width: 768px) and (pointer: coarse) {

  :root {
    --top-nav-height: 52px;
    --bottom-bar-height: 44px;
    --bottom-bar-margin: 0;

    --safe-bottom: env(safe-area-inset-bottom, 0px);
  }

  html {
    font-size: 12px;
  }

  body {
    overflow-y: hidden;
  }
  body.add-layers-open {
    overflow: hidden !important;
    height: 100% !important;
    position: fixed !important; /* trava o body no iOS */
    width: 100% !important;
    left: 0;
    right: 0;
    /* o JS coloca top: -scrollYpx */
  }

  /* TopBar */

  .top-bar {
    height: var(--top-nav-height);
    padding: 0 14px;
  }

  /* Logo - mobile */
  [data-bs-theme=light] .logo,
[data-bs-theme=dark] .logo {
  background-image: url('/static/assets/welcome/logo-atlantic-mob.svg');
  width: 120px;
  height: var(--top-nav-height);
  background-size: 110px auto;
  background-position: left center;
  background-repeat: no-repeat;
  }

  .top-bar .menu {
    gap: 8px;
  }

  .top-bar .menu .menu-item {
    padding: 0 6px;
  }

  .top-bar .menu .menu-item .menu-icon {
    height: 22px;
  }

  .top-bar .menu .menu-item .text {
    padding-top: 3px;
    font-size: 0.65em;
    line-height: 1.1;
    white-space: nowrap;
  }

  @supports (height: 100svh) {
    .leaflet-container {
      height: calc(100svh - var(--top-nav-height) - var(--bottom-bar-height) - var(--safe-bottom));
    }
  }

  @supports not (height: 100svh) {
  @supports (height: 100dvh) {
    .leaflet-container {
      height: calc(100dvh - var(--top-nav-height) - var(--bottom-bar-height) - var(--safe-bottom));
    }
  }

  @supports not (height: 100dvh) {
  .leaflet-container {
    height: calc(100vh - var(--top-nav-height) - var(--bottom-bar-height) - var(--safe-bottom));
      }
    }
  }

  /* popup */

  .popup-area {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .popup-area .popup {
    max-height: calc(100vh - var(--top-nav-height) - var(--bottom-bar-height) - 60px);
    display: flex;
    flex-direction: column;
  }

  .popup-area .popup .popup-body {
    max-height: calc(100vh - var(--top-nav-height) - var(--bottom-bar-height) - 130px);
    overflow-y: auto;
    padding-right: 10px;
    -webkit-overflow-scrolling: touch;
  }

  .popup-area .popup .popup-body * {
    max-width: 109%;
  }

  .popup-area .popup .popup-header {
    padding: 5px 10px;
  }

  .popup-area .popup .popup-title {
    font-size: 0.8rem;
  }

  /* Add layers - fullscreen*/
  .popup-area .popup#add-layers {
    position: fixed !important;
    top: var(--top-nav-height) !important;
    left: 0 !important;
    right: 0 !important;
    bottom: calc(var(--bottom-bar-height) + var(--safe-bottom)) !important;

    width: auto !important;
    height: auto !important;

    max-width: 100vw !important;
    max-height: none !important;

    margin: 0 !important;
    border-radius: 0 !important;
    z-index: 99999 !important;
    overscroll-behavior: contain;
    touch-action: pan-y;
    background: var(--color-000);
  }

  .popup-area .popup#add-layers .popup-header {
    position: sticky;
    top: 0;
    z-index: 2;
  }

  .popup-area .popup#add-layers .popup-body {
    height: calc(100% - 40px);
    max-height: none !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-right: 10px;

    overscroll-behavior: contain;
  }
  @supports (-webkit-touch-callout: none) {
    .popup-area .popup#add-layers {
      max-height: -webkit-fill-available !important;
    }
  }

  /* add layers */

  .add-layers .sub-menu {
    gap: 2px;
    margin-bottom: 4px;
  }

  .popup-area .popup#add-layers {
    max-width: 100vw;
    width: 100vw;
    flex: 0 0 auto;
  }

  .add-layers .sub-menu .sub-menu-button {
    padding: 3px 5px;
    margin: 2px;
    font-size: 0.8rem;
  }

  .add-layers .sub-menu-content-container {
    padding: 4px 14px;
    margin: 3px 3px 3px -12px;
    width: calc(100% + 20px);
  }

  .add-layers .gallery-content .gallery-item {
    padding: 3px 6px;
    min-width: 50px;
    min-height: 50px;
  }

  .add-layers .gallery-content .gallery-item .gallery-item-map {
    width: 64px;
    height: 42px;
  }

  .add-layers .gallery-content .gallery-item .gallery-item-icon {
    width: 30px;
    height: 30px;
  }

  .add-layers .pills-container .pill-type {
    padding: 3px 6px;
  }

  .add-layers .layers-titlebar {
    padding: 1px 35px 1px 4px;
  }

  .add-layers .layers .dataset {
    margin: 6px 0;
  }

  .add-layers .layers .dataset .layer {
    padding: 2px 0;
  }

  .add-layers .layers .layer .layer-label {
    font-size: 0.7rem;
    white-space: normal;
  }

  .no-layers-add-layers {
    font-size: 0.74rem;
    padding: 5px;
  }

  .add-layers .layers .layer .layer-icon,
  .add-layers .layers .layer .layer-info,
  .add-layers .layers .layer .layer-streamline,
  .add-layers .layers .layer .layer-historical {
    width: 12px;
    height: 12px;
  }

  .add-layers .layers .layer .layer-checkbox-plus-icon,
  .add-layers .layers .layer .layer-checkbox-minus-icon {
    margin-top: -3px;
    width: 12px;
    height: 12px;
  }

  /* Collapse/Expand all button*/
  .add-layers .collapse-all-button {
    padding: 2px 6px;
    gap: 6px;
    font-size: 9px;
  }

  .add-layers .collapse-all-icon {
    width: 12px;
    height: 8px;
  }

  /* Active layers (somente reduzido, NÃO fullscreen) */

  .active-layers .clear-layers .clear-layers-button {
    padding: 2px 4px;
    gap: 3px;
  }

  .active-layers .clear-layers .clear-layers-button span {
    font-size: 9px;
  }

  .active-layer {
    padding: 5px 0;
    gap: 3px;
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .active-layer .active-layer-left-content {
    gap: 2px;
    max-width: 58%;
    flex-wrap: wrap;
  }

  .active-layer .active-layer-left-content span {
    white-space: normal;
  }

  .active-layer .active-layer-left-content-container .active-layer-dataset-content {
    font-size: 0.65rem;
  }

  .active-layer .active-layer-left-content-container .active-layer-status-content {
    margin-top: 6px;
  }

  .active-layer .active-layer-right-content {
    gap: 13px;
    min-width: 13px;
    align-items: flex-start;
  }

  .active-layer .active-layer-close {
    width: 14px;
    height: 14px;
  }

  .active-layer-color-icon {
    width: 13px;
    height: 7px;
    margin-top: -28px;
    margin-left: 80px;
  }

  .active-layer .active-layer-right-content .active-layer-legend-container .active-layer-legend-values .active-layer-legend-value {
    font-size: 8px;
    margin-inline: -6px;
  }

  .active-layer .active-layer-right-content .active-layer-legend-container .active-layer-legend-values {
    margin: -13px -12px 0px 0px;
  }
  .active-layer .active-layer-right-content .active-layer-legend-container.trajectory-legend .active-layer-legend-values {
    margin: 0px -12px 0px 0px;
  }

  .active-layer .active-layer-details {
    padding: 10px;
    margin-right: 10px;
  }

  .active-layer .active-layer-details-content {
    padding-right: 8px;
  }

  .active-layer .active-layer-details-label {
    font-size: 0.7rem;
  }

  .active-layer .active-layer-tools .icon {
    width: 14px;
    height: 14px;
  }

  .active-layer .active-layer-color-range .active-layer-color-range-auto {
    padding: 1px 4px;
    font-size: 6px;
  }

  .active-layer-slider-labels {
    font-size: 8px;
    margin-top: 4px;
  }

  .active-layer-legend-name {
    font-size: 9px;
  }

  .active-layer .active-layer-palettes-label,
  .active-layer .active-layer-tool-label,
  .active-layer .active-layer-color-schemes .scheme-label {
    font-size: 0.5rem;
  }

  .active-layer .active-layer-color-schemes .scheme {
    padding: 1px 3px;
    font-size: 0.48rem;
  }

  .active-layer .active-layer-color-range .active-layer-color-range-input {
    width: 20px;
    font-size: 7px;
    padding: 1px 1px;
  }

  .active-layer .active-layer-legend-container .active-layer-legend-value {
    font-size: 6px;
  }

  .active-layer .active-layer-palettes-body {
    gap: 2px;
  }

  .active-layer-color-scheme .active-layer-color-scheme-part  {
    width: 13px;
    height: 10px;
  }

  .active-layer .active-layer-legend {
    padding: 1px 2px;
  }

  .active-layer .active-layer-legend img:not(.active-layer-palettes-icon) {
    height: 8px !important;
    max-width: 100%;
  }

  .active-layer .active-layer-legend .active-layer-palettes-icon {
    width: 15px;
    height: 6px;
    margin-left: 3px;
    margin-top: -1px;
  }

  .active-layer .active-layer-right-content .active-layer-legend-container .active-layer-legend-div {
    width: 85px;
  }

  .active-layer .toggle-switch {
    transform: scale(0.85);
    transform-origin: left center;
  }

  .active-layer .active-layer-tools {
    margin: 0;
    margin-top: 10px;
    gap: 5px;
    align-items: flex-start;
  }

  .active-layer .toggle-switch .slider {
    height: 10px;
  }

  .active-layer .toggle-switch .slider:before {
    width: 10px;
    height: 10px;
  }

  .data-not-available {
    flex-wrap: nowrap;
    align-items: center;
    padding: 2px 5px;
    border-radius: 4px;
    width: fit-content;
    max-width: 100%;
  }

  .data-not-available-text {
    font-size: 8px;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
  }

  .data-not-available-date {
    padding: 0 6px;
    font-size: 9px;
    height: 14px;
    line-height: 14px;
    flex-shrink: 0;
  }

  /* Leaflet controls */

  .leaflet-control.custom-control {
    padding: 3px;
    transform: scale(0.9);
    transform-origin: top right;
  }

  .leaflet-control.custom-control .leaflet-bar a,
  .leaflet-control.custom-control .leaflet-bar button {
    width: 20px;
    height: 20px;
    font-size: 11px;
  }

  .leaflet-control .zoom-control .leaflet-bar.leaflet-bar a {
    height: 16px;
    width: 16px;
    font-size: 13px;
    line-height: 16px;
  }

  .leaflet-control-scale-line {
    padding: 4px 3px 1px;
    font-size: 10px;
  }

  /* Popup close button */

  .popup-area .popup .popup-close {
    width: 14px;
    height: 14px;
  }

  /* Bottom bar */

  .bottom-bar {
    display: none;
  }

  body.has-map:not(.welcome-open) .bottom-bar {
    display: grid;

    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99998;

    height: calc(var(--bottom-bar-height) + var(--safe-bottom));
    padding: 0 14px var(--safe-bottom) 14px;

    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 10px;
    row-gap: 4px;

    background-color: var(--color-g-050);
    box-sizing: border-box;
  }

  body.has-map:not(.welcome-open) .bottom-bar .slider-container {
    display: none !important;
  }

  body.has-map:not(.welcome-open) .bottom-bar .player {
    grid-column: 1;
    grid-row: 1 / span 2;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    flex-wrap: nowrap;
  }

  body.has-map:not(.welcome-open) .bottom-bar .player img {
    max-height: 11px;
    display: block;
  }

  body.has-map:not(.welcome-open) .bottom-bar .player .player-button .player-text {
    display: none;
  }

  body.has-map:not(.welcome-open) .bottom-bar .player .player-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 0;
  }

  body.has-map:not(.welcome-open) .bottom-bar .player .player-button::after {
    font-size: 9px;
    color: var(--color-g-450);
    white-space: nowrap;
    line-height: 1;
    content: "";
  }

  body.has-map:not(.welcome-open) .bottom-bar .player .player-button:nth-child(1)::after { content: "1 DAY"; }
  body.has-map:not(.welcome-open) .bottom-bar .player .player-button:nth-child(2)::after { content: "1H"; }
  body.has-map:not(.welcome-open) .bottom-bar .player .player-button:nth-child(3)::after { content: "1H"; }
  body.has-map:not(.welcome-open) .bottom-bar .player .player-button:nth-child(4)::after { content: "1 DAY"; }

  body.has-map:not(.welcome-open) .bottom-bar .calendar {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    margin: 0;
    font-size: 11px;
    min-width: 0;
  }

  body.has-map:not(.welcome-open) .bottom-bar .calendar .calendar-text {
    width: auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.has-map:not(.welcome-open) .bottom-bar .location {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    margin: 0;
    font-size: 10px;
    min-width: 0;
  }

  body.has-map:not(.welcome-open) .bottom-bar .location .location-text {
    width: auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.has-map:not(.welcome-open) .bottom-bar .location .current-location {
    width: 14px;
    height: 14px;
    filter: var(--primary-filter);
    cursor: pointer;
    flex: 0 0 auto;
  }

  /* Popup*/
  .popup-area .popup#base-layers {
    position: fixed !important;
    left: 8px !important;
    bottom: calc(var(--bottom-bar-height) + var(--safe-bottom) + 12px) !important;
    min-width: 0;
    max-width: calc(100vw - 16px) !important;
    z-index: 100000 !important;
  }

  .base-layers.base-layers-shell {
    padding: 2px 2px;
    border-radius: 6px;
  }

  .base-layers.base-layers-shell .base-layers-panel {
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .base-layers .base-layer-item {
    padding: 0px;
    min-width: 50px;
    min-height: 50px;
    border-radius: 6px;
  }

  .base-layers .base-layer-item .base-layer-item-minimap {
    width: 48px;
    height: 30px;
    margin: 0 auto 2px auto;
  }

  .base-layers .base-layer-item .base-layer-item-text {
    font-size: 7px;
    line-height: 8px;
    max-width: 52px;
  }

  #base-layers .row.row-cols-2 > .col-auto {
    padding: 2px 2px;
  }

  #base-layers .base-layer-item-minimap {
    width: 48px;
    height: 30px;
    margin: 0 auto 2px auto;
  }

  #base-layers .base-layer-item-text {
    font-size: 7px;
    line-height: 8px;
    padding: 0 2px 2px;
    white-space: normal;
  }

  body.add-layers-open .popup-area .popup#base-layers {
    z-index: 99998 !important;
    pointer-events: none;
  }

  /* Sidebar fullscreen no mobile */
  body.sidebar-open #sidebar {
    position: fixed;
    top: var(--top-nav-height);
    left: 0;
    right: 0;
    bottom: calc(var(--bottom-bar-height) + var(--safe-bottom));
    width: 100vw;
    height: calc(100vh - var(--top-nav-height) - var(--bottom-bar-height) - var(--safe-bottom));
    z-index: 9000;
    background: var(--color-000);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.sidebar-open #sidebar.d-none {
    display: block !important;
  }

  body.sidebar-open .leaflet-container {
    pointer-events: none;
  }

  body.sidebar-open #sidebar {
    pointer-events: auto;
  }
}

/* Bottom bar */
@media (max-width: 380px) and (pointer: coarse) {

  :root {
    --bottom-bar-height: 44px;
  }

  body.has-map:not(.welcome-open) .bottom-bar {
    padding: 0 10px var(--safe-bottom) 10px;
    column-gap: 8px;
    row-gap: 4px;
  }

  body.has-map:not(.welcome-open) .bottom-bar .player {
    gap: 8px;
  }

  body.has-map:not(.welcome-open) .bottom-bar .player img {
    max-height: 10px;
  }

  body.has-map:not(.welcome-open) .bottom-bar .player .player-button::after {
    font-size: 8px;
  }

  body.has-map:not(.welcome-open) .bottom-bar .calendar {
    font-size: 10px;
  }

  body.has-map:not(.welcome-open) .bottom-bar .location {
    font-size: 9px;
  }

  body.has-map:not(.welcome-open) .bottom-bar .location .current-location {
    width: 16px;
    height: 16px;
  }

  .popup-area .popup#base-layers {
    left: 6px !important;
    bottom: calc(var(--bottom-bar-height) + var(--safe-bottom) + 10px) !important;
    max-width: calc(100vw - 12px) !important;
  }

  .base-layers .base-layer-item {
    min-width: 44px;
    min-height: 44px;
  }

  .base-layers .base-layer-item .base-layer-item-minimap,
  #base-layers .base-layer-item-minimap {
    width: 42px;
    height: 26px;
  }

  .base-layers .base-layer-item .base-layer-item-text,
  #base-layers .base-layer-item-text {
    font-size: 6px;
    line-height: 7px;
    max-width: 44px;
  }
}