/* ===========================================
   グリーンインフラ事例検索システム - スタイルシート
   =========================================== */

/* --- CSS変数 --- */
:root {
  --primary: #2d7d46;
  --primary-dark: #1e5e32;
  --primary-light: #4caf6e;
  --primary-bg: #f0f8f2;
  --accent: #5c9e4a;
  --accent2: #7dc15e;
  --text-main: #1a2e1a;
  --text-sub: #4a6050;
  --text-muted: #8fa897;
  --border: #c8dfc2;
  --border-light: #e4f0e0;
  --surface: #ffffff;
  --surface-hover: #f5fbf5;
  --badge-impl: #1e6e38;
  --badge-impl-bg: #d4edda;
  --badge-plan: #7c5e0d;
  --badge-plan-bg: #fff3cd;
  --shadow-sm: 0 1px 4px rgba(45, 125, 70, 0.08);
  --shadow-md: 0 4px 16px rgba(45, 125, 70, 0.12);
  --shadow-lg: 0 8px 32px rgba(45, 125, 70, 0.15);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --header-h: 56px;
  --search-h: auto;
  --transition: 0.2s ease;
}

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

html, body {
  height: 100%;
}

body {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 14px;
  color: var(--text-main);
  background: #f2f7f3;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* --- ヘッダー --- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
  box-shadow: 0 2px 12px rgba(0,0,0,0.18);
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 32px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.header-logo i {
  font-size: 22px;
  color: #a8e6b4;
}

.header-meta {
  color: rgba(255,255,255,0.85);
  font-size: 13px;
}

.header-meta strong {
  color: #fff;
  font-size: 17px;
  margin: 0 2px;
}

/* --- ページラッパー --- */
.page-wrapper {
  margin-top: var(--header-h);
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

/* ===========================================
   検索パネル
   =========================================== */
.search-panel {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  z-index: 500;
  position: relative;
  margin-top: 8px;
}

.search-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  cursor: pointer;
  user-select: none;
}

.search-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
}

.search-panel-title i {
  color: var(--primary-light);
}

.search-panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-panel-count {
  font-size: 13px;
  color: var(--text-sub);
  font-weight: 400;
  margin-left: 8px;
}

.search-panel-count strong {
  color: var(--primary);
  font-size: 16px;
}

.btn-reset-sm {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  font-family: 'Noto Sans JP', sans-serif;
  cursor: pointer;
  background: var(--surface);
  color: var(--text-sub);
  border: 1px solid var(--border);
  transition: all var(--transition);
}

.btn-reset-sm:hover {
  background: #fdf2f2;
  border-color: #d88;
  color: #c44;
}

.toggle-btn {
  background: var(--primary-bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--primary);
  transition: var(--transition);
}

.toggle-btn:hover {
  background: var(--primary);
  color: #fff;
}

.toggle-btn i {
  transition: transform 0.3s ease;
}

.toggle-btn.collapsed i {
  transform: rotate(180deg);
}

/* 検索フォーム本体 */
.search-panel-body {
  padding: 0 24px 16px;
  transition: all 0.3s ease;
  overflow: visible;
}

.search-panel-body.collapsed {
  padding: 0 24px;
  max-height: 0 !important;
  overflow: hidden !important;
}

.search-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.search-field {
  flex: 1;
  min-width: 200px;
}

.field-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field-label i {
  color: var(--primary-light);
  font-size: 11px;
}

/* Tom Select カスタムスタイル */
.select-wrapper .ts-wrapper {
  width: 100%;
}

.ts-wrapper .ts-control {
  border: 1.5px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  background: var(--surface) !important;
  font-size: 13px !important;
  min-height: 36px !important;
  padding: 3px 8px !important;
  font-family: 'Noto Sans JP', sans-serif !important;
  transition: border-color var(--transition), box-shadow var(--transition) !important;
}

.ts-wrapper.focus .ts-control {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(45, 125, 70, 0.12) !important;
  outline: none !important;
}

.ts-wrapper .ts-control.has-items > input {
  placeholder-color: transparent;
}

.ts-wrapper .ts-control.has-items > input::placeholder {
  color: transparent !important;
  opacity: 0 !important;
}

.ts-wrapper .ts-control.has-items > input::-webkit-input-placeholder {
  color: transparent !important;
  opacity: 0 !important;
}

.ts-wrapper .ts-control.has-items > input::-moz-placeholder {
  color: transparent !important;
  opacity: 0 !important;
}

.ts-wrapper .ts-control .item {
  background: var(--primary-bg) !important;
  color: var(--primary-dark) !important;
  border: 1px solid var(--border) !important;
  border-radius: 4px !important;
  font-size: 12px !important;
  padding: 1px 6px !important;
}

.ts-dropdown {
  border: 1.5px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow-md) !important;
  font-size: 13px !important;
  font-family: 'Noto Sans JP', sans-serif !important;
  z-index: 9000 !important;
  max-height: 300px !important;
  overflow-y: auto !important;
}

.ts-dropdown .ts-dropdown-content {
  max-height: 300px !important;
  overflow-y: auto !important;
}

.ts-dropdown .option {
  padding: 8px 12px !important;
  transition: background var(--transition) !important;
}

.ts-dropdown .option:hover,
.ts-dropdown .option.active {
  background: var(--primary-bg) !important;
  color: var(--primary-dark) !important;
}

.ts-dropdown .option.selected {
  background: var(--primary) !important;
  color: #fff !important;
}

/* ラジオボタン */
.radio-group {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 6px 0;
  flex-wrap: wrap;
}

.radio-item {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-main);
}

.radio-item input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* 検索アクション */
.search-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
  flex-wrap: wrap;
  gap: 8px;
}

.result-info {
  font-size: 13px;
  color: var(--text-sub);
}

.result-info strong {
  color: var(--primary);
  font-size: 16px;
}

.action-btns {
  display: flex;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: 'Noto Sans JP', sans-serif;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
}

.btn-reset {
  background: var(--surface);
  color: var(--text-sub);
  border: 1.5px solid var(--border);
}

.btn-reset:hover {
  background: #fdf2f2;
  border-color: #d88;
  color: #c44;
}

.btn-search {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(45, 125, 70, 0.3);
}

.btn-search:hover {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  box-shadow: 0 4px 12px rgba(45, 125, 70, 0.4);
  transform: translateY(-1px);
}

/* ===========================================
   メインコンテンツ
   =========================================== */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
  gap: 0;
}

/* ===== 事例一覧パネル ===== */
.case-list-panel {
  width: 340px;
  min-width: 280px;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 2px solid var(--border);
  flex-shrink: 0;
  z-index: 400;
  position: relative;
}

.case-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  background: var(--primary-bg);
}

.case-list-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  gap: 6px;
}

.case-count-badge {
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 20px;
}

.case-list-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.case-list-scroll::-webkit-scrollbar {
  width: 4px;
}

.case-list-scroll::-webkit-scrollbar-track {
  background: var(--border-light);
}

.case-list-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* 状態表示 */
.loading-state,
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  gap: 12px;
  text-align: center;
}

.loading-state p,
.empty-state p {
  font-size: 13px;
}

.empty-state i {
  font-size: 36px;
  opacity: 0.3;
}

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

@keyframes spin {
  to { transform: rotate(360deg); }
}

.hidden {
  display: none !important;
}

/* 事例リストアイテム */
.case-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.case-item {
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--surface);
  position: relative;
}

.case-item:hover {
  border-color: var(--primary-light);
  background: var(--surface-hover);
  box-shadow: var(--shadow-sm);
  transform: translateX(2px);
}

.case-item.active {
  border-color: #e67e22;
  background: #fef5ec;
  box-shadow: 0 2px 8px rgba(230, 126, 34, 0.2);
}

.case-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #e67e22;
  border-radius: 3px 0 0 3px;
}

.case-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.case-item-no {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  background: var(--border-light);
  padding: 1px 6px;
  border-radius: 3px;
  white-space: nowrap;
  margin-top: 2px;
}

.case-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  flex: 1;
  line-height: 1.4;
}

.case-item.active .case-item-name {
  color: #d35400;
}

.status-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.status-badge.impl {
  background: var(--badge-impl-bg);
  color: var(--badge-impl);
}

.status-badge.plan {
  background: var(--badge-plan-bg);
  color: var(--badge-plan);
}

.case-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.meta-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--text-sub);
  background: var(--border-light);
  padding: 2px 7px;
  border-radius: 3px;
}

.meta-tag i {
  font-size: 9px;
  color: var(--primary-light);
}

/* ===== 地図パネル ===== */
.map-panel {
  flex: 1;
  position: relative;
  background: #f2f7f3;
  z-index: 1;
}

.map-panel #map {
  width: 100%;
  height: 100%;
}

/* ===== 場所未特定事例パネル ===== */
.no-location-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 320px;
  max-height: 300px;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  z-index: 450;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.no-location-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #fff8f0;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  user-select: none;
}

.no-location-title {
  font-size: 12px;
  font-weight: 600;
  color: #b45309;
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.no-location-title i {
  color: #d97706;
}

.no-location-badge {
  background: #d97706;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
}

.no-location-toggle-btn {
  background: none;
  border: none;
  color: #b45309;
  cursor: pointer;
  font-size: 12px;
  padding: 2px;
  transition: transform 0.3s ease;
}

.no-location-toggle-btn.expanded i {
  transform: rotate(180deg);
}

.no-location-body {
  overflow-y: auto;
  max-height: 50vh;
  padding: 6px;
}

.no-location-body::-webkit-scrollbar {
  width: 4px;
}

.no-location-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.no-location-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.no-location-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  font-size: 12px;
  color: var(--text-main);
  border: 1px solid transparent;
}

.no-location-item:hover {
  background: #fff8f0;
  border-color: #fde68a;
}

.no-location-item .no-loc-no {
  font-size: 10px;
  font-weight: 600;
  color: #b45309;
  background: #fef3c7;
  padding: 1px 6px;
  border-radius: 3px;
  white-space: nowrap;
}

.no-location-item .no-loc-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-marker {
  background: none !important;
  border: none !important;
}

/* 詳細表示 */
.case-detail {
  padding: 24px;
  max-width: 900px;
  margin: 0 auto;
}

.detail-header {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
  border-left: 4px solid var(--primary);
  position: relative;
}

.detail-no {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.4;
  margin-bottom: 12px;
}

.detail-status-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 14px;
  border-radius: 6px;
}

/* 詳細カード */
.detail-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

.detail-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1.5px solid var(--border-light);
}

.detail-card-title i {
  color: var(--primary-light);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-item.full-width {
  grid-column: 1 / -1;
}

.detail-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 4px;
}

.detail-label i {
  font-size: 10px;
  color: var(--primary-light);
}

.detail-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
  background: var(--primary-bg);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.detail-description {
  font-size: 14px;
  color: var(--text-main);
  line-height: 1.8;
  padding: 4px 0;
}

/* ===========================================
   モーダル
   =========================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.hidden {
  display: none !important;
}

.modal-content {
  background: #f2f7f3;
  border-radius: var(--radius-lg);
  max-width: 720px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
  box-shadow: var(--shadow-lg);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-sub);
  font-size: 14px;
  transition: all var(--transition);
  z-index: 1;
}

.modal-close:hover {
  background: #fdf2f2;
  border-color: #d88;
  color: #c44;
}

/* PDFリンクボタン */
.detail-pdf-card {
  text-align: center;
}

.btn-pdf {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 32px;
  background: linear-gradient(135deg, #c0392b 0%, #e74c3c 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Noto Sans JP', sans-serif;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(199, 57, 43, 0.3);
  transition: all var(--transition);
}

.btn-pdf:hover {
  background: linear-gradient(135deg, #a93226 0%, #c0392b 100%);
  box-shadow: 0 4px 12px rgba(199, 57, 43, 0.4);
  transform: translateY(-1px);
}

.btn-pdf i {
  font-size: 18px;
}

/* ===========================================
   フッター
   =========================================== */
.site-footer {
  background: var(--primary-dark);
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
  padding: 10px 24px;
  font-size: 12px;
  flex-shrink: 0;
}

/* ===========================================
   レスポンシブ
   =========================================== */
@media (max-width: 900px) {
  .case-list-panel {
    width: 280px;
  }

  .search-row {
    flex-direction: column;
  }

  .search-field {
    min-width: unset;
  }
}

@media (max-width: 640px) {
  .header-logo span {
    font-size: 14px;
  }

  .main-content {
    flex-direction: column;
  }

  .page-wrapper {
    height: auto;
    min-height: calc(100vh - var(--header-h));
    overflow: visible;
  }

  .main-content {
    overflow: visible;
    flex: none;
  }

  .case-list-panel {
    width: 100%;
    max-width: 100%;
    max-height: 360px;
    border-right: none;
    border-bottom: 2px solid var(--border);
  }

  .map-panel {
    min-height: 70vh;
    height: 70vh;
  }

  .modal-content {
    padding: 16px;
    max-height: 90vh;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .detail-item.full-width {
    grid-column: 1;
  }
}
