/* ジモポート兵庫加盟店マップ スタイル */
/* モバイルファースト設計 */

/* ベースリセット */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ページ全体の余分スクロールを封じる + iOS対応統合 */
html, body {
  width: 100%;
  height: 100vh;
  overflow-x: hidden;
}

@supports (height: 100svh) {
  html, body { height: 100svh; }
}
@supports (height: 100dvh) {
  html, body { height: 100dvh; }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
  color: #333;
  line-height: 1.6;
  background-color: #f8f9fa;
  overflow: hidden;
  position: relative;
}

/* コンテナとマップ領域の統合レイアウト */
#container {
  display: flex;
  flex-direction: column;
  height: inherit;
  width: 100%;
  position: relative;
  overflow: hidden;
}

#map {
  flex: 1;
  width: 100%;
  position: relative;
  z-index: 1;
  background-color: #e5e7eb;
  overflow: hidden;
}

/* フルスクリーン対応 */
:fullscreen #map, 
:-webkit-full-screen #map, 
:-moz-full-screen #map, 
:-ms-fullscreen #map {
  height: 100vh !important;
  min-height: 100vh !important;
}

/* サイドバー統合設定 - モバイル・デスクトップ対応 */
#sidebar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 60vh;
  background-color: #fff;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  border-radius: 16px 16px 0 0;
  z-index: 2000;
  transition: transform 0.3s ease;
  transform: translateY(0);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

/* Safari専用の調整 */
@supports (-webkit-touch-callout: none) {
  #sidebar {
    bottom: 20px;
  }
}

/* サイドバー閉じ状態とトグルハンドル */
#sidebar.collapsed {
  transform: translateY(calc(100% - 50px - env(safe-area-inset-bottom, 0)));
  overflow: hidden;
}

#sidebar-toggle {
  width: 100%;
  height: 50px;
  padding: 12px;
  text-align: center;
  font-size: 14px;
  color: #666;
  background-color: #fff;
  border: none;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  position: relative;
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  touch-action: pan-y;
}

#sidebar-toggle::before {
  content: '';
  display: block;
  width: 40px;
  height: 4px;
  background-color: #ddd;
  border-radius: 2px;
  margin: 0 auto 8px;
}

/* 現在地ボタン - ビューポート外への配置防止 */
#locate-button {
  position: fixed;
  right: clamp(8px, 2vw, 16px);
  background-color: #fff;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  cursor: pointer;
  transition: bottom 0.3s ease;
  max-width: calc(100vw - 16px);
}

#locate-button.closed {
  bottom: calc(120px + env(safe-area-inset-bottom, 0px));
}

#locate-button.open {
  bottom: calc(50vh + 32px + env(safe-area-inset-bottom, 0px));
}

.icon-default, .icon-active, .icon-user-location {
  width: 32px;
  height: 32px;
  transition: all 0.2s ease;
  color: #666;
}

.icon-active {
  color: #3b82f6;
}

/* モバイルエリアフィルター */
.mobile-filter {
  position: absolute;
  top: 16px;
  left: clamp(8px, 2vw, 16px);
  right: clamp(8px, 2vw, 16px);
  z-index: 5;
  transition: opacity 0.2s ease;
  max-width: calc(100vw - 32px);
}

.sidebar-open .mobile-filter {
  opacity: 0;
  pointer-events: none;
}

.mobile-filter-button {
  width: 100%;
  padding: 12px 16px;
  background-color: #fff;
  border: none;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
  cursor: pointer;
}

.mobile-filter-dropdown {
  margin-top: 8px;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.mobile-filter-option {
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
}

.mobile-filter-option:last-child {
  border-bottom: none;
}

.mobile-filter-option.active {
  background-color: #f0f7ff;
  color: #1e40af;
  font-weight: bold;
}

/* エリアフィルターコントロール */
#filter-controls {
  display: flex;
  overflow-x: auto;
  white-space: nowrap;
  padding: 12px 8px;
  gap: 8px;
  border-bottom: 1px solid #eee;
  background-color: #fbfbfb;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: relative;
  z-index: 5;
}

#filter-controls::-webkit-scrollbar {
  display: none;
}

#filter-controls button {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background-color: #fff;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
  color: #666;
  flex-shrink: 0;
}

#filter-controls button.active {
  background-color: #1e40af;
  border-color: #1e40af;
  color: #fff;
  font-weight: 500;
}

/* 店舗リストコンテナ */
#store-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  background-color: #f9fafb;
  touch-action: pan-y;
}

/* 店舗カード */
.store-card {
  background-color: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  margin-bottom: 16px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
  animation: fadeIn 0.3s ease-out;
  animation-fill-mode: both;
}

.store-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.store-card.highlight {
  border: 2px solid #3b82f6;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
  animation: pulse 2s ease-in-out;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(59, 130, 246, 0); }
  100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

.store-image {
  height: 180px;
  width: 100%;
  background-color: #f4f4f4;
  position: relative;
  overflow: hidden;
}

.store-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.store-card:hover .store-image img {
  transform: scale(1.05);
}

.store-info {
  padding: 16px;
}

.store-name {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 6px;
  color: #1f2937;
}

.store-hours, .store-area {
  font-size: 14px;
  color: #6b7280;
  margin-bottom: 4px;
}

.store-benefit {
  margin: 8px 0;
  padding: 8px 12px;
  background-color: #fef3c7;
  border-radius: 6px;
  font-size: 14px;
  color: #92400e;
}

.store-instagram {
  display: inline-flex;
  align-items: center;
  font-size: 14px;
  color: #db2777;
  text-decoration: none;
  margin-top: 8px;
}

.store-instagram:hover {
  text-decoration: underline;
}

.store-instagram i, .store-instagram svg {
  margin-right: 6px;
}

/* プランバッジスタイル統合 */
.plan-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  line-height: 1.8;
  font-weight: 700;
  letter-spacing: .4px;
  margin-bottom: 8px;
  border: 1px solid transparent;
}

.badge-premium {
  color: #7c4600;
  background: linear-gradient(180deg, #fde68a 0%, #f59e0b 100%);
  border-color: #f59e0b;
}

.badge-free {
  color: #374151;
  background: #e5e7eb;
  border-color: #d1d5db;
}

/* 詳細リンクのスタイル */
.store-detail-link {
  display: inline-flex;
  align-items: center;
  color: #2563eb;
  text-decoration: none;
  font-size: 14px;
  margin-top: 8px;
  padding: 6px 12px;
  border: 1px solid #2563eb;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.store-detail-link:hover {
  background-color: #2563eb;
  color: white;
}

.store-detail-link i {
  margin-right: 6px;
  font-size: 12px;
}

/* InfoWindow最適化 - はみ出し防止統合 */
.gm-style .gm-style-iw,
.gm-style .gm-style-iw-c,
.gm-style .gm-style-iw-d {
  overflow-x: hidden !important;
}

.gm-style-iw.gm-style-iw-c {
  padding: 0 !important;
  border-radius: 12px !important;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08) !important;
}

.popup-card {
  padding: 14px 28px 16px 16px;
  border-radius: 12px;
  background: #fff;
  max-width: min(280px, calc(100vw - 32px));
  overflow-x: hidden;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  touch-action: pan-y;
}

.popup-card .store-name,
.popup-card .store-title {
  margin: 4px 0 8px;
  display: block; 
  font-weight: 700;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.popup-card .meta,
.popup-card .hours-chip {
  margin: 0 0 10px;
  font-size: 12px;
  color: #6b7280;
  line-height: 1.6;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Actions Row統合 - Instagram/Google Mapボタン等幅横並び */
.popup-card .actions-row {
  display: flex;
  gap: 8px;
  margin: 0 0 10px;
}

.popup-card .actions-row > a {
  flex: 1 1 0;
  min-width: 0;
}

/* 統合ボタンスタイル - 重複削除・高さ統一 */
.popup-card .actions-btn,
.popup-card .actions-row .insta-btn,
.popup-card .actions-row .gmaps-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  line-height: 1;
  padding: 6px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  color: #111827;
  text-decoration: none;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
  -webkit-user-select: none;
  user-select: none;
}

.popup-card .actions-btn span,
.popup-card .actions-row .insta-btn span,
.popup-card .actions-row .gmaps-btn span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.popup-card .actions-btn i,
.popup-card .actions-row .insta-btn i,
.popup-card .actions-row .gmaps-btn i {
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}

/* ホバー効果統合 */
@media (hover: hover) {
  .popup-card .actions-btn:hover,
  .popup-card .actions-row .insta-btn:hover,
  .popup-card .actions-row .gmaps-btn:hover {
    background: #f9fafb;
    color: #374151;
    text-decoration: none;
  }
}

/* 既存単体Instagramボタン後方互換 */
.popup-card .insta-btn:not(.actions-row .insta-btn) {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 13px;
  color: #111827;
  text-decoration: none;
  background: #fff;
  margin: 0 0 10px;
  max-width: 100%;
  box-sizing: border-box;
}

.popup-card .benefit,
.popup-card .benefit-chip {
  display: block;
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff7ed;
  border: 1px solid #fde68a;
  color: #92400e;
  line-height: 1.6;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
  box-sizing: border-box;
}

/* ポップアップ内プランバッジ */
.popup-card .plan-badge {
  margin-bottom: 6px;
  display: inline-block;
  padding: 3px 8px;
  border-radius: 9999px;
  font-size: 10px;
  line-height: 1.6;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  max-width: 100%;
  box-sizing: border-box;
}

.popup-card .badge-premium {
  color: #7c4600;
  background: linear-gradient(180deg, #fde68a 0%, #f59e0b 100%);
  border-color: #f59e0b;
}

.popup-card .badge-free {
  color: #374151;
  background: #e5e7eb;
  border-color: #d1d5db;
}

/* Google Maps UIスタッキング調整 */
.gm-style .gm-style-cc,
.gm-style .gm-style-cc + div {
  z-index: 1 !important;
}

.gm-style-iw button.gm-ui-hover-effect,
.gm-style-iw + div > button.gm-ui-hover-effect {
  top: 8px !important;
  right: 8px !important;
}

/* タッチ操作最適化 */
.gm-style,
.gm-style div,
.gm-style canvas {
  touch-action: pan-x pan-y !important;
  -webkit-user-select: none;
  user-select: none;
}

/* デスクトップレスポンシブ */
@media (min-width: 769px) {
  #container {
    flex-direction: row;
  }
  
  #sidebar {
    position: static;
    width: 380px;
    height: 100vh;
    border-radius: 0;
    box-shadow: none;
    border-left: 1px solid #e5e7eb;
    transform: none !important;
    bottom: auto;
    z-index: 10;
  }
  
  #sidebar-toggle {
    display: none;
  }
  
  #store-list {
    padding: 0 12px 12px 12px;
  }
  
  #locate-button {
    bottom: 24px !important;
  }
  
  .store-card {
    margin-bottom: 20px;
  }
  
  .mobile-filter {
    display: none;
  }
}

/* エラーメッセージ最適化 */
.error-message {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background-color: #f44336;
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  font-size: 14px;
  z-index: 2000;
  max-width: calc(100vw - 32px);
  text-align: center;
  transition: transform 0.3s ease;
}

.error-message.show {
  transform: translateX(-50%) translateY(0);
}

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

.store-card:nth-child(2) { animation-delay: 0.05s; }
.store-card:nth-child(3) { animation-delay: 0.1s; }
.store-card:nth-child(4) { animation-delay: 0.15s; }
.store-card:nth-child(5) { animation-delay: 0.2s; }

/* アクセシビリティサポート */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ユーティリティ */
.loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.7) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="20" height="20"><circle cx="50" cy="50" r="40" stroke="%232196F3" stroke-width="8" fill="none" stroke-linecap="round" stroke-dasharray="180 100" stroke-dashoffset="0"><animateTransform attributeName="transform" attributeType="XML" type="rotate" from="0 50 50" to="360 50 50" dur="1s" repeatCount="indefinite"/></circle></svg>') center/20px no-repeat;
  border-radius: 50%;
  z-index: 10;
}

.no-stores {
  text-align: center;
  padding: 32px 16px;
  color: #6b7280;
  font-size: 15px;
}