/* ========================================
 * 制御ボタン専用スタイル
 * ======================================== */

/* 制御ボタンコンテナ */
.control-buttons {
  position: fixed;
  top: 20px;
  right: 20px;
  display: none; /* デフォルトでは非表示 */
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Phase 4: .stacked-buttons-container.minimized / #minimizeFloatingBtn 廃止（HISTORY_MASTER_DETAIL_PSEUDO_NAV_UI_PLAN） */

/* 履歴ページでのみ表示 */
body.history-page .control-buttons {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: center;
  margin: 0;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .control-buttons {
    top: 15px;
    right: 15px;
    gap: 12px;
  }
  
  .control-buttons .control-btn {
    width: 48px;
    height: 48px;
    font-size: 12px;
  }
  
  .control-buttons .control-btn .btn-icon {
    font-size: 16px;
  }
  
  .control-buttons .control-btn .btn-text {
    font-size: 9px;
  }
}

@media (max-width: 480px) {
  .control-buttons {
    top: 10px;
    right: 10px;
    gap: 10px;
  }
  
  .control-buttons .control-btn {
    width: 44px;
    height: 44px;
    font-size: 11px;
  }
  
  .control-buttons .control-btn .btn-icon {
    font-size: 14px;
  }
  
  .control-buttons .control-btn .btn-text {
    font-size: 8px;
  }
  
  .control-buttons.minimized {
    transform: scale(0.25);
  }
}

/* タッチデバイス対応 */
@media (hover: none) and (pointer: coarse) {
  .control-buttons .control-btn:hover {
    transform: none;
  }
  
  .control-buttons.minimized .minimize-btn:hover {
    transform: translate(-50%, -50%) scale(1);
  }
}

/* Phase 4: .stacked-buttons-container .control-buttons / .rewrite-control-buttons 系廃止 */

/* 個別の制御ボタン */
.control-btn {
  width: 120px;
  height: 56px;
  border-radius: 16px;
  border: none;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  min-width: 120px;
}

/* 詳細パネル閉じるボタンのスタイル（詳細パネルボタンと統一） */
.control-btn#closeDetailBtn {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

/* 詳細パネル閉じるボタンのホバー状態 */
.control-btn#closeDetailBtn:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  box-shadow: 0 6px 20px rgba(220, 38, 38, 0.5);
  transform: translateY(-2px);
}

/* 詳細パネル閉じるボタンのアクティブ状態 */
.control-btn#closeDetailBtn:active {
  background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%);
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(185, 28, 28, 0.4);
}

/* 詳細パネルボタンの基本スタイル（詳細パネルが閉じられているとき） */
.control-btn#toggleHistoryTableBtn,
.control-btn#toggleHistoryTableBtn[style] {
  background: linear-gradient(135deg, #ffffff 0%, #f3f4f6 100%);
  color: #1f2937;
  border: 2px solid #d1d5db;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}



/* 詳細パネルボタンのテキストとアイコンの色（詳細パネルが閉じられているとき） */
.control-btn#toggleHistoryTableBtn .btn-text,
.control-btn#toggleHistoryTableBtn .btn-icon,
.control-btn#toggleHistoryTableBtn[style] .btn-text,
.control-btn#toggleHistoryTableBtn[style] .btn-icon {
  color: #1f2937;
  font-weight: 700;
}

/* 詳細パネルボタンのホバー状態（詳細パネルが閉じられているとき） */
.control-btn#toggleHistoryTableBtn:hover,
.control-btn#toggleHistoryTableBtn[style]:hover {
  background: linear-gradient(135deg, #f9fafb 0%, #e5e7eb 100%);
  border-color: #9ca3af;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.control-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.control-btn:hover::before {
  left: 100%;
}

.control-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.control-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* ボタンアイコンとテキストのスタイル */
.control-btn .btn-icon {
  font-size: 20px;
  margin-bottom: 2px;
  line-height: 1;
  display: block;
}

.control-btn .btn-text {
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ボタンのツールチップ - 下側に表示 */
.control-btn[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: -40px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  z-index: 1002;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.control-btn[title]:hover::before {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.9);
  z-index: 1002;
}

/* リライト系ボタン */
.rewrite-control-buttons {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: none;
  flex-direction: column;
  gap: 8px;
  z-index: 1001;
}

/* Phase 4: .stacked-buttons-container 廃止（HISTORY_MASTER_DETAIL_PSEUDO_NAV_UI_PLAN） */

/* 履歴ページでのみ表示 */
body.history-page .rewrite-control-buttons {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: center;
  margin: 0;
}

/* 個別のリライトボタン */
.rewrite-btn {
  width: 120px;
  height: 56px;
  border-radius: 16px;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 120px;
  max-width: 120px;
}

.rewrite-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.rewrite-btn:hover::before {
  left: 100%;
}

.rewrite-btn:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25);
}

.rewrite-btn:active {
  transform: translateY(-1px) scale(0.98);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* リライトボタンの種類別スタイル - 統一感のある色分け */
.rewrite-btn.primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.rewrite-btn.secondary {
  background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
  color: #2c3e50;
}

.rewrite-btn.info {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  color: white;
}

.rewrite-btn.warning {
  background: linear-gradient(135deg, #ffa726 0%, #ff7043 100%);
  color: white;
}

/* リライトボタンの無効状態 */
.rewrite-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: scale(0.9);
}

.rewrite-btn.disabled:hover {
  transform: scale(0.9);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* リライトボタンのツールチップ - 下側に表示 */
.rewrite-btn[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: -40px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  z-index: 1002;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.rewrite-btn[title]:hover::before {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.9);
  z-index: 1002;
}

/* ボタンアイコンのスタイル */
.rewrite-btn .btn-icon {
  font-size: 18px;
  margin-bottom: 2px;
  line-height: 1;
}

/* ボタンテキストのスタイル */
.rewrite-btn .btn-text {
  font-size: 10px;
  line-height: 1;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .control-buttons {
    top: 10px;
    right: 10px;
  }
  
  .control-btn {
    width: 100px;
    height: 48px;
    min-width: 100px;
    border-radius: 14px;
  }
  
  .control-btn .btn-icon {
    font-size: 18px;
  }
  
  .control-btn .btn-text {
    font-size: 9px;
  }
  
  .control-btn[title]:hover::after {
    font-size: 11px;
    padding: 6px 10px;
    bottom: -35px;
  }
  
  .rewrite-btn {
    width: 100px;
    height: 48px;
    min-width: 100px;
    border-radius: 12px;
  }
  
  .rewrite-btn .btn-icon {
    font-size: 16px;
  }
  
  .rewrite-btn .btn-text {
    font-size: 9px;
  }
  
  .rewrite-btn[title]:hover::after {
    font-size: 11px;
    padding: 6px 10px;
    bottom: -35px;
  }
}

/* リライト状態表示 */
.rewrite-status {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 20px 30px;
  border-radius: 10px;
  z-index: 1003;
  animation: fadeInOut 0.3s ease-in-out;
}

.status-message {
  font-size: 16px;
  font-weight: 500;
  text-align: center;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* アニメーション */
@keyframes buttonPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.control-btn.pulse {
  animation: buttonPulse 0.6s ease-in-out;
}

/* アクティブ状態の表示 */
.control-btn.active {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  box-shadow: 0 0 20px rgba(79, 172, 254, 0.5);
  animation: buttonPulse 0.6s ease-in-out;
  transform: scale(1.05);
  z-index: 1002;
}

/* 状態変化のトランジション強化 */
.control-btn {
  transition: all 0.2s ease;
}

/* テストテーブル非表示時のボタン状態 */
.control-btn.test-table-hidden {
  background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
  box-shadow: 0 0 15px rgba(250, 112, 154, 0.4);
  transform: scale(0.95);
  filter: brightness(1.1);
}

/* 履歴テーブル非表示時のボタン状態（詳細パネルが閉じられている場合のみ） */
.control-btn.table-hidden:not(.active),
.control-btn.table-hidden[style]:not(.active) {
  background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
  box-shadow: 0 0 15px rgba(168, 237, 234, 0.4);
  transform: scale(0.95);
  filter: brightness(1.1);
}

/* 詳細パネル展開時の詳細パネルボタンの状態 */
body.history-page.detail-open .control-btn#toggleHistoryTableBtn,
body.history-page.detail-open .control-btn#toggleHistoryTableBtn[style] {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
  transform: scale(1.05);
  font-weight: 700;
  border: none;
}

/* 詳細パネル展開時の詳細パネルボタンのテキスト */
body.history-page.detail-open .control-btn#toggleHistoryTableBtn .btn-text,
body.history-page.detail-open .control-btn#toggleHistoryTableBtn[style] .btn-text {
  color: white;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* 詳細パネル展開時の詳細パネルボタンのアイコン */
body.history-page.detail-open .control-btn#toggleHistoryTableBtn .btn-icon,
body.history-page.detail-open .control-btn#toggleHistoryTableBtn[style] .btn-icon {
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* 詳細パネル展開時の詳細パネルボタンのホバー状態 */
body.history-page.detail-open .control-btn#toggleHistoryTableBtn:hover,
body.history-page.detail-open .control-btn#toggleHistoryTableBtn[style]:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  box-shadow: 0 0 25px rgba(220, 38, 38, 0.6);
  transform: scale(1.08);
}

/* 詳細パネル展開時の詳細パネルボタンのアクティブ状態 */
body.history-page.detail-open .control-btn#toggleHistoryTableBtn:active,
body.history-page.detail-open .control-btn#toggleHistoryTableBtn[style]:active {
  background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%);
  transform: scale(1.02);
  box-shadow: 0 0 15px rgba(185, 28, 28, 0.5);
}

/* インラインスタイルを強制的に上書きするための最高優先度セレクタ */
body.history-page.detail-open .control-btn#toggleHistoryTableBtn[style*="background"],
body.history-page.detail-open .control-btn#toggleHistoryTableBtn[style*="color"],
body.history-page.detail-open .control-btn#toggleHistoryTableBtn[style*="transform"] {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
  font-weight: 700;
  border: none;
}

/* インラインスタイルを強制的に上書きするための最高優先度セレクタ（テキストとアイコン） */
body.history-page.detail-open .control-btn#toggleHistoryTableBtn[style*="background"] .btn-text,
body.history-page.detail-open .control-btn#toggleHistoryTableBtn[style*="background"] .btn-icon {
  color: white;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* 詳細パネル展開時の最優先スタイル（table-hiddenクラスがあっても上書き） */
body.history-page.detail-open .control-btn#toggleHistoryTableBtn.table-hidden,
body.history-page.detail-open .control-btn#toggleHistoryTableBtn.table-hidden[style] {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
  transform: scale(1.05);
  font-weight: 700;
  border: none;
  filter: none;
}

/* 詳細パネル展開時の最優先スタイル（テキストとアイコン） */
body.history-page.detail-open .control-btn#toggleHistoryTableBtn.table-hidden .btn-text,
body.history-page.detail-open .control-btn#toggleHistoryTableBtn.table-hidden .btn-icon,
body.history-page.detail-open .control-btn#toggleHistoryTableBtn.table-hidden[style] .btn-text,
body.history-page.detail-open .control-btn#toggleHistoryTableBtn.table-hidden[style] .btn-icon {
  color: white;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}



body.history-page .control-buttons .control-btn.table-hidden:not(.active),
body.history-page .control-buttons .control-btn.table-hidden[style]:not(.active) {
  background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
  box-shadow: 0 0 15px rgba(168, 237, 234, 0.4);
  transform: scale(0.95);
  filter: brightness(1.1);
}

/* 履歴ページ専用統計データ挿入モーダル */
.history-stat-data-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

.history-stat-data-modal .modal-content {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.history-stat-data-modal .modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-stat-data-modal .modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #111827;
}

.history-stat-data-modal .close-btn {
  background: none;
  border: none;
  font-size: 24px;
  color: #6b7280;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s;
}

.history-stat-data-modal .close-btn:hover {
  background: #f3f4f6;
  color: #374151;
}

.history-stat-data-modal .modal-body {
  padding: 20px 24px;
}

.history-stat-data-modal .stat-data-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.history-stat-data-modal .form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-stat-data-modal .form-group label {
  font-size: 14px;
  font-weight: 500;
  color: #374151;
}

.history-stat-data-modal .form-group input,
.history-stat-data-modal .form-group textarea {
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.history-stat-data-modal .form-group input:focus,
.history-stat-data-modal .form-group textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.history-stat-data-modal .form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.history-stat-data-modal .modal-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.history-stat-data-modal .btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.history-stat-data-modal .btn-secondary {
  background: #f3f4f6;
  color: #374151;
}

.history-stat-data-modal .btn-secondary:hover {
  background: #e5e7eb;
}

/* Phase 4: @media 内 #minimizeFloatingBtn / .stacked-buttons-container.minimized 廃止 */

.history-stat-data-modal .btn-primary {
  background: #3b82f6;
  color: white;
}

.history-stat-data-modal .btn-primary:hover {
  background: #2563eb;
}

/* Phase 4: body.history-page .stacked-buttons-container 系は廃止（HISTORY_MASTER_DETAIL_PSEUDO_NAV_UI_PLAN） */

/* 履歴ページ専用モーダルのレスポンシブ対応 */
@media (max-width: 768px) {
  .history-stat-data-modal .modal-content {
    width: 95%;
    margin: 20px;
  }
  
  .history-stat-data-modal .modal-header,
  .history-stat-data-modal .modal-body,
  .history-stat-data-modal .modal-footer {
    padding: 16px 20px;
  }
  
  .control-btn {
    width: 100px;
    height: 48px;
    min-width: 100px;
    border-radius: 14px;
  }
  
  .control-btn .btn-icon {
    font-size: 18px;
  }
  
  .control-btn .btn-text {
    font-size: 9px;
  }
  
  .control-btn[title]:hover::after {
    font-size: 11px;
    padding: 6px 10px;
    bottom: -35px;
  }
  
  .rewrite-btn {
    width: 100px;
    height: 48px;
    min-width: 100px;
    border-radius: 12px;
  }
  
  .rewrite-btn .btn-icon {
    font-size: 16px;
  }
  
  .rewrite-btn .btn-text {
    font-size: 9px;
  }
}
