/* 洗練されたクリニックマップ CSS */

:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary-color: #f1f5f9;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
}

/* 強制的に白背景と黒文字を適用 */
.clinic-map-container,
.clinic-map-container * {
  background-color: white !important;
  color: #1e293b !important;
}

.clinic-map-container {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: white !important;
  min-height: 100vh;
  line-height: 1.6;
  color: #1e293b !important;
}

/* ヘッダーセクション */
.map-header {
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%) !important;
  color: white !important;
  padding: 2rem 1rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.map-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 20"><path d="M0,10 Q25,0 50,10 T100,10 V20 H0 Z" fill="rgba(255,255,255,0.1)"/></svg>') repeat-x bottom;
}

.map-header h1 {
  margin: 0 0 0.5rem 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: white !important;
}

.map-header p {
  margin: 0;
  opacity: 0.9;
  font-size: 1rem;
  color: white !important;
}

/* 検索セクション */
.search-section {
  position: sticky;
  top: 0;
  z-index: 100;
  background: white !important;
  padding: 1rem;
  border-bottom: 1px solid #e2e8f0;
  backdrop-filter: blur(10px);
  background-color: rgba(255, 255, 255, 0.95) !important;
  color: #1e293b !important;
}

.search-form {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.search-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 1rem;
  background: white;
  transition: var(--transition);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-btn {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  transition: var(--transition);
  white-space: nowrap;
}

.search-btn:hover {
  background: var(--primary-hover);
}

.search-btn:active {
  transform: scale(0.98);
}

/* フィルターチップ */
.filter-chips {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.filter-chips::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  background: var(--secondary-color);
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
}

.filter-chip:hover {
  background: #e2e8f0;
}

.filter-chip.active {
  background: var(--primary-color);
  color: white;
}

/* タブナビゲーション（モバイル） */
.tab-navigation {
  display: none;
  background: white;
  border-bottom: 1px solid var(--border-color);
}

.tab-nav {
  display: flex;
}

.tab-button {
  flex: 1;
  padding: 1rem;
  background: none;
  border: none;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}

.tab-button.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

/* メインコンテンツ */
.main-content {
  display: block;
  min-height: calc(100vh - 200px);
  width: 100%;
  position: relative;
}

/* 地図セクション */
.map-section {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: white;
}

/* 地図セクション内にリスト要素が表示されないように完全制御 */
.map-section .clinic-card,
.map-section .clinic-item,
.map-section .clinic-list,
.map-section .loading-state,
.map-section .error-message,
.map-section .empty-state {
  display: none !important;
}

/* 詳細パネル以外のクリニック情報は地図セクションで非表示 */
.map-section > .clinic-card,
.map-section > .clinic-item,
.map-container ~ .clinic-card,
.map-container ~ .clinic-item,
.map-detail-panel ~ .clinic-card,
.map-detail-panel ~ .clinic-item {
  display: none !important;
}

/* タブナビゲーション（全デバイス共通） */
.tab-navigation {
  background: white;
  border-bottom: 1px solid var(--border-color);
  display: block;
}

.tab-nav {
  display: flex;
  max-width: 400px;
  margin: 0 auto;
}

.tab-button {
  flex: 1;
  padding: 1rem;
  background: none;
  border: none;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 3px solid transparent;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
}

.tab-button.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
  background: rgba(37, 99, 235, 0.05);
}

.tab-button:hover:not(.active) {
  color: var(--text-primary);
  background: var(--secondary-color);
}

.tab-icon {
  width: 20px;
  height: 20px;
}

/* タブコンテンツ */
.tab-content {
  display: none;
  width: 100%;
  height: 100%;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
}

.clinic-list.tab-content.active {
  display: block;
}

/* 地図エリア */
.map-container {
  position: relative;
  background: var(--secondary-color);
  flex: 1;
  min-height: 400px;
}

/* 地図下の詳細情報エリア */
.map-detail-panel {
  background: white;
  border-top: 1px solid var(--border-color);
  padding: 0;
  max-height: 0;
  overflow: hidden;
  transition: all 0.3s ease;
}

.map-detail-panel.active {
  max-height: 400px;
  padding: 1.5rem;
  border-top: 2px solid var(--primary-color);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--primary-color) var(--secondary-color);
}

.map-detail-panel.active::-webkit-scrollbar {
  width: 6px;
}

.map-detail-panel.active::-webkit-scrollbar-track {
  background: var(--secondary-color);
  border-radius: 3px;
}

.map-detail-panel.active::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 3px;
}

.map-detail-panel.active::-webkit-scrollbar-thumb:hover {
  background: var(--primary-hover);
}

.detail-content {
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease 0.1s;
  background: white;
  width: 100%;
}

.map-detail-panel.active .detail-content {
  opacity: 1;
  transform: translateY(0);
  background: white;
}

.detail-header {
  display: flex;
  justify-content: between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.detail-clinic-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  flex: 1;
}

.close-detail {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: var(--transition);
}

.close-detail:hover {
  color: var(--text-primary);
}

.detail-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.detail-info-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.detail-rating {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.detail-description {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.detail-actions {
  display: flex;
  gap: 0.75rem;
}

.google-map {
  width: 100%;
  height: 100%;
  border-radius: 0;
}

.location-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 48px;
  height: 48px;
  background: white;
  border: none;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: var(--transition);
  z-index: 10;
}

.location-btn:hover {
  background: var(--primary-color);
  color: white;
  transform: scale(1.05);
}

/* クリニックリスト */
.clinic-list {
  background: white;
  overflow-y: auto;
  padding: 1rem;
}

.results-summary {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1rem;
  text-align: center;
}

/* クリニックカード */
.clinic-card {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1rem;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.clinic-card:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.clinic-card.active {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.clinic-name {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
  margin: 0;
}

.clinic-info {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.info-icon {
  width: 16px;
  height: 16px;
  opacity: 0.7;
}

.clinic-rating {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.stars {
  color: #fbbf24;
  font-size: 1rem;
}

.rating-score {
  font-weight: 600;
  color: var(--text-primary);
}

/* 予約ボタン */
.booking-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.booking-btn {
  background: var(--primary-color);
  color: white;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.booking-btn:hover {
  background: var(--primary-hover);
  color: white;
  text-decoration: none;
  transform: translateY(-1px);
}

.booking-btn.secondary {
  background: white;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
}

.booking-btn.secondary:hover {
  background: var(--primary-color);
  color: white;
}

.route-btn {
  background: #059669;
  color: white;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.route-btn:hover {
  background: #047857;
}

/* 情報ウィンドウ */
.info-window {
  max-width: 320px;
  padding: 1.5rem;
  font-family: inherit;
}

.info-window h3 {
  margin: 0 0 1rem 0;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
}

.info-window .clinic-info {
  margin-bottom: 1rem;
}

.info-window .booking-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.info-window .booking-btn,
.info-window .route-btn {
  flex: 1;
  min-width: 120px;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
}

@media (max-width: 768px) {
  .info-window .booking-btn,
  .info-window .route-btn {
    min-width: 100px;
    font-size: 0.8rem;
    padding: 0.5rem;
  }
}

/* ローディング状態 */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--text-secondary);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* エラー・空状態 */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
}

.empty-state h3 {
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.error-message {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  padding: 1rem;
  border-radius: var(--radius-md);
  margin: 1rem;
  text-align: center;
}

/* スマートフォン対応 */
@media (max-width: 768px) {
  .clinic-map-container {
    min-height: 100vh;
  }

  .map-header {
    padding: 1.5rem 1rem;
  }

  .map-header h1 {
    font-size: 1.5rem;
  }

  .search-section {
    position: relative;
    padding: 1rem;
  }

  .search-form {
    flex-direction: column;
    gap: 0.75rem;
  }

  .search-btn {
    width: 100%;
    padding: 1rem;
  }

  .tab-navigation {
    display: block;
  }

  .main-content {
    display: block;
    min-height: calc(100vh - 300px);
  }

  .map-section {
    display: flex;
    flex-direction: column;
    height: auto;
  }

  .tab-content {
    display: none;
  }

  .tab-content.active {
    display: flex;
    flex-direction: column;
  }

  .map-container {
    height: 60vh;
    min-height: 400px;
    flex: none;
  }

  .google-map {
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  .map-detail-panel {
    position: relative;
    flex: none;
  }

  .map-detail-panel.active {
    max-height: 300px;
    padding: 1rem;
  }

  .detail-info {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .detail-actions {
    flex-direction: column;
    gap: 0.5rem;
  }

  .clinic-list {
    padding: 1rem;
    max-height: none;
    height: auto;
    min-height: calc(100vh - 200px);
  }

  .clinic-list.tab-content.active {
    display: block;
  }

  .clinic-card {
    padding: 1rem;
    margin-bottom: 0.75rem;
  }

  .clinic-name {
    font-size: 1rem;
  }

  .clinic-marker-badge {
    width: 32px !important;
    height: 32px !important;
    font-size: 12px !important;
  }

  .booking-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .booking-btn,
  .route-btn {
    flex: 1;
    min-width: 0;
    font-size: 0.875rem;
    padding: 0.75rem 0.5rem;
  }

  .location-btn {
    width: 44px;
    height: 44px;
    top: 0.75rem;
    right: 0.75rem;
  }

  /* フローティングアクションボタン */
  .fab {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    width: 56px;
    height: 56px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    z-index: 1000;
    transition: var(--transition);
  }

  .fab:hover {
    transform: scale(1.1);
  }

  /* モバイル用トースト */
  .mobile-toast {
    position: fixed;
    bottom: 5rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    z-index: 1001;
    animation: toast-slide-up 0.3s ease-out;
  }

  @keyframes toast-slide-up {
    from {
      opacity: 0;
      transform: translate(-50%, 20px);
    }
    to {
      opacity: 1;
      transform: translate(-50%, 0);
    }
  }
}

/* タブレット対応 */
@media (min-width: 769px) and (max-width: 1024px) {
  .main-content {
    grid-template-columns: 1fr 350px;
  }

  .clinic-list {
    padding: 0.75rem;
  }

  .clinic-card {
    padding: 1.25rem;
  }
}

/* デスクトップ大画面対応 */
@media (min-width: 1200px) {
  .main-content {
    grid-template-columns: 1fr 450px;
  }

  .clinic-list {
    padding: 1.5rem;
  }
}

/* ダークモード対応 */
@media (prefers-color-scheme: dark) {
  :root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
  }

  .clinic-map-container {
    background: #0f172a;
  }

  .search-section {
    background-color: rgba(15, 23, 42, 0.95);
    border-bottom-color: var(--border-color);
  }

  .search-input,
  .clinic-card {
    background: #1e293b;
    border-color: var(--border-color);
  }

  .filter-chip {
    background: #334155;
    color: var(--text-secondary);
  }

  .filter-chip:hover {
    background: #475569;
  }
}

/* アクセシビリティ対応 */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* プリント対応 */
@media print {
  .search-section,
  .tab-navigation,
  .location-btn,
  .booking-actions {
    display: none;
  }

  .main-content {
    display: block;
  }

  .clinic-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #000;
  }
}