/* リセット */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ログイン画面 */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
}

.login-box {
  background: #fff;
  padding: 40px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 360px;
}

.login-box h2 {
  text-align: center;
  color: #2c3e50;
  margin-bottom: 30px;
  font-size: 1.5rem;
}

.login-field {
  margin-bottom: 20px;
}

.login-field label {
  display: block;
  margin-bottom: 6px;
  color: #555;
  font-size: 0.9rem;
}

.login-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
  transition: border-color 0.15s;
}

.login-field input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.login-error {
  color: #e74c3c;
  font-size: 0.85rem;
  margin-bottom: 15px;
  text-align: center;
}

.login-btn {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
}

:root {
  --sidebar-width: 280px;
  --header-height: 50px;
  --primary-color: #0066cc;
  --primary-hover: #0052a3;
  --bg-color: #f5f5f5;
  --sidebar-bg: #2c3e50;
  --sidebar-text: #ecf0f1;
  --border-color: #ddd;
  --text-color: #333;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Meiryo", sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  height: 100vh;
  overflow: hidden;
}

.container {
  display: flex;
  height: 100vh;
}

/* サイドバー */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: margin-left 0.3s ease, width 0.3s ease;
}

/* サイドバー閉じた状態 */
.sidebar.collapsed {
  margin-left: calc(-1 * var(--sidebar-width));
}

/* サイドバーが閉じている時に表示する開くボタン */
.sidebar-open-btn {
  position: absolute;
  left: 0;
  top: 7px;
  z-index: 100;
  width: 28px;
  height: 36px;
  border: none;
  border-radius: 0 4px 4px 0;
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
}

.sidebar-open-btn:hover {
  background-color: #34495e;
}

.sidebar-open-btn .material-symbols-outlined {
  font-size: 20px;
}

/* サイドバーが閉じている時に開くボタンを表示 */
.container.sidebar-collapsed .sidebar-open-btn {
  display: flex;
}

.sidebar-header {
  padding: 15px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header h1 {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0;
}

.sidebar-header h1 a {
  color: inherit;
  text-decoration: none;
}

.sidebar-header h1 a:hover {
  opacity: 0.8;
}

/* サイドバーヘッダーのアクションボタン群 */
.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* サイドバー閉じるボタン */
.btn-sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  color: var(--sidebar-text);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-sidebar-toggle:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.btn-sidebar-toggle .material-symbols-outlined {
  font-size: 20px;
}

/* 更新ボタン */
.btn-refresh {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  color: var(--sidebar-text);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-refresh:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.btn-refresh:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-refresh.loading .refresh-icon {
  animation: spin 1s linear infinite;
}

.refresh-icon {
  font-size: 1rem;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* 検索ボックス */
.search-box {
  padding: 10px 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 8px 30px 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--sidebar-text);
  font-size: 0.85rem;
}

.search-box input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary-color);
  background-color: rgba(255, 255, 255, 0.15);
}

.search-clear {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 5px;
  line-height: 1;
}

.search-clear:hover {
  color: var(--sidebar-text);
}

/* 検索結果 */
.search-results {
  max-height: 300px;
  overflow-y: auto;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.search-result-item {
  display: flex;
  align-items: center;
  padding: 10px 15px;
  cursor: pointer;
  transition: background-color 0.15s;
}

.search-result-item:hover,
.search-result-item.selected {
  background-color: rgba(255, 255, 255, 0.1);
}

.search-result-item.selected {
  background-color: rgba(255, 255, 255, 0.15);
}

.search-result-icon {
  width: 20px;
  margin-right: 10px;
  text-align: center;
}

.search-result-info {
  flex: 1;
  min-width: 0;
}

.search-result-name {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-path {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-no-results {
  padding: 15px;
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.85rem;
}

.search-loading {
  padding: 15px;
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.85rem;
}

.file-tree {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
}

/* ファイルツリー */
.tree-item {
  cursor: pointer;
  user-select: none;
}

.tree-folder,
.tree-file {
  display: flex;
  align-items: center;
  padding: 8px 15px;
  transition: background-color 0.15s;
}

.tree-folder:hover,
.tree-file:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.tree-file.active,
.tree-folder.active {
  background-color: var(--primary-color);
}

.tree-icon {
  width: 20px;
  margin-right: 8px;
  text-align: center;
  font-size: 18px;
}

.tree-icon.material-symbols-outlined {
  font-size: 18px;
}

.tree-name {
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-children {
  display: none;
}

.tree-children.expanded {
  display: block;
}

.tree-children .tree-folder,
.tree-children .tree-file {
  padding-left: 30px;
}

.tree-children .tree-children .tree-folder,
.tree-children .tree-children .tree-file {
  padding-left: 45px;
}

.tree-children .tree-children .tree-children .tree-folder,
.tree-children .tree-children .tree-children .tree-file {
  padding-left: 60px;
}

.folder-arrow {
  transition: transform 0.2s;
}

.folder-arrow.expanded {
  transform: rotate(90deg);
}

.tree-loading,
.tree-empty {
  padding: 8px 30px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.85rem;
  font-style: italic;
}

/* メインコンテンツ */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.content-header {
  height: var(--header-height);
  background-color: #fff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  transition: padding-left 0.3s ease;
}

/* サイドバーが閉じている時はヘッダーの左側にスペースを確保 */
.container.sidebar-collapsed .content-header {
  padding-left: 40px;
}

.header-download-btn {
  flex-shrink: 0;
  margin-left: 15px;
}

.breadcrumb {
  font-size: 0.9rem;
  color: #666;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.breadcrumb-link {
  color: var(--primary-color);
  text-decoration: none;
  cursor: pointer;
}

.breadcrumb-link:hover {
  text-decoration: underline;
}

.breadcrumb-separator {
  color: #999;
}

.content-body {
  flex: 1;
  overflow: auto;
  background-color: #fff;
}

/* ウェルカム画面 */
.welcome-view {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.welcome-message {
  text-align: center;
  color: #888;
}

.welcome-message h2 {
  font-size: 1.5rem;
  margin-bottom: 10px;
}

/* Markdownビュー */
.markdown-view {
  height: 100%;
  background-color: #fff !important;
}

.markdown-container {
  display: flex;
  height: 100%;
}

.markdown-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

/* 目次サイドバー */
.toc-sidebar {
  width: 250px;
  border-left: 1px solid var(--border-color);
  background-color: #fafbfc;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.toc-header {
  padding: 12px 16px;
  font-weight: 600;
  font-size: 0.9rem;
  color: #1f2328;
  border-bottom: 1px solid var(--border-color);
}

.toc-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.toc-item {
  display: block;
  padding: 6px 16px;
  font-size: 0.85rem;
  color: #656d76;
  text-decoration: none;
  line-height: 1.4;
  border-left: 2px solid transparent;
  transition: all 0.15s;
}

.toc-item:hover {
  color: #1f2328;
  background-color: #f0f0f0;
}

.toc-item.active {
  color: var(--primary-color);
  border-left-color: var(--primary-color);
  background-color: #e8f4fd;
}

/* 見出しレベルに応じたインデント */
.toc-h1 {
  font-weight: 600;
  padding-left: 16px;
}

.toc-h2 {
  padding-left: 24px;
}

.toc-h3 {
  padding-left: 36px;
  font-size: 0.8rem;
}

.toc-h4 {
  padding-left: 48px;
  font-size: 0.75rem;
}

.toc-sidebar.hidden {
  display: none;
}

.markdown-body {
  font-size: 16px;
  line-height: 1.8;
  color-scheme: light !important;
  --color-canvas-default: #fff !important;
  --color-fg-default: #1f2328 !important;
  --color-fg-muted: #656d76 !important;
  --color-canvas-subtle: #f6f8fa !important;
  --color-border-default: #d0d7de !important;
  --color-border-muted: hsla(210, 18%, 87%, 1) !important;
  --color-accent-fg: #0969da !important;
  background-color: #fff !important;
  color: #1f2328 !important;
}

/* ダークモード対策 - Markdownの全子要素にライトモードを強制 */
.markdown-body,
.markdown-body * {
  background-color: inherit;
  color: inherit;
}

.markdown-body pre,
.markdown-body code {
  background-color: #f6f8fa !important;
  color: #1f2328 !important;
}

.markdown-body a {
  color: #0969da !important;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  color: #1f2328 !important;
  border-color: #d0d7de !important;
}

.markdown-body table {
  width: 100% !important;
  table-layout: auto;
}

.markdown-body table th,
.markdown-body table td {
  background-color: #fff !important;
  border-color: #d0d7de !important;
  color: #1f2328 !important;
}

.markdown-body table tr:nth-child(2n) {
  background-color: #f6f8fa !important;
}

.markdown-body blockquote {
  color: #656d76 !important;
  border-left-color: #d0d7de !important;
}

/* Mermaid図 */
.markdown-body .mermaid-diagram {
  display: flex;
  justify-content: center;
  margin: 16px 0;
  padding: 16px;
  background-color: #f6f8fa;
  border-radius: 6px;
  overflow-x: auto;
}

.markdown-body .mermaid-diagram svg {
  max-width: 100%;
  height: auto;
}

/* Mermaidエラー時のスタイル */
.markdown-body pre.mermaid-error {
  border-left: 3px solid #f59e0b;
  background-color: #fffbeb !important;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Mermaid ER図のスタイル修正 */
.mermaid-diagram .er.entityBox {
  fill: #e8f4fd !important;
  stroke: #0969da !important;
}

.mermaid-diagram .er.entityLabel {
  fill: #1f2328 !important;
}

.mermaid-diagram .er.relationshipLabel {
  fill: #1f2328 !important;
  font-size: 12px !important;
}

.mermaid-diagram .er.relationshipLabelBox {
  fill: #fff !important;
  fill-opacity: 1 !important;
}

.mermaid-diagram .er.relationshipLine {
  stroke: #656d76 !important;
}

.mermaid-diagram .er.attributeBoxEven,
.mermaid-diagram .er.attributeBoxOdd {
  fill: #f6f8fa !important;
  stroke: #d0d7de !important;
}

/* Mermaid ER図のテキスト全般を黒に */
.mermaid-diagram svg[id*="mermaid"] text {
  fill: #1f2328 !important;
}

/* ER図の関連線ラベルの背景を白に（視認性向上） */
.mermaid-diagram svg rect.er.relationshipLabelBox {
  fill: #ffffff !important;
  fill-opacity: 1 !important;
}

/* Mermaidエラー要素を非表示（body直下に生成されるエラー表示） */
/* body > div[id^="dmermaid-"] {
  display: none !important;
} */

/* コードブロックのシンタックスハイライト */
.markdown-body pre {
  background-color: #f6f8fa !important;
  border-radius: 6px;
  padding: 16px;
  overflow-x: auto;
}

.markdown-body pre code {
  background-color: transparent !important;
  padding: 0;
  font-size: 85%;
  line-height: 1.45;
}

.markdown-body code {
  background-color: rgba(175, 184, 193, 0.2) !important;
  padding: 0.2em 0.4em;
  border-radius: 6px;
  font-size: 85%;
}

/* highlight.js スタイル調整 */
.hljs {
  background: transparent !important;
  color: #1f2328 !important;
}

/* Excelビュー */
.excel-view {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.excel-toolbar {
  padding: 10px 20px;
  background-color: #f8f9fa;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 15px;
}

.file-name {
  color: #666;
  font-size: 0.9rem;
}

/* シートタブ */
.excel-sheet-tabs {
  display: flex;
  background-color: #e9ecef;
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  flex-shrink: 0;
}

.excel-sheet-tabs::-webkit-scrollbar {
  height: 4px;
}

.excel-sheet-tabs::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 2px;
}

.sheet-tab {
  padding: 8px 16px;
  background-color: #dee2e6;
  border: none;
  border-right: 1px solid #ced4da;
  cursor: pointer;
  font-size: 0.85rem;
  white-space: nowrap;
  transition: background-color 0.15s;
}

.sheet-tab:hover {
  background-color: #ced4da;
}

.sheet-tab.active {
  background-color: #fff;
  border-bottom: 2px solid var(--primary-color);
  font-weight: 600;
}

#excelContainer {
  flex: 1;
  overflow: hidden;
}

/* 画像ビュー */
.image-view {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 20px;
  background-color: #f0f0f0;
}

.image-view img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* 未対応ビュー */
.unsupported-view {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.unsupported-message {
  text-align: center;
  color: #888;
}

.unsupported-message p {
  margin-bottom: 15px;
}

/* ボタン */
.btn {
  display: inline-block;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.15s;
}

.btn-primary {
  background-color: var(--primary-color);
  color: #fff;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: #6c757d;
  color: #fff;
}

.btn-secondary:hover {
  background-color: #5a6268;
}

/* ユーティリティ */
.hidden {
  display: none !important;
}

/* スクロールバー */
.file-tree::-webkit-scrollbar,
.content-body::-webkit-scrollbar {
  width: 8px;
}

.file-tree::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

.file-tree::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.content-body::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.content-body::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

/* Handsontable調整 */
.handsontable {
  font-size: 13px;
}

/* フォルダビュー */
.folder-view {
  height: 100%;
  padding: 20px;
  overflow: auto;
}

.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 15px;
}

.folder-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 15px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background-color: #fff;
  cursor: pointer;
  transition: all 0.15s;
}

.folder-item:hover {
  background-color: #f0f7ff;
  border-color: var(--primary-color);
  box-shadow: 0 2px 8px rgba(0, 102, 204, 0.15);
}

.folder-item-icon {
  font-size: 48px;
  margin-bottom: 10px;
}

.folder-item-icon.material-symbols-outlined {
  font-size: 48px;
}

.folder-item-name {
  font-size: 0.9rem;
  text-align: center;
  word-break: break-word;
  line-height: 1.3;
  max-width: 100%;
}

.folder-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: #888;
  padding: 40px;
}

/* サービスリンク（ファイルと同じカード形式） */
.service-link-item {
  text-decoration: none;
  color: inherit;
}

.service-link-item:hover {
  background-color: #e8f4fd;
  border-color: var(--primary-color);
}

/* サイドバーのリンク */
.tree-link {
  text-decoration: none;
  color: inherit;
}
