/* 基本スタイル */
body { 
  font-family: Arial, sans-serif; 
  background: #f8f8f8; 
  margin: 0; 
  padding: 20px; 
  font-size: 16px;
}

h2, h3 { 
  text-align: center; 
}

.container { 
  max-width: 1200px; 
  margin: auto; 
  padding: 0 10px;
}

.chart-container { 
  width: 100%; 
  margin: auto; 
  padding: 10px; 
  overflow-x: auto;
}

/* テーブルスタイル */
table { 
  width: 100%; 
  border-collapse: collapse; 
  margin-bottom: 20px; 
}

th, td { 
  border: 1px solid #ccc; 
  padding: 5px; 
  text-align: center; 
}

th { 
  background: #f0f0f0; 
}

/* モバイル用テーブルスクロール */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
}

/* フォーム要素 */
input[type=text], 
input[type=number], 
input[type=month], 
input[type=date] { 
  width: 90%; 
  padding: 8px; 
  border-radius: 4px;
  border: 1px solid #ccc;
  font-size: 14px;
}

select { 
  width: 95%; 
  padding: 8px; 
  border-radius: 4px;
  border: 1px solid #ccc;
  font-size: 14px;
}

textarea { 
  width: 100%; 
  height: 150px; 
  border-radius: 4px;
  border: 1px solid #ccc;
  padding: 8px;
  font-size: 14px;
}

button { 
  padding: 10px 15px; 
  margin-top: 5px; 
  background-color: #4682B4;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.3s;
}

button:hover {
  background-color: #3a6a8e;
}

.overdue { 
  color: red; 
  font-weight: bold; 
}

/* ガントチャートのスタイル - 最終調整版 */
.gantt-visual-container {
  width: 100%;
  overflow-x: auto;
  margin-bottom: 20px;
  border: 1px solid #ddd;
  padding: 10px;
  background: white;
  -webkit-overflow-scrolling: touch;
}

.gantt-wrapper {
  min-width: 900px;
  position: relative;
}

.edit-button-container {
  text-align: center;
  margin-bottom: 20px;
}

#editGanttButton {
  background-color: #6c757d;
  margin: 0 auto;
}

.gantt-header {
  display: flex;
  border-bottom: 1px solid #ccc;
  margin-bottom: 10px;
  min-width: 900px; /* 最小幅を設定して横スクロール時の表示を保証 */
}

.gantt-task-label {
  width: 200px;
  font-weight: bold;
  padding: 5px;
  text-align: left;
  border-right: 1px solid #ddd;
  position: sticky;
  left: 0;
  background-color: white;
  z-index: 11;
}

.gantt-month-labels {
  display: flex;
  flex-grow: 1;
}

.gantt-month {
  flex: 1;
  text-align: center;
  padding: 5px;
  font-weight: bold;
  border-right: 1px solid #eee;
  min-width: 60px;
}

.gantt-row {
  display: flex;
  margin: 5px 0;
  align-items: center;
  min-width: 900px; /* 最小幅を設定して横スクロール時の表示を保証 */
}

.gantt-task-name {
  width: 200px;
  padding: 5px;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  position: sticky;
  left: 0;
  background-color: white;
  z-index: 9;
  border-right: 1px solid #ddd;
}

.gantt-bars {
  display: flex;
  flex-grow: 1;
  height: 30px;
  position: relative;
}

.gantt-bar {
  position: absolute;
  height: 20px;
  border-radius: 3px;
  top: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  box-shadow: 1px 1px 3px rgba(0,0,0,0.2);
}

.gantt-bar.prep {
  background-color: #FFA07A; /* 準備タスク用の色 */
}

.gantt-bar.sales {
  background-color: #4682B4; /* 営業タスク用の色 */
}

.gantt-bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 5px;
}

/* ローディングオーバーレイのスタイル */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  color: white;
  font-size: 16px;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 5px solid #f3f3f3;
  border-top: 5px solid #3498db;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 10px;
}

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

/* タブUIのスタイル */
.tab-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0;
  justify-content: center;
}

.tab-button {
  padding: 10px 15px;
  background-color: #f0f0f0;
  border: 1px solid #ccc;
  border-radius: 5px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s ease;
  font-size: 14px;
  flex: 1;
  min-width: 100px;
  text-align: center;
}

.tab-button:hover {
  background-color: #e0e0e0;
}

.tab-button.active {
  background-color: #4682B4;
  color: white;
  border-color: #3a6a8e;
}

.tab-content {
  display: none;
  background-color: white;
  border: 1px solid #ddd;
  border-radius: 5px;
  padding: 15px;
  margin-bottom: 20px;
}

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

/* リード管理のスタイル */
.score-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.total-score {
  font-weight: bold;
  font-size: 16px;
}

.score-edit-btn {
  padding: 2px 5px;
  font-size: 12px;
}

.status {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: bold;
  color: white;
}

.status.hot {
  background-color: #dc3545;
}

.status.warm {
  background-color: #ffc107;
  color: #333;
}

.status.cold {
  background-color: #17a2b8;
}

/* モーダルスタイル */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.5);
}

.modal-content {
  background-color: white;
  margin: 10% auto;
  padding: 20px;
  border-radius: 5px;
  max-width: 600px;
  position: relative;
  width: 90%;
}

.modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.score-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 15px;
  margin: 20px 0;
}

.score-item {
  display: flex;
  flex-direction: column;
}

.detail-section {
  margin-bottom: 20px;
  border-bottom: 1px solid #eee;
  padding-bottom: 15px;
}

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

.history-item {
  display: grid;
  grid-template-columns: 100px 100px 1fr;
  gap: 10px;
  margin-bottom: 8px;
  padding: 5px;
  background-color: #f8f8f8;
}

.history-form {
  display: flex;
  gap: 5px;
}

#new-memo {
  flex-grow: 1;
}

/* パイプライン移行ボタン */
.move-to-project-btn {
  background-color: #28a745;
  color: white;
  font-weight: bold;
  border: 1px solid #218838;
  border-radius: 4px;
  padding: 8px 12px;
  transition: all 0.2s ease;
}

.move-to-project-btn:hover {
  background-color: #218838;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* リード管理のスマホ表示改善用スタイル */
.lead-action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
}

.lead-action-buttons button {
  padding: 6px 10px;
  min-width: 60px;
  margin: 0;
  white-space: nowrap;
}

.detail-btn {
  background-color: #17a2b8;
}

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

.sort-btn {
  padding: 2px 5px;
  margin-left: 5px;
  font-size: 12px;
  background-color: #6c757d;
}

/* リードレベル表示 */
.lead-level {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 12px;
  color: white;
  font-weight: bold;
  font-size: 12px;
  text-align: center;
  min-width: 70px;
}

/* タイムプレッシャー表示 */
.time-pressure {
  display: inline-block;
  color: #ff6b6b;
  font-size: 16px;
  margin-left: 5px;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* スコア管理モーダル */
.score-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 10px;
  background-color: #f8f9fa;
  border-radius: 5px;
}

.lead-level-display {
  padding: 5px 10px;
  border-radius: 15px;
  color: white;
  font-weight: bold;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 100px;
}

.level-label {
  font-size: 12px;
  margin-bottom: 2px;
}

.level-name {
  font-size: 16px;
}

.total-score-display {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.score-label {
  font-size: 12px;
  color: #6c757d;
}

.score-value {
  font-size: 24px;
  font-weight: bold;
}

.score-detail {
  margin-bottom: 20px;
}

.score-category {
  margin-bottom: 15px;
}

.category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}

.category-header h4 {
  margin: 0;
  font-size: 14px;
}

.category-score {
  font-weight: bold;
}

.progress-bar {
  height: 10px;
  background-color: #e9ecef;
  border-radius: 5px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.5s ease;
}

.score-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

#score-event-select {
  flex-grow: 2;
}

#score-event-memo {
  flex-grow: 3;
}

.history-list {
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid #dee2e6;
  border-radius: 5px;
  padding: 5px;
}

.history-item {
  display: grid;
  grid-template-columns: 80px 1fr 1fr;
  gap: 10px;
  margin-bottom: 5px;
  padding: 5px;
  background-color: #f8f9fa;
  border-radius: 3px;
}

.history-item.score-event {
  background-color: #e6f7ff;
}

.score-event-name {
  font-weight: bold;
  color: #0056b3;
}

.score-change {
  color: #28a745;
  font-weight: bold;
  margin-left: 5px;
}

.score-category-badge {
  display: inline-block;
  background-color: #6c757d;
  color: white;
  padding: 2px 5px;
  border-radius: 10px;
  font-size: 10px;
  margin-left: 5px;
}

/* レベルアップモーダル */
.level-up-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.level-up-content {
  background-color: white;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 400px;
  text-align: center;
  animation: scaleIn 0.5s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes scaleIn {
  from { transform: scale(0.8); }
  to { transform: scale(1); }
}

.level-up-header {
  border-bottom: 1px solid #dee2e6;
  padding-bottom: 10px;
  margin-bottom: 15px;
}

.level-up-header h3 {
  margin: 0;
  color: #dc3545;
  font-size: 22px;
}

.level-up-body {
  margin-bottom: 20px;
}

.level-up-message {
  font-size: 18px;
  margin-bottom: 10px;
}

.level-up-detail {
  font-size: 16px;
  margin-bottom: 15px;
}

.level-up-detail .highlight {
  font-size: 20px;
  font-weight: bold;
  color: #dc3545;
}

.level-up-points {
  font-size: 24px;
  font-weight: bold;
  color: #28a745;
}

.level-up-footer button {
  padding: 8px 30px;
  background-color: #dc3545;
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 16px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.level-up-footer button:hover {
  background-color: #c82333;
}

/* リード詳細のスコア表示改善 */
.lead-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 10px;
  background-color: #f8f9fa;
  border-radius: 5px;
}

.score-card-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 15px;
}

.score-card {
  border: 1px solid #dee2e6;
  border-radius: 5px;
  overflow: hidden;
}

.score-card-header {
  background-color: #f8f9fa;
  padding: 5px;
  font-weight: bold;
  font-size: 14px;
  text-align: center;
  border-bottom: 1px solid #dee2e6;
}

.score-card-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.mini-progress {
  width: 100%;
  height: 6px;
  background-color: #e9ecef;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 5px;
}

.mini-progress-fill {
  height: 100%;
  transition: width 0.5s ease;
}

.score-card-value {
  font-weight: bold;
  font-size: 16px;
}

.score-action-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}

.score-action-btn {
  background-color: #17a2b8;
  color: white;
  border: none;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
}

.hint-text {
  font-size: 12px;
  color: #6c757d;
  font-style: italic;
}

/* リセットボタンのスタイル */
.reset-btn {
  background-color: #dc3545;
  color: white;
  font-weight: bold;
  padding: 8px 15px;
  border: none;
  border-radius: 4px;
  margin-right: 10px;
}

.reset-btn:hover {
  background-color: #c82333;
}

.mini-reset-btn {
  background-color: #dc3545;
  color: white;
  padding: 2px 5px;
  border: none;
  border-radius: 3px;
  font-size: 10px;
  margin-left: 5px;
  cursor: pointer;
}

.mini-reset-btn:hover {
  background-color: #c82333;
}

.category-score-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* 履歴エリアにクリアボタンを追加 */
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.history-header h4 {
  margin: 0;
}

.clear-history-btn {
  background-color: #6c757d;
  color: white;
  padding: 3px 8px;
  border: none;
  border-radius: 3px;
  font-size: 12px;
  cursor: pointer;
}

.clear-history-btn:hover {
  background-color: #5a6268;
}

/* リセット履歴アイテムのスタイル */
.history-item.reset-event {
  background-color: #ffeff0;
  border-left: 3px solid #dc3545;
}

.score-change.negative {
  color: #dc3545;
}

/* 操作ボタングループのスタイル改善 */
.button-group {
  display: flex;
  gap: 5px;
  justify-content: center;
}

.button-group button {
  padding: 5px 8px;
  font-size: 12px;
}

/* モバイル用スタイル調整 */
@media (max-width: 768px) {
  /* 基本調整 */
  .gantt-bar-label {
    font-size: 10px;
  }
  
  .gantt-task-name {
    width: 150px;
    font-size: 12px;
  }
  
  .gantt-task-label {
    width: 150px;
  }
  
  /* ガントチャート編集ボタンのモバイル最適化 */
  #editGanttButton.mobile-optimized {
    width: 90% !important;
    margin: 10px auto !important;
    padding: 12px 15px !important;
    min-height: 50px !important;
    font-size: 16px !important;
    display: block !important;
  }
  
  /* タブボタンのモバイル最適化 */
  .tab-buttons.mobile-optimized {
    flex-direction: column !important;
    gap: 5px !important;
    width: 90% !important;
    margin: 20px auto !important;
  }
  
  .tab-buttons.mobile-optimized .tab-button {
    flex: none !important;
    padding: 12px 15px !important;
    width: 100% !important;
    min-height: 50px !important;
    font-size: 16px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  
  /* ガントチャート全体をスクロール可能に */
  .gantt-visual-container {
    overflow-x: auto !important;
    max-width: 100% !important;
    padding: 5px !important;
  }
  
  /* KPIチャートのモバイル調整 */
  .chart-container {
    width: 100% !important;
    overflow-x: auto !important;
    padding: 5px !important;
  }
  
  /* スコアカードとモーダルの調整 */
  .score-card-container {
    grid-template-columns: 1fr;
  }
  
  .score-actions {
    flex-direction: column;
  }
  
  .lead-summary {
    flex-direction: column;
    gap: 10px;
  }
  
  .history-item {
    grid-template-columns: 70px 1fr;
    grid-template-rows: auto auto;
  }
  
  .history-item .history-action {
    grid-column: 2;
    grid-row: 1;
  }
  
  .history-item .history-memo {
    grid-column: 1 / span 2;
    grid-row: 2;
  }
  
  /* モーダル改善 */
  .modal-content {
    margin: 5% auto;
    padding: 15px;
    width: 95%;
  }
  
  .score-grid {
    grid-template-columns: 1fr !important;
  }
  
  .history-item {
    grid-template-columns: 80px 80px 1fr !important;
    font-size: 12px;
  }
  
  .history-form {
    flex-direction: column;
    gap: 8px;
  }
  
  .history-form select,
  .history-form input,
  .history-form button {
    width: 100%;
  }
  
  .modal-buttons {
    justify-content: center;
  }
  
  .modal-buttons button {
    width: 100%;
    margin-bottom: 5px;
  }
  
  /* テーブルセルの固定幅設定（横スクロール防止） */
  #leadsTable th:nth-child(1), #leadsTable td:nth-child(1) { /* 企業名 */
    width: 20%;
  }
  #leadsTable th:nth-child(2), #leadsTable td:nth-child(2) { /* 担当者 */
    width: 15%;
  }
  #leadsTable th:nth-child(3), #leadsTable td:nth-child(3) { /* 獲得ソース */
    width: 15%;
  }
  #leadsTable th:nth-child(4), #leadsTable td:nth-child(4) { /* スコア */
    width: 15%;
  }
  #leadsTable th:nth-child(5), #leadsTable td:nth-child(5) { /* ステータス */
    width: 10%;
  }
  #leadsTable th:nth-child(6), #leadsTable td:nth-child(6) { /* 次回アクション */
    width: 15%;
  }
  #leadsTable th:nth-child(7), #leadsTable td:nth-child(7) { /* 操作 */
    width: 10%;
  }
  
  /* リード管理のモバイル対応 */
  #leadsTable th, #leadsTable td {
    padding: 4px 2px;
    font-size: 12px;
  }
  
  .lead-action-buttons {
    flex-direction: column;
    gap: 3px;
  }
  
  .lead-action-buttons button {
    padding: 4px 6px;
    font-size: 11px;
  }
  
  /* ソートボタン */
  .sort-btn {
    display: block;
    margin: 3px auto 0;
    font-size: 10px;
  }
  
  /* スコア表示 */
  .score-display {
    flex-direction: column;
    gap: 3px;
  }
  
  .score-edit-btn {
    font-size: 10px;
    padding: 2px 4px;
  }
  
  /* 詳細表示の改善 */
  .form-group label {
    display: block;
    margin-bottom: 3px;
    font-weight: bold;
  }
  
  .form-group input,
  .form-group textarea,
  .form-group select {
    width: 100%;
    box-sizing: border-box;
  }
  
  /* 固定ヘッダーとスクロールパネル */
  .table-responsive {
    max-height: 70vh;
  }
  
  /* スマホ用テーブル最適化 */
  table.mobile-optimized td,
  table.mobile-optimized th {
    padding: 3px;
    font-size: 12px;
  }
  
  table.mobile-optimized input[type=text],
  table.mobile-optimized input[type=number],
  table.mobile-optimized input[type=month],
  table.mobile-optimized input[type=date],
  table.mobile-optimized select {
    padding: 4px;
    font-size: 12px;
  }
  
  /* ガントチャート編集ボタン */
  #editGanttButton {
    position: sticky;
    bottom: 10px;
    display: block;
    margin: 0 auto;
    z-index: 100;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  }
}