/**
 * 統計データモーダル専用スタイル
 * ミニマルデザイン: 装飾排除、レイアウト・スペーシング・フォントサイズ・UI feedbackを重視
 */

/* ========== 統計データ新規作成モーダル（ミニマル版） ========== */
#statDataCreateModal {
  border: none;
  border-radius: 8px;
  padding: 0;
  max-width: 800px;
  width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  border: 1px solid #e0e0e0;
}

#statDataCreateModal::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

.stat-create-container {
  background: white;
  border-radius: 8px;
  overflow: hidden;
}

.stat-create-header {
  background: #f8f9fa;
  color: #333;
  padding: 1.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  border-bottom: 1px solid #e0e0e0;
}

.stat-create-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: #333;
  letter-spacing: 0.01em;
}

.stat-create-badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.stat-create-badges .badge {
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  background: #e9ecef;
  border: 1px solid #dee2e6;
  color: #495057;
}

.stat-create-badges .badge.primary {
  background: #007bff;
  border-color: #007bff;
  color: white;
}

#statDataCreateModal .stat-data-form {
  background: white;
  padding: 2rem;
  margin: 0;
}

/* ========== 統計データ検索・選択モーダル ========== */
#statDataSearchModal {
  border: none;
  border-radius: 8px;
  padding: 0;
  max-width: 1000px;
  width: 95vw;
  max-height: 90vh;
  overflow: hidden;
  border: 1px solid #e0e0e0;
}

#statDataSearchModal::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

.stat-search-container {
  background: white;
  border-radius: 8px;
  overflow: hidden;
}

.stat-search-header {
  background: #f8f9fa;
  color: #333;
  padding: 1.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  border-bottom: 1px solid #e0e0e0;
}

.stat-search-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: #333;
  letter-spacing: 0.01em;
}

.stat-search-badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.stat-search-badges .badge {
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  background: #e9ecef;
  border: 1px solid #dee2e6;
  color: #495057;
}

.stat-search-badges .badge.primary {
  background: #007bff;
  border-color: #007bff;
  color: white;
}

.stat-search-badges .badge.secondary {
  background: #6c757d;
  border-color: #6c757d;
  color: white;
}

/* ========== 検索フィルター ========== */
#statDataSearchModal .search-filters {
  background: white;
  padding: 1.5rem 2rem;
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  align-items: flex-end;
  border-bottom: 1px solid #e0e0e0;
}

#statDataSearchModal .filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 150px;
}

#statDataSearchModal .filter-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #495057;
}

#statDataSearchModal .search-input,
#statDataSearchModal .search-select {
  padding: 0.75rem;
  border: 1px solid #ced4da;
  border-radius: 4px;
  font-size: 0.875rem;
  background: white;
  width: 100%;
}

#statDataSearchModal .search-input:focus,
#statDataSearchModal .search-select:focus {
  border-color: #007bff;
  outline: none;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

#statDataSearchModal .favorite-filter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 4px;
}

#statDataSearchModal .favorite-filter:hover {
  background: #f8f9fa;
}

#statDataSearchModal .filter-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: #495057;
}

/* ========== データグリッド ========== */
#statDataSearchModal .stat-data-grid {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  background: white;
}

#statDataSearchModal .search-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: #6c757d;
}

#statDataSearchModal .search-loading .loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #007bff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

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

#statDataSearchModal .search-loading p {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
}

/* ========== アクションボタン ========== */
#statDataSearchModal .search-actions {
  background: #f8f9fa;
  padding: 1.5rem 2rem;
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  border-top: 1px solid #e0e0e0;
}

#statDataSearchModal .btn-secondary {
  background: #6c757d;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

#statDataSearchModal .btn-secondary:hover {
  background: #5a6268;
}

#statDataSearchModal .btn-primary {
  background: #007bff;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#statDataSearchModal .btn-primary:hover:not(:disabled) {
  background: #0056b3;
}

#statDataSearchModal .btn-primary:disabled {
  background: #6c757d;
  cursor: not-allowed;
  opacity: 0.6;
}

#statDataSearchModal .btn-icon {
  font-size: 1rem;
}

/* ========== 統計データカード ========== */
.stat-data-card {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.stat-data-card:hover {
  border-color: #007bff;
}

.stat-data-card.selected {
  border-color: #007bff;
  background: #f8f9ff;
}

.stat-data-card h3 {
  margin: 0 0 0.75rem 0;
  color: #333;
  font-size: 1.125rem;
  font-weight: 600;
}

.stat-data-meta {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  color: #6c757d;
  flex-wrap: wrap;
}

.stat-data-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #007bff;
  margin-bottom: 0.75rem;
}

.stat-data-comment {
  background: #f8f9fa;
  padding: 0.75rem;
  border-radius: 4px;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: #495057;
  border-left: 3px solid #007bff;
}

.stat-data-tags {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.tag {
  background: #e9ecef;
  color: #495057;
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  border: 1px solid #dee2e6;
}

.card-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  align-items: center;
}

.btn-small {
  padding: 0.5rem 0.75rem;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  background: white;
  color: #495057;
}

.btn-small:hover {
  background: #f8f9fa;
  border-color: #ced4da;
}

.btn-edit {
  color: #28a745;
  border-color: #28a745;
}

.btn-edit:hover {
  background: #f8fff9;
}

.btn-delete {
  color: #dc3545;
  border-color: #dc3545;
}

.btn-delete:hover {
  background: #fff8f8;
}

.btn-insert {
  color: #17a2b8;
  border-color: #17a2b8;
}

.btn-insert:hover {
  background: #f8fffe;
}

.btn-show-detail {
  color: #6c757d;
  border-color: #6c757d;
}

.btn-show-detail:hover {
  background: #f8f9fa;
}

.favorite-star {
  color: #ffc107;
  cursor: pointer;
  font-size: 1.25rem;
}

.favorite-star:hover {
  color: #e0a800;
}

.usage-count {
  color: #6c757d;
  font-size: 0.75rem;
  background: #f8f9fa;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  border: 1px solid #e9ecef;
}

/* ========== 詳細表示エリア（モードレスUI） ========== */
#detailDisplayArea {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  margin-top: 1rem;
  overflow: hidden;
}

.detail-header {
  background: #f8f9fa;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.detail-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: #333;
}

.btn-close-detail {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #6c757d;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
}

.btn-close-detail:hover {
  background: #e9ecef;
  color: #495057;
}

.detail-content {
  padding: 1.5rem;
}

.detail-item {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #f1f3f4;
}

.detail-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.detail-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
}

.detail-value {
  font-size: 0.875rem;
  color: #333;
  line-height: 1.4;
}

.detail-value.highlight {
  font-weight: 600;
  color: #007bff;
}

.detail-actions {
  background: #f8f9fa;
  padding: 1rem 1.5rem;
  border-top: 1px solid #e0e0e0;
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.detail-actions .btn-small {
  min-width: 80px;
  text-align: center;
}

/* ========== フォーム要素 ========== */
.stat-data-form {
  padding: 2rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-row.full-width {
  grid-template-columns: 1fr;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #495057;
}

.form-group input,
.form-group textarea,
.form-group select {
  padding: 0.75rem;
  border: 1px solid #ced4da;
  border-radius: 4px;
  font-size: 0.875rem;
  background: white;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: #007bff;
  outline: none;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-actions {
  background: #f8f9fa;
  padding: 1.5rem 2rem;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

/* ========== レスポンシブ対応 ========== */
@media (max-width: 768px) {
  #statDataCreateModal,
  #statDataSearchModal {
    width: 95vw;
    max-height: 95vh;
  }
  
  .stat-create-header,
  .stat-search-header {
    padding: 1rem 1.5rem;
  }
  
  .stat-data-form,
  .stat-data-grid {
    padding: 1.5rem;
  }
  
  .search-filters {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1rem 1.5rem;
  }
  
  .form-row {
    grid-template-columns: 1fr;
  }
  
  .search-actions,
  .form-actions {
    padding: 1rem 1.5rem;
    flex-direction: column;
  }
  
  .btn-secondary,
  .btn-primary {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .stat-create-title,
  .stat-search-title {
    font-size: 1.25rem;
  }
  
  .stat-create-badges,
  .stat-search-badges {
    gap: 0.25rem;
  }
  
  .stat-create-badges .badge,
  .stat-search-badges .badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
  }
  
  .stat-data-card {
    padding: 1rem;
  }
  
  .card-actions {
    flex-direction: column;
    align-items: stretch;
  }
  
  .btn-small {
    text-align: center;
  }
}

/* カード内詳細表示エリア */
.card-detail-area {
  margin-top: 1rem;
  padding: 0;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  border-left: 4px solid #007bff;
  overflow: hidden;
}

/* 詳細ヘッダー */
.card-detail-area .detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: #007bff;
  color: #fff;
  margin: 0;
}

.card-detail-area .detail-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

/* 閉じるボタン */
.card-detail-area .btn-close-detail {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: background-color 0.2s ease;
  line-height: 1;
}

.card-detail-area .btn-close-detail:hover {
  background: rgba(255, 255, 255, 0.2);
}

.card-detail-area .detail-item {
  display: flex;
  margin-bottom: 0.75rem;
  align-items: flex-start;
  padding: 0 1rem;
}

.card-detail-area .detail-item:first-of-type {
  padding-top: 1rem;
}

.card-detail-area .detail-label {
  flex: 0 0 80px;
  font-weight: 600;
  color: #495057;
  font-size: 0.9rem;
}

.card-detail-area .detail-value {
  flex: 1;
  color: #212529;
  line-height: 1.4;
}

.card-detail-area .detail-value.highlight {
  font-weight: 600;
  color: #007bff;
}



.card-detail-area .tag {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  margin: 0.125rem;
  background: #e9ecef;
  color: #495057;
  border-radius: 12px;
  font-size: 0.8rem;
}

/* 既存の詳細表示エリアを非表示 */
#detailDisplayArea {
  display: none !important;
}
