/* 変数定義 */
:root {
  --main-color: #E8712A;
  --main-color-hover: #D45E1A;
  --main-color-active: #B5490F;
  --main-color-light: #FDDCBC;
  --border-color: #ccc;
  --header-bg: #f2f2f2;
}

/* 全体構成 */
body,
html {
  margin: 0;
  height: 100%;
  font-family: Arial, sans-serif;
  color: #333;
}

/* 地図領域 */
#map {
  width: 100%;
  height: 100%;
}

/* レイヤーコントロール */
#layerControl {
  position: absolute;
  top: 10px;
  left: 10px !important;
  right: auto !important;
  width: 350px;
  max-height: calc(100vh - 40px);
  padding: 10px;
  background-color: #fff;
  font-size: 12px;
  border-radius: 5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  display: flex !important;
  flex-direction: column;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#layerControl.collapsed {
  width: 44px;
  height: 44px;
  padding: 0;
  overflow: hidden;
}

#layerControl select,
#layerControl input[type="text"],
#layerControl button,
#opacitySlider {
  width: 100%;
  margin-bottom: 8px;
  padding: 6px;
  font-size: 12px;
  border: 1px solid var(--border-color);
  border-radius: 3px;
  box-sizing: border-box;
}

/* ステップ説明 */
.step-description {
  font-size: 12px;
  color: #666;
  margin: 0 0 6px 0;
  padding: 0;
}

/* コントロールボタン */
#layerControlButton,
#helpButton {
  display: none !important;
}

#layerControlButton {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 40px;
  height: 40px;
  background-color: var(--main-color);
  color: white;
  font-size: 16px;
  font-weight: bold;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1000;
}

/* モーダル */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
}

.modal-content {
  position: relative;
  top: 50%;
  left: 50%;
  width: 90%;
  height: 90%;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.close-button {
  position: absolute;
  top: 10px;
  right: 20px;
  font-size: 30px;
  color: #333;
  cursor: pointer;
}

/* 地図帰属情報 */
.attribution {
  position: absolute;
  bottom: 5px;
  right: 10px;
  padding: 3px 10px;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 4px;
  pointer-events: none;
  z-index: 1000;
}

/* パネルヘッダー */
.panel-header {
  background: var(--main-color);
  margin: -10px -10px 10px -10px;
  padding: 10px 15px;
  border-radius: 5px 5px 0 0;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  height: 44px;
  box-sizing: border-box;
  flex-shrink: 0;
}

#layerControl.collapsed .panel-header {
  margin: 0;
  border-radius: 5px;
  width: 44px;
  height: 44px;
  padding: 0;
  justify-content: center;
}

.panel-title {
  margin: 0;
  font-size: 16px;
  font-weight: bold;
  color: white;
  transition: opacity 0.3s ease-out;
}

#layerControl.collapsed .panel-title {
  display: none;
}

.panel-description {
  font-size: 13px;
  color: #555;
  margin: 0 0 15px 0;
  padding: 0;
  line-height: 1.5;
}

.detail-link {
  color: var(--main-color);
  text-decoration: none;
  font-weight: normal;
  display: inline;
}

.detail-link:hover {
  text-decoration: underline;
}

.powered-by {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  font-size: 11px;
  color: #666;
  margin: 10px 0 0 0;
}

.logo-link {
  display: flex;
  align-items: center;
  transition: opacity 0.2s;
}

.logo-link:hover {
  opacity: 0.8;
}

.mq-logo {
  height: 16px;
  width: auto;
}

.powered-text {
  white-space: nowrap;
}

.panel-toggle {
  font-size: 18px;
  color: white;
  cursor: pointer;
  user-select: none;
  transition: transform 0.3s;
  font-weight: bold;
}

#layerControl.collapsed .panel-toggle {
  font-size: 22px;
}

.panel-content {
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 1;
  visibility: visible;
  transform: scale(1);
  transform-origin: top left;
}

#layerControl.collapsed .panel-content {
  opacity: 0;
  visibility: hidden;
  position: absolute;
  transform: scale(0);
}

/* 単位セレクタ */
.unit-selectors {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #eee;
}

.unit-selector-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

/* すべて削除ボタン */
#layerControl .delete-all-btn {
  margin-left: auto;
  padding: 2px 6px;
  font-size: 11px;
  color: #d32f2f;
  background: transparent;
  border: 1px solid #d32f2f;
  border-radius: 3px;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
  flex-shrink: 0;
  width: auto;
  margin-bottom: 0;
}

#layerControl .delete-all-btn:hover:not(:disabled) {
  background: #d32f2f;
  color: white;
}

#layerControl .delete-all-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  border-color: #ccc;
  color: #999;
}

/* アイコンボタン */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 28px;
  width: 28px;
  min-width: 28px;
  max-width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: 3px;
  background: #f5f5f5;
  cursor: pointer;
  color: #666;
  transition: background-color 0.2s, color 0.2s;
}

.icon-btn:hover {
  background: #e0e0e0;
  color: #e53935;
}

.icon-btn .material-icons {
  font-size: 18px;
}

/* ========================================
   サークルパネルリスト
   ======================================== */

/* パネルリストコンテナ */
.measurement-panel-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0;
  max-height: 300px;
  overflow-y: auto;
}

/* サークルパネル */
.measurement-panel {
  display: flex;
  flex-shrink: 0;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  overflow: hidden;
}

.measurement-panel:hover {
  border-color: #999;
}

/* アクティブパネル */
.measurement-panel.active {
  border-width: 2px;
  border-color: var(--main-color);
  box-shadow: 0 2px 4px rgba(232, 113, 42, 0.2);
}

/* 色インジケータ（パネル左端の縦バー） */
.color-indicator {
  width: 6px;
  flex-shrink: 0;
}

/* パネルボディ */
.panel-body {
  flex: 1;
  padding: 8px 10px;
  min-width: 0;
}

/* パネルヘッダー行（アイコン + タイトル + ボタン） */
.panel-header-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

/* カラーピッカー */
.color-picker-trigger {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.2);
  cursor: pointer;
  flex-shrink: 0;
}

.color-picker-trigger:hover {
  border-color: rgba(0, 0, 0, 0.5);
}

.color-picker-popup {
  display: none;
  position: absolute;
  z-index: 10;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  gap: 4px;
  flex-wrap: wrap;
  width: 116px;
}

.color-picker-popup.open {
  display: flex;
}

.color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
}

.color-swatch:hover {
  border-color: rgba(0, 0, 0, 0.4);
}

.color-swatch.selected {
  border-color: #333;
}

/* パネルタイトル */
.measurement-panel .panel-title {
  font-size: 13px;
  font-weight: bold;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* パネル計測結果行 */
.panel-result-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* パネル計測結果 */
.panel-result {
  flex: 1;
  font-size: 18px;
  font-weight: bold;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* パネル内ボタン共通 */
.panel-btn {
  padding: 3px 6px;
  font-size: 11px;
  border: 1px solid var(--border-color);
  border-radius: 3px;
  background: #f5f5f5;
  cursor: pointer;
  transition: background-color 0.2s;
}

.panel-btn:hover:not(:disabled) {
  background: #e0e0e0;
}

.panel-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* パネル内アイコンボタン */
.panel-btn.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 !important;
  padding: 0 !important;
  width: 24px;
  height: 24px;
  border: none !important;
  background: transparent !important;
  color: #888;
}

.panel-btn.icon-btn .material-icons {
  font-size: 16px;
}

.panel-btn.icon-btn:hover:not(:disabled) {
  background: transparent;
  color: #e53935;
}

/* 新規サークルボタンコンテナ */
.add-measurement-btns {
  display: flex;
  gap: 8px;
}

/* 新規サークルボタン */
.add-measurement-btn {
  flex: 1;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--main-color);
  background: #fff;
  border: 1px dashed var(--main-color);
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.add-measurement-btn:hover {
  background: var(--main-color-light);
  color: var(--main-color-active);
}

/* ========================================
   半径入力
   ======================================== */

.radius-input-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}

.radius-input {
  flex: 1;
  min-width: 0;
  width: auto;
  padding: 3px 6px;
  font-size: 12px;
  line-height: 1.2;
  border: 1px solid var(--border-color);
  border-radius: 3px;
  box-sizing: border-box;
  margin-bottom: 0;
}

.radius-unit {
  font-size: 12px;
  color: #666;
}

#layerControl .radius-set-btn {
  width: auto;
  flex-shrink: 0;
  padding: 3px 6px;
  font-size: 12px;
  line-height: 1.2;
  color: white;
  background: var(--main-color);
  border: 1px solid var(--main-color);
  border-radius: 3px;
  cursor: pointer;
  transition: background-color 0.2s;
  box-sizing: border-box;
  margin-bottom: 0;
}

.radius-set-btn:hover {
  background: var(--main-color-hover);
}

/* ========================================
   円ラベル（HTML マーカー）
   ======================================== */

.circle-label {
  background: rgba(255, 255, 255, 0.95);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: bold;
  color: #333;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
  text-align: center;
}

.circle-label-title {
  font-size: 13px;
  font-weight: bold;
  color: #333;
}

.circle-label-preview {
  opacity: 0.85;
  pointer-events: none;
}

/* ========================================
   ステータスメッセージ
   ======================================== */

.circle-status {
  font-size: 11px;
  color: #999;
  font-style: italic;
  margin-top: 2px;
}

/* ========================================
   画像出力コントロール
   ======================================== */

.export-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

#exportSizeSelector {
  width: 100%;
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: #fff;
}

#exportImageBtn {
  width: 100%;
}

.export-error-message {
  display: none;
  color: #dc3545;
  font-size: 12px;
  margin-top: 6px;
  margin-bottom: 0;
}
