/**
 * 決算書データ分類ツール用CSS - 改訂版
 */

/* コンテナ */
.accounting-tool-container {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  background: #f8fafc;
  border-radius: 8px;
  color: #1f2937;
}

/* ヘッダー */
.accounting-tool-header {
  background: #ffffff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

.accounting-tool-header h2 {
  margin: 0 0 10px 0;
  font-size: 24px;
  font-weight: 700;
  color: #1e3a8a;
}

.accounting-tool-header p {
  margin: 0;
  color: #6b7280;
}

/* ツールバー */
.accounting-tool-toolbar {
  background: #ffffff;
  padding: 15px 20px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.accounting-tool-button {
  padding: 10px 16px;
  border-radius: 6px;
  border: none;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.accounting-tool-button:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.accounting-tool-button:active {
  transform: translateY(1px);
}

.accounting-tool-button.calculate {
  background-color: #2563eb;
  color: white;
}

.accounting-tool-button.export {
  background-color: #10b981;
  color: white;
}

.accounting-tool-button.upload {
  background-color: #6366f1;
  color: white;
}

.accounting-tool-message {
  padding: 8px 16px;
  border-radius: 6px;
  flex-grow: 1;
  text-align: center;
}

.accounting-tool-message.success {
  background-color: #d1fae5;
  color: #065f46;
}

.accounting-tool-message.error {
  background-color: #fee2e2;
  color: #b91c1c;
}

/* タブ */
.accounting-tool-tabs {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
  overflow: hidden;
}

.accounting-tool-tabs ul {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  border-bottom: 1px solid #e5e7eb;
}

.accounting-tool-tabs li {
  margin: 0;
}

.accounting-tool-tabs a {
  display: block;
  padding: 14px 20px;
  color: #6b7280;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
  position: relative;
}

.accounting-tool-tabs a:hover {
  color: #4b5563;
  background-color: #f9fafb;
}

.accounting-tool-tabs a.active {
  color: #2563eb;
  background-color: #f0f9ff;
}

.accounting-tool-tabs a.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background-color: #2563eb;
}

/* コンテンツエリア */
.accounting-tool-content {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
}

/* 左カラム */
.accounting-tool-left-column {
  width: 30% !important;
  min-width: 250px !important;
  max-width: 350px !important; /* 横幅上限を強制 */
  flex-shrink: 0 !important;
  flex-grow: 0 !important;
  overflow-x: hidden !important;  /* 横スクロールを出さない */
  overflow-y: auto !important;    /* 縦スクロールだけ許可 */
  position: sticky !important;
  top: 20px !important;
}


.accounting-tool-left-column h3 {
  margin: 0 0 10px 0;
  font-size: 18px;
  font-weight: 700;
  color: #1e3a8a;
}

.accounting-tool-instruction {
  color: #6b7280;
  font-size: 14px;
  margin-bottom: 20px;
}

.accounting-tool-source {
  display: none;
}

.accounting-tool-source.active {
  display: block;
}

.accounting-tool-source h4 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 15px 0;
  color: #4b5563;
}

/* 左カラムのアイテムリスト */
.accounting-tool-items {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow-x: hidden !important; /* 横スクロールしない */
  word-wrap: break-word !important; 
  word-break: break-word !important; 
  white-space: normal !important; /* 折り返しを許可 */
}


/* スクロールバーのスタイル調整 */
.accounting-tool-items::-webkit-scrollbar {
  width: 8px;
}

.accounting-tool-items::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.accounting-tool-items::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

.accounting-tool-items::-webkit-scrollbar-thumb:hover {
  background: #a1a1a1;
}

/* 左カラムのアイテム */
.accounting-item {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  white-space: normal !important;
  word-break: break-word !important;
  margin-left:15px;	
}

.accounting-item:hover {
  border-color: #d1d5db;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.accounting-item:active {
  cursor: grabbing;
}

/* 未対応項目は黄色の背景 */
.accounting-item.unmatched {
  background-color: #fffbeb;
  border-color: #fbbf24;
}

/* マッピング済み項目は薄い青の背景 */
.accounting-item.mapped {
  background-color: #dbeafe;
  border-color: #3b82f6;
}

/* ドラッグ中の項目のスタイル */
.accounting-item.being-dragged {
  opacity: 0.5;
  border: 1px dashed #3b82f6;
}

.dragging-clone {
  width: 270px !important; /* 固定幅を設定 */
  max-width: 270px !important;
}

.accounting-item-left {
  display: flex;
  flex-direction: column;
}

.accounting-item-content {
  margin:5px;
  margin-left:15px;
  white-space: normal !important;
  word-break: break-word !important;
}
.accounting-item-subcategory {
  color: #6b7280;
  font-size: 12px;
  margin-top: 4px;
}

.accounting-item-value {
  font-weight: 600;
  font-size: 14px;
  margin-right:25px;
  text-align: right;
  color: #1e3a8a;
}

/* 右カラム */
.accounting-tool-right-column {
  flex-grow: 1; /* 残りのスペースを埋める */
  width: 70%;
  background: #ffffff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.accounting-tool-right-column h3 {
  margin: 0 0 15px 0;
  font-size: 18px;
  font-weight: 700;
  color: #1e3a8a;
}

.accounting-tool-target {
  display: none;
}

.accounting-tool-target.active {
  display: block;
}

.accounting-tool-target h4 {
  font-size: 16px;
  font-weight: 600;
  margin: 15px 0;
  color: #4b5563;
}

/* ツリー構造スタイル */
.parent-item-container {
  margin-bottom: 15px;
  border-radius: 6px;
  overflow: hidden;
  transition: all 0.3s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.parent-item-container:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.parent-item-container.is-parent {
  border-left: 3px solid #3b82f6;
}

/* 計算項目のヘッダー */
.parent-item-container.is-calculated .parent-item-header {
  border-left-color: #10b981; /* 計算項目は緑色の境界線 */
}

/* 親項目のヘッダー */
.parent-item-container.is-parent .parent-item-header {
  border-left-color: #3b82f6; /* 親項目は青色の境界線 */
}

.parent-item-header:hover {
  background-color: #f1f5f9;
}

.parent-item-expander {
  margin-right: 12px;
  font-size: 14px;
  color: #6b7280;
  cursor: pointer;
  width: 20px;
  text-align: center;
}

.parent-item-name {
  flex-grow: 1;
  font-weight: 500;
  color: #1e3a8a;
}

.parent-item-value {
  width: 150px;
  position: relative;
}

.value-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  text-align: right;
  transition: all 0.2s ease;
  font-size: 14px;
  font-weight: 500;
  color: #1f2937;
}

.value-input:focus {
  border-color: #3b82f6;
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.value-input.modified-value {
  background-color: #eff6ff;
  border-color: #3b82f6;
}

.value-input.calculated-value {
  background-color: #ecfdf5;
  border-color: #10b981;
}

.value-input[readonly] {
  background-color: #f8fafc;
  cursor: not-allowed;
}

.parent-item-children {
  padding: 10px 15px 10px 35px;
  background-color: #ffffff;
  border-top: 1px dashed #e5e7eb;
  min-height: 10px;
  transition: all 0.3s ease;
  position: relative;
}

.parent-item-children.potential-drop-target {
  background-color: #f8fafc;
}

.parent-item-children.active-drop-target {
  background-color: #dbeafe;
  border: 2px dashed #3b82f6;
  box-shadow: inset 0 0 10px rgba(59, 130, 246, 0.2);
}

.parent-item-children.potential-drop-target:after {
  content: "ここにドロップしてください";
  display: block;
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  text-align: center;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 14px;
  font-style: italic;
  opacity: 0.6;
  pointer-events: none;
}

.parent-item-children.has-children.potential-drop-target:after {
  content: "ここに追加できます";
  opacity: 0.4;
}

.parent-item-children.active-drop-target:after {
  color: #3b82f6;
  opacity: 1;
  font-weight: bold;
}

/* 子アイテムのインデント */
.child-item {
  margin-left: 20px; /* 子アイテムを右にずらす */
  border-left: 2px solid #e5e7eb; /* 左側に線を追加してツリー構造を強調 */
  padding-left: 10px;
  display: flex;
  align-items: center;
  padding: 8px 10px 8px 15px; /* 左側のパディングを増やす */
  margin-bottom: 5px;
  background-color: white;
  border-radius: 4px;
  transition: all 0.2s ease;
}

/* 子アイテムのホバー状態 */
.child-item:hover {
  background-color: #f9fafb;
  border-left-color: #3b82f6; /* ホバー時に線の色を変更 */
}

.child-item-content {
  flex-grow: 1;
  font-size: 14px;
  color: #4b5563;
}

.child-item-value {
  width: 120px;
  text-align: right;
  font-size: 14px;
  font-weight: 500;
  color: #1e3a8a;
}

.remove-child-button {
  margin-left: 10px;
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.remove-child-button:hover {
  background-color: #fee2e2;
}

/* 計算結果 */
.accounting-tool-results {
  margin-top: 25px;
}

.accounting-results-table {
  background-color: #f8fafc;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.accounting-results-table table {
  width: 100%;
  border-collapse: collapse;
}

.accounting-results-table th,
.accounting-results-table td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}

.accounting-results-table th {
  background-color: #f1f5f9;
  font-weight: 600;
  color: #1e40af;
}

.accounting-results-table td.result-value {
  text-align: right;
  font-weight: 500;
  color: #1e3a8a;
}

.accounting-results-table tr:hover {
  background-color: #f1f5f9;
}

.accounting-results-table tr:last-child td {
  border-bottom: none;
}

/* ツリー構造のレベル表示 */
.tree-level-0 {
  margin-left: 0;
}

.tree-level-1 {
  margin-left: 20px;
}

.tree-level-2 {
  margin-left: 40px;
}

/* ハイライト効果 */
.highlight-item {
  border: 2px solid #3b82f6 !important;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3) !important;
}

.highlight-container {
  border: 2px solid #3b82f6 !important;
  box-shadow: 0 0 5px rgba(59, 130, 246, 0.5) !important;
}

/* ヒント表示 */
.operation-hint {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #dbeafe;
  border-left: 4px solid #3b82f6;
  padding: 15px;
  border-radius: 6px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  max-width: 300px;
  z-index: 9999;
}

.operation-hint h4 {
  margin-top: 0;
  color: #1e40af;
}

.operation-hint p {
  margin: 8px 0;
  font-size: 14px;
}

.operation-hint button {
  background: #3b82f6;
  color: white;
  border: none;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 10px;
}

/* インデントされた項目のスタイル */
.indented-item {
  margin-left: 20px;
  position: relative;
}

.indented-item::before {
  content: '';
  position: absolute;
  left: -15px;
  top: 50%;
  width: 10px;
  height: 1px;
  background-color: #d1d5db;
}

/* ネストされた子項目の表示 */
.grandchild-item {
  margin-left: 40px; /* さらに右にずらす */
  border-left: 2px solid #e5e7eb;
}


/* レスポンシブ対応 */
@media (max-width: 768px) {
  .accounting-tool-content {
    flex-direction: column;
  }
  
  .accounting-tool-left-column,
  .accounting-tool-right-column {
    width: 100%;
    margin-bottom: 20px;
  }
  
  .accounting-tool-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .accounting-tool-message {
    order: -1;
    margin-bottom: 10px;
  }
  
  .accounting-tool-button {
    padding: 12px;
  }
  
  .accounting-tool-tabs a {
    padding: 12px;
  }
}


/* マニュアルアコーディオンのスタイル */
.accounting-tool-manual {
  margin-top: 15px;
  background-color: #f8fafc;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.manual-header {
  padding: 12px 15px;
  background-color: #f1f5f9;
  cursor: pointer;
  border-bottom: 1px solid #e5e7eb;
  transition: background-color 0.2s;
}

.manual-header:hover {
  background-color: #e0e7ff;
}

.manual-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #1e40af;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.toggle-icon {
  transition: transform 0.3s;
}

.toggle-icon.rotated {
  transform: rotate(180deg);
}

.manual-content {
  padding: 15px;
  background-color: #ffffff;
}

.manual-section {
  margin-bottom: 20px;
}

.manual-section:last-child {
  margin-bottom: 0;
}

.manual-section h4 {
  margin: 0 0 10px 0;
  font-size: 15px;
  font-weight: 600;
  color: #4b5563;
}

.manual-section ul, 
.manual-section ol {
  margin: 0;
  padding-left: 20px;
}

.manual-section li {
  margin-bottom: 5px;
}

/* 色サンプル */
.color-sample {
  display: inline-block;
  width: 15px;
  height: 15px;
  border-radius: 3px;
  margin-right: 5px;
  vertical-align: middle;
  border: 1px solid #e5e7eb;
}

.blue-sample {
  background-color: #dbeafe;
  border-color: #3b82f6;
}

.yellow-sample {
  background-color: #fffbeb;
  border-color: #fbbf24;
}

.normal-sample {
  background-color: #ffffff;
  border-color: #e5e7eb;
}


/**
 * 左カラム追随スクロール用のCSSスタイル
 * accounting-tool.css に追加するか、addEnhancedStyles 関数内に統合してください
 */

/* 左カラムのスクロール追随スタイル */
.accounting-tool-left-column.sticky {
  position: sticky;
  top: 32px; /* WordPress管理バー分の余白 */
  max-height: calc(100vh - 50px);
  overflow-y: auto;
  transition: top 0.2s ease;
  z-index: 100;
  padding-bottom: 20px;
}

/* スクロールバーのカスタマイズ */
.accounting-tool-left-column.sticky::-webkit-scrollbar {
  width: 8px;
}

.accounting-tool-left-column.sticky::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.accounting-tool-left-column.sticky::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

.accounting-tool-left-column.sticky::-webkit-scrollbar-thumb:hover {
  background: #a1a1a1;
}

/* メインコンテンツのレイアウト調整 */
.accounting-tool-content {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  align-items: flex-start !important;
}

/* 管理バーがない場合（フロントエンド表示時）*/
body:not(.admin-bar) .accounting-tool-left-column.sticky {
  top: 15px;
}

/* モバイル対応 */
@media (max-width: 768px) {
  .accounting-tool-left-column.sticky {
    position: relative;
    top: 0;
    max-height: none;
    overflow-y: visible;
  }
  
  .accounting-tool-content {
    flex-direction: column;
  }
}


/* テキストが長いときに強制改行するための追加 */
.accounting-item-content,
.accounting-item-subcategory,
.child-item-content {
  white-space: normal !important;
  word-break: break-all !important; /* 単語途中でも強制改行 */
  overflow-wrap: break-word !important;
  /* 場合によっては break-word より break-all の方が強制力が高い */
}


/* エクスポートボタン関連のスタイル */
.export-buttons {
  display: flex;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}

#export-html-button,
#export-all-tabs-button {
  background-color: #6366f1;
  color: white;
}

#export-html-button:hover,
#export-all-tabs-button:hover {
  background-color: #4f46e5;
}

/* メッセージ表示領域の強化 */
.accounting-tool-message {
  transition: all 0.3s ease;
  opacity: 1;
  padding: 8px 16px;
  border-radius: 6px;
  text-align: center;
}

.accounting-tool-message:empty {
  opacity: 0;
  padding: 0;
}

/* レスポンシブ対応の強化 */
@media (max-width: 768px) {
  .accounting-tool-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .export-buttons {
    margin-left: 0;
    margin-top: 10px;
    flex-direction: column;
    width: 100%;
  }
  
  .export-buttons button {
    width: 100%;
    margin-bottom: 5px;
  }
  
  .accounting-tool-button {
    width: 100%;
    margin-bottom: 8px;
  }
  
  .accounting-tool-message {
    width: 100%;
    order: -1;
    margin-bottom: 8px;
  }
}

/* タブナビゲーションのスタイル改善 */
.accounting-tool-tabs ul {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  border-bottom: 1px solid #e5e7eb;
  flex-wrap: wrap;
}

.accounting-tool-tabs a {
  display: block;
  padding: 12px 20px;
  color: #6b7280;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
  position: relative;
  white-space: nowrap;
}

.accounting-tool-tabs a:hover {
  color: #4b5563;
  background-color: #f9fafb;
}

.accounting-tool-tabs a.active {
  color: #2563eb;
  background-color: #f0f9ff;
}

.accounting-tool-tabs a.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background-color: #2563eb;
}

/* モバイル向けタブ表示の改善 */
@media (max-width: 576px) {
  .accounting-tool-tabs ul {
    flex-direction: column;
    border-bottom: none;
  }
  
  .accounting-tool-tabs li {
    width: 100%;
    border-bottom: 1px solid #e5e7eb;
  }
  
  .accounting-tool-tabs a {
    width: 100%;
    text-align: center;
    padding: 12px 0;
  }
  
  .accounting-tool-tabs a.active::after {
    height: 100%;
    width: 3px;
    top: 0;
    bottom: 0;
    left: 0;
    right: auto;
  }
}

/* タブ内容の表示制御を強化 */
.accounting-tool-source {
  display: none !important;
}

.accounting-tool-source.active {
  display: block !important;
}

.accounting-tool-target {
  display: none !important;
}

.accounting-tool-target.active {
  display: block !important;
}