/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2016-2017, 2025 Dan "Ducky" Little
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

@favorite-star-color: #29b2ff;

.group {
  .group {
    padding-left: 20px;
  }

  .group-label {
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;

    input[type="checkbox"] {
      /* force fontawesome for the checkbox */
      .fa;
      border: none;

      &::before {
        display: inline-block;
        content: @fa-var-chevron-right;
        transform: translateX(50%) translateY(0%);
      }

      transition: 120ms transform ease-in-out;
      transform: rotate(0deg);

      &:checked {
        transform: rotate(90deg);
        &::before {
          transform: translateX(50%) translateY(-50%);
        }
      }
    }

    &:hover {
      background-color: #eee;
    }
  }

  .layer {
    padding-left: 20px;
  }

  &.gm-collapse {
    .children {
      max-height: 0 !important;
      overflow: hidden;
      visibility: hidden !important;
      transition:
        max-height 0.5s ease-in,
        visibility 0s linear 0.5s;
    }
  }

  &.gm-expand {
    .children {
      max-height: 3000px;
      visibility: visible;
      transition:
        max-height 0.5s ease-in,
        visibility 0s linear 0;
    }
  }
}

@checkbox-width: 20px;
@checkbox-margin: 2px;

.layer {
  /* unstyle the tool buttons */
  button {
    margin: 0;
    padding: 0;
    background: none;
    border: none;
  }

  .layer-label {
    cursor: pointer;

    .checkbox {
      margin: @checkbox-margin;
      width: @checkbox-width;
    }
  }

  .layer-tools,
  .catalog-legend {
    padding-left: (@checkbox-width + @checkbox-margin * 2);
  }

  .metadata.icon,
  .favorite.icon,
  .refresh.icon,
  .checkbox.icon {
    font-size: 110%;
  }

  .favorite.icon {
    margin-right: 0.25em;
  }

  .metadata.icon,
  .refresh.icon {
    margin-right: 0.25em;
    margin-left: 0.25em;
  }

  &.out-of-resolution {
    color: #aaa;
    font-style: italic;
  }

  .layer-tools {
    .icon {
      color: #333;
      font-size: 20px;
      width: 28px;
      height: 28px;
      border-radius: 14px;

      display: inline-flex;
      justify-content: center;
      align-items: center;

      margin-right: 4px;
      margin-bottom: 4px;

      &:hover {
        box-shadow: 0 0 1px 1px #a09999;
      }

      &.active {
        box-shadow: 0 0 1px 1px #a09999;
        background-color: rgba(160, 153, 153, 0.2);
      }
    }
  }

  input[type="checkbox"].favorite {
    color: @favorite-star-color;
    border: none;
  }
}

.layer.inline-tools {
  .layer-label {
    display: inline-block;
  }

  .layer-tools {
    padding-left: 6px;
    display: inline-block;
  }
}

.catalog {
  .searchbox {
    position: absolute;
    width: 100%;
    top: 0;
    left: 0;

    text-align: center;

    input {
      padding: 4px;
      margin: 4px;
      text-align: left;
      width: 85%;
      height: 20px;
    }
  }

  a.metadata {
    color: black;
  }
}

.catalog.searchable {
  padding-top: 40px;
  padding-left: 4px;
}

.catalog.favorites.flat {
  padding-left: 4px;
}

.catalog.visible-layers.flat {
  padding-left: 4px;
}

/***
 ***  Flat Catalog
 ***/

.catalog.flat {
  .group {
    padding-left: 0px;

    .group-label {
      display: none;
    }

    .children {
      max-height: 2000px !important;
    }

    .layer {
      padding-left: 0px;
    }
  }
}
