/* 全体的なスタイリング */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: #333;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
}

/* メインコンテナ */
.main-container {
  max-width: 1200px;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  padding: 30px;
  backdrop-filter: blur(10px);
}

/* ヘッダー */
h1 {
  text-align: center;
  color: #2c3e50;
  margin-bottom: 30px;
  font-size: 2.5em;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

h2 {
  color: #34495e;
  margin: 25px 0 15px 0;
  padding-bottom: 10px;
  border-bottom: 3px solid #3498db;
  font-size: 1.5em;
}

h3 {
  color: #2c3e50;
  margin: 20px 0 10px 0;
  font-size: 1.3em;
}

/* セクション */
.section {
  background: white;
  margin: 20px 0;
  padding: 25px;
  border-radius: 10px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  border-left: 5px solid #3498db;
}

/* ボタンスタイル */
.btn {
  background: linear-gradient(45deg, #3498db, #2980b9);
  color: white;
  border: none;
  padding: 12px 25px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
  margin: 5px;
  -webkit-tap-highlight-color: transparent; /* Webkitのタップハイライトを無効化 */
  user-select: none; /* テキスト選択を無効化 */
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

.btn:active {
  transform: translateY(0);
  transform: scale(0.98); /* タップ時の視覚的フィードバック */
}

.btn-success {
  background: linear-gradient(45deg, #27ae60, #2ecc71);
  box-shadow: 0 4px 15px rgba(46, 204, 113, 0.3);
}

.btn-success:hover {
  box-shadow: 0 6px 20px rgba(46, 204, 113, 0.4);
}

.btn-warning {
  background: linear-gradient(45deg, #f39c12, #e67e22);
  box-shadow: 0 4px 15px rgba(243, 156, 18, 0.3);
}

.btn-warning:hover {
  box-shadow: 0 6px 20px rgba(243, 156, 18, 0.4);
}

/* フォームスタイル */
.form-group {
  margin-bottom: 20px;
}

.form-inline {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}

label {
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 5px;
  display: block;
}

input[type="text"] {
  padding: 12px 15px;
  border: 2px solid #ecf0f1;
  border-radius: 8px;
  font-size: 16px;
  transition: all 0.3s ease;
  width: 100%;
  max-width: 300px;
}

input[type="text"]:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 10px rgba(52, 152, 219, 0.2);
}

/* テーブルスタイル */
.table-container {
  overflow-x: auto;
  margin: 20px 0;
  border-radius: 10px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  -webkit-overflow-scrolling: touch; /* iOS での滑らかなスクロール */
}

table {
  width: 100%;
  min-width: 600px; /* テーブルの最小幅を設定 */
  border-collapse: collapse;
  background: white;
  border-radius: 10px;
  overflow: hidden;
}

th {
  background: linear-gradient(45deg, #34495e, #2c3e50);
  color: white;
  padding: 15px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap; /* ヘッダーの改行を防ぐ */
}

td {
  padding: 12px 15px;
  border-bottom: 1px solid #ecf0f1;
  white-space: nowrap; /* セルの改行を防ぐ */
}

tr:hover {
  background-color: #f8f9fa;
}

tr:nth-child(even) {
  background-color: #f1f2f6;
}

/* マップスタイル */
#map {
  width: 100%;
  height: 400px;
  border-radius: 10px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  margin: 15px 0;
}

/* マップコンテナとサイドパネル */
.map-container {
  position: relative;
  width: 100%;
  height: 500px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

#map {
  width: 100%;
  height: 100%;
}

.info-panel {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 280px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 10px;
  padding: 15px;
  box-shadow: 0 5px 20px rgba(0,0,0,0.3);
  backdrop-filter: blur(10px);
  z-index: 1000;
  max-height: 90%;
  overflow-y: auto;
}

.info-panel h4 {
  margin: 0 0 15px 0;
  color: #2c3e50;
  font-size: 16px;
  border-bottom: 2px solid #4CAF50;
  padding-bottom: 5px;
}

.panel-device-info {
  font-size: 13px;
}

.panel-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  align-items: center;
}

.panel-label {
  font-weight: bold;
  color: #555;
  margin-right: 10px;
}

.panel-value {
  color: #333;
  text-align: right;
  flex: 1;
  word-break: break-all;
}

.panel-detail-btn, .panel-maps-btn {
  width: 100%;
  padding: 8px;
  margin: 5px 0;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  font-weight: bold;
  transition: all 0.3s ease;
}

.panel-detail-btn {
  background: linear-gradient(135deg, #3498db, #2980b9);
  color: white;
}

.panel-detail-btn:hover {
  background: linear-gradient(135deg, #2980b9, #1f618d);
}

.panel-maps-btn {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: white;
}

.panel-maps-btn:hover {
  background: linear-gradient(135deg, #c0392b, #a93226);
}

.close-panel-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 25px;
  height: 25px;
  background: #e74c3c;
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s ease;
}

.close-panel-btn:hover {
  background: #c0392b;
}

/* 走行モードセクション */
#drivingModeSection {
  text-align: center;
  padding: 25px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 15px;
  color: white;
  margin: 20px 0;
}

#drivingModeSection p {
  font-size: 1.2em;
  margin-bottom: 20px;
  font-weight: 600;
}

#currentMode {
  background: rgba(255, 255, 255, 0.2);
  padding: 5px 15px;
  border-radius: 20px;
  font-weight: bold;
}

.mode-buttons {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

.mode-btn {
  font-size: 1.2em;
  padding: 15px 30px;
  border-radius: 25px;
  border: 3px solid transparent;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
  min-width: 180px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation; /* タッチ操作の最適化 */
}

.mode-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.mode-btn:active {
  transform: scale(0.95);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* ステータスメッセージ */
#status, #modeStatus, #select_status {
  padding: 10px 15px;
  border-radius: 8px;
  margin: 10px 0;
  font-weight: 600;
  text-align: center;
}

.status-success {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.status-error {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.status-info {
  background-color: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
}

/* カスタムマーカーのスタイル */
.custom-marker {
  background: none !important;
  border: none !important;
}

/* マーカーのホバー効果を無効化 */

.marker-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  pointer-events: auto; /* クリック可能にする */
}

.marker-icon {
  font-size: 24px;
  margin-bottom: 2px;
  filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.3));
  position: relative;
  z-index: 1;
}

.marker-label {
  background: rgba(76, 175, 80, 0.9);
  color: white;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: bold;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  position: relative;
  z-index: 2;
}

/* ポップアップのスタイル */
.popup-content {
  min-width: 250px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.popup-title {
  color: #2c3e50;
  margin-bottom: 12px;
  font-size: 16px;
  border-bottom: 2px solid #4CAF50;
  padding-bottom: 5px;
}

.popup-details {
  margin-bottom: 15px;
}

.detail-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  align-items: center;
}

.detail-label {
  font-weight: bold;
  color: #555;
  margin-right: 10px;
  font-size: 12px;
}

.detail-value {
  color: #333;
  font-size: 12px;
  text-align: right;
  flex: 1;
}

.popup-button {
  width: 100%;
  padding: 8px 12px;
  background: linear-gradient(135deg, #4CAF50, #45a049);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: bold;
  transition: all 0.3s ease;
}

.popup-button:hover {
  background: linear-gradient(135deg, #45a049, #3d8b40);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0,0,0,0.2);
}

/* Leaflet ポップアップの調整 */
.leaflet-popup-content-wrapper {
  border-radius: 10px !important;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3) !important;
}

.leaflet-popup-content {
  margin: 15px !important;
}

.leaflet-popup-tip {
  border-top-color: white !important;
}

/* マーカーホバー効果を無効化 - 完全に削除 */

/* マーカーホバー効果を無効化 - 完全に削除 */

/* レスポンシブデザイン */
@media (max-width: 768px) {
  body {
    padding: 8px;
    font-size: 14px;
  }

  .main-container {
    padding: 15px;
    margin: 0;
    border-radius: 10px;
  }

  h1 {
    font-size: 1.8em;
    margin-bottom: 20px;
  }

  h2 {
    font-size: 1.3em;
    margin: 20px 0 10px 0;
  }

  h3 {
    font-size: 1.1em;
    margin: 15px 0 8px 0;
  }

  .section {
    padding: 15px;
    margin: 15px 0;
  }

  /* フォームの改善 */
  .form-inline {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .form-group {
    margin-bottom: 15px;
  }

  label {
    font-size: 14px;
    margin-bottom: 8px;
  }

  input[type="text"] {
    max-width: 100%;
    width: 100%;
    padding: 15px;
    font-size: 16px; /* iOS Safari のズーム防止 */
    border-radius: 6px;
  }

  /* ボタンの改善 */
  .btn {
    width: 100%;
    max-width: none;
    padding: 15px 20px;
    font-size: 16px;
    margin: 8px 0;
    border-radius: 6px;
  }

  /* テーブルの改善 */
  .table-container {
    margin: 15px 0;
    font-size: 12px;
  }

  table {
    font-size: 12px;
  }

  th, td {
    padding: 8px 6px;
    word-break: break-all;
  }

  th {
    font-size: 11px;
  }

  /* 走行モードセクションの改善 */
  #drivingModeSection {
    padding: 20px 15px;
  }

  #drivingModeSection h2 {
    font-size: 1.4em;
    margin-bottom: 15px;
  }

  #drivingModeSection p {
    font-size: 1em;
    margin-bottom: 15px;
  }

  #currentMode {
    padding: 8px 12px;
    font-size: 14px;
  }

  .mode-buttons {
    flex-direction: column;
    align-items: center;
    gap: 15px;
  }

  .mode-btn {
    width: 100%;
    max-width: 320px;
    font-size: 16px;
    padding: 18px 20px;
    border-radius: 12px;
    min-width: auto;
  }

  /* マップの改善 */
  #map {
    height: 250px;
    margin: 10px 0;
    border-radius: 8px;
  }

  /* ステータスメッセージの改善 */
  #status, #modeStatus, #select_status {
    padding: 12px;
    font-size: 14px;
    margin: 12px 0;
    border-radius: 6px;
  }

  /* キャンバスの改善 */
  canvas {
    max-width: 100%;
    border-radius: 8px;
  }

  /* ツールチップの改善 */
  #tooltip {
    padding: 6px 10px;
    font-size: 11px;
    border-radius: 4px;
  }
}

/* より小さなスマホ画面用 (iPhone SE等) */
@media (max-width: 375px) {
  body {
    padding: 5px;
  }

  .main-container {
    padding: 10px;
  }

  h1 {
    font-size: 1.6em;
    margin-bottom: 15px;
  }

  .section {
    padding: 12px;
    margin: 10px 0;
  }

  .table-container {
    font-size: 10px;
  }

  th, td {
    padding: 6px 4px;
  }

  .mode-btn {
    padding: 16px 15px;
    font-size: 15px;
  }

  #map {
    height: 200px;
  }
}

/* 横向きスマホ用 */
@media (max-width: 768px) and (orientation: landscape) {
  .main-container {
    padding: 10px;
  }

  .mode-buttons {
    flex-direction: row;
    gap: 10px;
  }

  .mode-btn {
    width: 48%;
    max-width: none;
    font-size: 14px;
    padding: 15px 10px;
  }

  #map {
    height: 200px;
  }
}

/* タッチ操作の改善 */
@media (hover: none) and (pointer: coarse) {
  .btn, .mode-btn {
    min-height: 44px; /* Appleのタッチガイドライン */
  }

  .btn:active, .mode-btn:active {
    transform: scale(0.95);
  }

  input[type="text"] {
    min-height: 44px;
  }
}

/* ツールチップのスタイル */
#tooltip {
  position: absolute;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #ccc;
  padding: 8px 12px;
  font-size: 12px;
  display: none;
  pointer-events: none;
  z-index: 10;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: translate(1px, 1px);
}

/* キャンバススタイル */
canvas {
  border: 2px solid #34495e;
  border-radius: 10px;
  width: 100%;
  max-width: 900px;
  height: auto;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* アニメーション */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section {
  animation: fadeIn 0.6s ease-out;
}
