/**
 * 항적조회 뷰어 스타일
 */

.track-query-viewer {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: rgba(30, 35, 55, 0.95);
  border-radius: 8px;
  padding: 12px 16px;
  width: 980px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  color: #fff;

  &.compact {
    width: 600px;
    padding: 8px 12px;

    .track-query-time-info {
      font-size: 11px;
    }

    .track-query-progress-bar {
      height: 16px;
    }

    .progress-handle {
      width: 14px;
      height: 14px;
    }
  }

  // 단일 선박 모드 (선박 모달에서 1척 조회 시)
  &.single-vessel {
    width: 480px;
  }

  // 선박 모달 모드 (fixed 배치, 중앙 하단)
  &.modal-mode {
    position: fixed;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    width: 520px;
    z-index: 1000;
  }

  // 드래그 중
  &.dragging {
    user-select: none;
    opacity: 0.95;
  }
}

// 헤더 (선명, TargetId, 버튼)
.track-query-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: -12px -16px 8px;
  padding: 8px 12px;
  background: linear-gradient(135deg, rgba(79, 195, 247, 0.3), rgba(41, 182, 246, 0.2));
  border-bottom: 1px solid rgba(79, 195, 247, 0.3);
  border-radius: 8px 8px 0 0;

  // 드래그 가능 상태
  &.draggable {
    cursor: move;
    cursor: grab;

    &:active {
      cursor: grabbing;
    }
  }

  .header-info {
    display: flex;
    align-items: center;
    gap: 10px;

    .vessel-name {
      font-size: 14px;
      font-weight: 600;
      color: #fff;
    }

    .vessel-id {
      font-size: 12px;
      color: rgba(255, 255, 255, 0.7);
      padding: 2px 6px;
      background: rgba(255, 255, 255, 0.1);
      border-radius: 3px;
    }

    .vessel-signal {
      font-size: 11px;
      color: #4fc3f7;
      padding: 2px 6px;
      background: rgba(79, 195, 247, 0.2);
      border-radius: 3px;
    }

    .vessel-kind {
      font-size: 11px;
      color: #81c784;
      padding: 2px 6px;
      background: rgba(129, 199, 132, 0.2);
      border-radius: 3px;
    }

    .vessel-count {
      font-size: 14px;
      font-weight: 600;
      color: #fff;
    }
  }

  .header-actions {
    display: flex;
    align-items: center;
    gap: 8px;

    .live-ship-toggle {
      padding: 4px 10px;
      border: none;
      border-radius: 4px;
      font-size: 11px;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.2s ease;

      &.on {
        background: rgba(76, 175, 80, 0.8);
        color: #fff;

        &:hover {
          background: rgba(76, 175, 80, 1);
        }
      }

      &.off {
        background: rgba(244, 67, 54, 0.8);
        color: #fff;

        &:hover {
          background: rgba(244, 67, 54, 1);
        }
      }
    }

    .close-btn {
      background: transparent;
      border: none;
      color: rgba(255, 255, 255, 0.7);
      font-size: 14px;
      cursor: pointer;
      padding: 2px 6px;
      border-radius: 4px;
      transition: all 0.2s ease;
      line-height: 1;

      &:hover {
        background: rgba(244, 67, 54, 0.3);
        color: #fff;
      }
    }
  }
}

.track-query-progress-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.track-query-time-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);

  .start-time,
  .end-time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
  }

  .current-time {
    font-size: 14px;
    font-weight: 600;
    color: #4fc3f7;
  }
}

.track-query-progress-bar {
  position: relative;
  height: 20px;
  cursor: pointer;
  user-select: none;

  .progress-track {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 6px;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: visible;
  }

  .progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, #4fc3f7, #29b6f6);
    border-radius: 3px;
    transition: width 0.05s ease-out;
  }

  .progress-handle {
    position: absolute;
    top: 50%;
    width: 16px;
    height: 16px;
    background: #fff;
    border: 2px solid #4fc3f7;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    cursor: grab;
    transition: transform 0.1s ease;

    &:hover {
      transform: translate(-50%, -50%) scale(1.2);
    }

    &:active {
      cursor: grabbing;
      transform: translate(-50%, -50%) scale(1.1);
    }
  }
}

.track-query-options {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 4px;

  .option-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: transparent;
    transition: all 0.2s ease;
    user-select: none;

    input[type='checkbox'] {
      display: none;
    }

    // 체크된 상태
    &:has(input:checked) {
      color: #fff;
      background: rgba(79, 195, 247, 0.25);
      border-color: rgba(79, 195, 247, 0.5);
    }

    // 체크 안된 상태
    &:has(input:not(:checked)) {
      color: rgba(255, 255, 255, 0.4);
      border-color: rgba(255, 255, 255, 0.1);
    }

    &:hover {
      color: #fff;
      border-color: rgba(79, 195, 247, 0.4);
    }
  }
}

.track-query-ship-info {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  justify-content: flex-start;

  .ship-info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    font-size: 10px;
    min-width: 80px;
    max-width: 90px;
    flex: 0 0 auto;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 2px solid transparent;

    &:hover {
      background: rgba(255, 255, 255, 0.15);
    }

    // 활성 상태 (현재 시간에 선박 아이콘이 표시됨)
    &.active {
      background: rgba(79, 195, 247, 0.25);
      border-color: rgba(79, 195, 247, 0.6);
      box-shadow: 0 0 8px rgba(79, 195, 247, 0.4);

      .ship-name {
        color: #4fc3f7;
      }
    }

    // 비활성화 상태 (사용자가 OFF한 경우)
    &.disabled {
      opacity: 0.4;
      background: rgba(100, 100, 100, 0.2);

      &:hover {
        opacity: 0.6;
      }
    }

    // 하이라이트 상태 (호버 연동)
    &.highlighted {
      background: rgba(255, 255, 0, 0.3);
      border-color: rgba(255, 255, 0, 0.8);
      box-shadow: 0 0 12px rgba(255, 255, 0, 0.5);
      transform: scale(1.05);
      z-index: 1;

      .ship-name {
        color: #ffeb3b;
      }
    }

    .ship-name {
      font-weight: 600;
      color: #fff;
      max-width: 100%;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      text-align: center;
    }

    .ship-kind {
      padding: 1px 4px;
      background: rgba(79, 195, 247, 0.3);
      border-radius: 3px;
      color: #4fc3f7;
      font-size: 9px;
    }

    .ship-signal {
      display: none;
    }

    .ship-speed {
      color: #81c784;
      font-weight: 500;
      font-size: 9px;
    }

    .ship-status {
      font-size: 8px;
      color: rgba(255, 255, 255, 0.5);
      margin-top: 2px;
    }
  }
}

.track-query-tooltip {
  position: fixed;
  z-index: 1000;
  background: rgba(30, 35, 60, 0.95);
  border: 1px solid rgba(79, 195, 247, 0.5);
  border-radius: 6px;
  padding: 8px 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  font-size: 12px;
  min-width: 180px;

  .tooltip-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 0;

    .label {
      color: rgba(255, 255, 255, 0.6);
      margin-right: 12px;
    }

    .value {
      color: #fff;
      font-weight: 500;
    }
  }
}

// 모달 모드: 로딩/에러 상태
.track-query-status {
  text-align: center;
  padding: 16px 0;

  .status-loading {
    font-size: 13px;
    color: #4fc3f7;
  }

  .status-error {
    font-size: 13px;
    color: #ef5350;
  }
}

// 선박 모달 모드: 시간 입력 폼
.track-query-time-form {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);

  .time-form-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;

    > label {
      font-size: 11px;
      color: rgba(255, 255, 255, 0.8);
      white-space: nowrap;
    }

    .time-inputs {
      display: flex;
      align-items: center;
      gap: 4px;
      flex: 1;
      min-width: 0;

      input[type='datetime-local'] {
        flex: 1;
        min-width: 0;
        padding: 2px 6px;
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 4px;
        background: rgba(255, 255, 255, 0.1);
        color: #fff;
        font-size: 11px;
        line-height: 1.2;
        height: 26px;
        outline: none;
        transition: border-color 0.2s ease;

        &:focus {
          border-color: #4fc3f7;
        }

        &::-webkit-calendar-picker-indicator {
          filter: invert(1);
          cursor: pointer;
        }
      }

      .time-separator {
        color: rgba(255, 255, 255, 0.6);
        font-size: 12px;
        flex-shrink: 0;
      }
    }

    .query-btn {
      padding: 2px 12px;
      height: 26px;
      border: none;
      border-radius: 4px;
      background: linear-gradient(135deg, #4fc3f7, #29b6f6);
      color: #fff;
      font-size: 11px;
      font-weight: 500;
      cursor: pointer;
      white-space: nowrap;
      flex-shrink: 0;
      transition: all 0.2s ease;

      &:hover:not(:disabled) {
        background: linear-gradient(135deg, #29b6f6, #03a9f4);
        transform: translateY(-1px);
      }

      &:disabled {
        background: rgba(128, 128, 128, 0.5);
        cursor: not-allowed;
      }
    }
  }
}

// 장비별 항적 필터 (통합선박 modalMode 전용) - 한 줄 배치
.track-query-equipment-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);

  .filter-title {
    font-size: 11px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
  }

  .filter-actions {
    display: flex;
    gap: 4px;

    .filter-action-btn {
      padding: 2px 6px;
      border: 1px solid rgba(255, 255, 255, 0.25);
      border-radius: 3px;
      background: transparent;
      color: rgba(255, 255, 255, 0.6);
      font-size: 10px;
      cursor: pointer;
      transition: all 0.15s ease;

      &:hover {
        background: rgba(255, 255, 255, 0.1);
        border-color: rgba(255, 255, 255, 0.4);
        color: #fff;
      }
    }
  }

  .equipment-filter-list {
    display: flex;
    gap: 4px;

    .equipment-toggle {
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0;
      border: 2px solid transparent;
      border-radius: 4px;
      background: transparent;
      cursor: pointer;
      transition: all 0.15s ease;

      &.enabled {
        .equipment-badge {
          opacity: 1;
        }
      }

      &.disabled {
        .equipment-badge {
          opacity: 0.4;
        }
      }

      &:hover {
        transform: scale(1.1);

        .equipment-badge {
          opacity: 1;
        }
      }

      .equipment-badge {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 22px;
        height: 22px;
        border-radius: 4px;
        font-size: 11px;
        font-weight: 600;
        color: #fff;
        transition: all 0.15s ease;
      }
    }
  }
}
