/**
 * TopBar 스타일
 * 지도 상단 중앙 정보/검색 바
 */

.topBar {
  position: absolute;
  top: 1.5rem;
  left: 0;
  right: 0;
  height: 4.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5.4rem;
  box-sizing: border-box;
  z-index: 95;
  pointer-events: none; // 빈 영역은 지도 이벤트 통과

  > * {
    pointer-events: auto; // 내부 요소는 클릭 가능
  }
}

// 위치 정보 바
.locationInfo {
  flex: 0 0 auto;
  min-width: 71rem;
  height: 3.8rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  background-color: rgba(var(--secondary6-rgb), 0.9);
  // overflow: hidden 제거 - 설정 드롭다운 표시를 위해

  ul {
    display: flex;
    align-items: center;
    width: 100%;
    height: 100%;

    li {
      display: flex;
      align-items: center;
      height: 100%;
      padding: 0 1rem;
      color: var(--white);
      font-weight: var(--fw-bold);
      font-size: 1.3rem;

      &:first-child,
      &:last-child {
        padding: 0;
      }

      span + span {
        padding-right: 0.5rem;
      }

      // 구분선 (좌표 표시)
      &.divider {
        position: relative;
        width: 20rem; // 고정 너비로 아이콘 위치 고정
        flex-shrink: 0;
        font-variant-numeric: tabular-nums; // 숫자 고정폭
        font-feature-settings: "tnum"; // 숫자 고정폭 (fallback)

        &::after {
          content: '';
          position: absolute;
          right: 0;
          top: 50%;
          transform: translateY(-50%);
          width: 1px;
          height: 1.8rem;
          background-color: rgba(255, 255, 255, 0.3);
        }
      }

      // WGS84 좌표 라벨
      .wgs {
        display: flex;
        align-items: center;
        padding-right: 0.5rem;

        &::before {
          content: '';
          display: block;
          width: 2rem;
          height: 2rem;
          margin-right: 0.5rem;
          background: url(../../assets/images/ico_globe.svg) no-repeat center / 2rem;
        }
      }

      // 시간 영역
      &.time-section {
        width: 22rem; // 고정 너비
        flex-shrink: 0;
        font-variant-numeric: tabular-nums;
        font-feature-settings: "tnum";
      }

      // 시간 뱃지 (KST/UTC)
      .time-badge {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 3.1rem;
        height: 1.8rem;
        margin-right: 0.5rem;
        border-radius: 0.3rem;
        color: var(--white);
        font-size: var(--fs-s);
        font-weight: var(--fw-bold);
        flex-shrink: 0;

        &.kst {
          background-color: var(--tertiary3);
        }

        &.utc {
          background-color: var(--primary1);
        }
      }

      // 설정 컨테이너
      &.settings-container {
        position: relative;
        padding: 0 0.5rem;
        flex-shrink: 0;
      }

      // 첫번째(지도) 버튼 컨테이너
      &:first-child {
        flex-shrink: 0;
      }

      // 선박 모드 컨테이너
      &.ship-mode-container {
        position: relative;
        display: flex;
        align-items: center;
        flex-shrink: 0;
        padding: 0;
      }

      // 추적 중인 함정 정보
      .tracked-ship-info {
        display: flex;
        align-items: center;
        gap: 0.6rem;
        padding: 0 1rem;
        height: 100%;
        background-color: rgba(var(--primary1-rgb), 0.3);
        border-left: 1px solid rgba(var(--white-rgb), 0.2);

        .tracked-name {
          color: var(--white);
          font-size: 1.2rem;
          font-weight: var(--fw-bold);
          max-width: 12rem;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
        }

        .tracked-radius {
          color: var(--tertiary3);
          font-size: 1.1rem;
          font-weight: var(--fw-bold);
          padding: 0.2rem 0.5rem;
          background-color: rgba(var(--tertiary3-rgb), 0.2);
          border-radius: 0.3rem;
        }
      }
    }
  }

  // 설정 드롭다운
  .settings-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 16rem;
    padding: 1rem;
    background-color: rgba(var(--secondary6-rgb), 0.95);
    border-radius: 0.8rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 100;

    .settings-group {
      & + .settings-group {
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid rgba(var(--white-rgb), 0.1);
      }
    }

    .settings-label {
      color: rgba(var(--white-rgb), 0.7);
      font-size: 1.1rem;
      margin-bottom: 0.6rem;
    }

    .settings-options {
      display: flex;
      gap: 0.5rem;

      button {
        flex: 1;
        padding: 0.6rem 1rem;
        border: 1px solid rgba(var(--white-rgb), 0.2);
        border-radius: 0.4rem;
        background-color: transparent;
        color: rgba(var(--white-rgb), 0.7);
        font-size: 1.2rem;
        cursor: pointer;
        transition: all 0.15s ease;
        width: auto;
        height: auto;

        &:hover {
          border-color: rgba(var(--white-rgb), 0.4);
          color: var(--white);
          background-color: transparent;
        }

        &.active {
          border-color: var(--primary1);
          background-color: var(--primary1);
          color: var(--white);
        }
      }
    }
  }

  // 버튼 공통
  button {
    width: 4rem;
    height: 3.8rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-sizing: border-box;
    background-color: var(--secondary3);
    background-repeat: no-repeat;
    background-position: center;
    background-size: 3rem;
    border: none;
    transition: background-color 0.2s ease;

    &:hover,
    &.active {
      background-color: rgba(var(--primary1-rgb), 0.8);
    }

    // 지도 모드 버튼
    &.map {
      background-image: url(../../assets/images/ico_map.svg);
    }

    // 선박 버튼
    &.ship {
      background-image: url(../../assets/images/ico_ship.svg);
    }

    // 설정 버튼
    &.set {
      width: 2rem;
      height: 2rem;
      background-color: transparent;
      background-image: url(../../assets/images/ico_set_s.svg);
      background-size: 2rem;

      &:hover,
      &.active {
        background-color: transparent;
      }
    }
  }
}

// 검색 박스
.topSchBox {
  position: absolute;
  right: 5.4rem;
  flex: 0 0 auto;
  width: 26rem;
  display: flex;
  flex-direction: column;

  // 입력창 래퍼
  .search-input-wrapper {
    position: relative;
    width: 100%;
    height: 3.8rem;
  }

  .tschInput {
    width: 100%;
    height: 100%;
    padding: 0 4.4rem 0 1.2rem;
    border-radius: 2rem;
    background-color: rgba(var(--secondary6-rgb), 0.9);
    border: 0;
    color: var(--white);
    font-size: var(--fs-m);

    &::placeholder {
      color: rgba(var(--white-rgb), 0.6);
    }

    &:focus {
      outline: none;
      background-color: rgba(var(--secondary6-rgb), 1);
    }
  }

  // 검색어 지우기 버튼
  .search-clear-btn {
    position: absolute;
    top: 50%;
    right: 3rem;
    transform: translateY(-50%);
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: none;
    background: transparent;
    color: rgba(var(--white-rgb), 0.6);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;

    &:hover {
      color: var(--white);
    }
  }

  .mainSchBtn {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    width: 3rem;
    height: 3.8rem;
    font-size: 0;
    text-indent: -999999em;
    border: none;
    cursor: pointer;
    background: url(../../assets/images/ico_search_main.svg) no-repeat center / 2rem;
    background-color: transparent;

    &:hover {
      opacity: 0.8;
    }
  }

  // 검색 결과 목록
  .search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.5rem;
    padding: 0.5rem 0;
    background-color: rgba(var(--secondary6-rgb), 0.95);
    border-radius: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    max-height: 30rem;
    overflow-y: auto;
    z-index: 100;
    list-style: none;

    // 스크롤바 스타일
    &::-webkit-scrollbar {
      width: 6px;
    }

    &::-webkit-scrollbar-track {
      background: transparent;
    }

    &::-webkit-scrollbar-thumb {
      background: rgba(var(--white-rgb), 0.3);
      border-radius: 3px;
    }
  }

  // 검색 결과 항목
  .search-result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1.2rem;
    cursor: pointer;
    transition: background-color 0.15s ease;

    &:hover {
      background-color: rgba(var(--primary1-rgb), 0.3);
    }

    .result-info {
      display: flex;
      flex-direction: column;
      gap: 0.2rem;
      overflow: hidden;
    }

    .result-name {
      color: var(--white);
      font-size: 1.3rem;
      font-weight: var(--fw-bold);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .result-id {
      color: rgba(var(--white-rgb), 0.6);
      font-size: 1.1rem;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .result-action {
      flex-shrink: 0;
      width: 2.4rem;
      height: 2.4rem;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--tertiary3);

      &:hover {
        color: var(--white);
      }
    }
  }

  // 검색 결과 없음
  .search-no-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.5rem;
    padding: 1.2rem;
    background-color: rgba(var(--secondary6-rgb), 0.95);
    border-radius: 1rem;
    color: rgba(var(--white-rgb), 0.6);
    font-size: 1.2rem;
    text-align: center;
    z-index: 100;
  }
}

// 접근성: 스크린리더 전용 텍스트
.blind {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
