:root {
  --primary-color: #4B5563;
  --primary-hover: #374151;
  --start-color: #28a745;
  --start-hover: #218838;
  --stop-color: #dc3545;
  --stop-hover: #c82333;
  --secondary-color: #6c757d;
  --secondary-hover: #5a6268;

  --dark-bg: #1f2937;
  /* ダークグレー */
  --dark-nav: #374151;
  /* やや明るいグレー */
  --light-bg: #f3f4f6;
  /* ページの背景色 */
  --card-bg: #ffffff;
  /* カードの背景色 */
  --text-primary: #111827;
  /* メインテキスト */
  --text-secondary: #6b7281;
  /* サブテキスト（日付など） */
  --border-color: #e5e7eb;
  /* 境界線 */
}

/* 基本的なリセットと設定 */
html {
  box-sizing: border-box;
  font-size: 16px;
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

body {
  font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  margin: 0;
  padding: 0;
  background-color: var(--light-bg);
  color: var(--text-primary);
  line-height: 1.6;
}

/* ヘッダー */
header {
  background-color: var(--dark-bg);
  color: white;
  padding: 1rem 1.5rem;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

header h1 {
  margin: 0;
  font-size: 1.5rem;
}

/* ナビゲーション */
nav {
  background-color: var(--dark-nav);
  display: flex;
  justify-content: center;
  padding: 0;
}

nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
}

nav ul li {
  margin: 0;
}

nav ul li a,
#logoutButton {
  color: white;
  text-decoration: none;
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  font-weight: 500;
  display: inline-block;
  line-height: 1.5;
  background-color: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
}

nav ul li a:hover,
#logoutButton:hover {
  background-color: var(--primary-color);
  color: white;
}

/* メインコンテンツエリア */
.content {
  max-width: 960px;
  margin: 2rem auto;
  padding: 0 1rem;
  /* スマホ用に左右パディング */
}

/* ページタイトル (h1など) */
.page-title {
  font-size: 2rem;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  text-align: center;
  font-weight: 600;
}

/* 汎用カード */
.card {
  background-color: var(--card-bg);
  padding: 1.5rem 2rem;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.07);
  margin-bottom: 2rem;
  text-align: left;
}

/* カード内の見出し (h2) */
.card h2 {
  margin-top: 0;
  margin-bottom: 1rem;
  color: var(--text-primary);
  font-size: 1.75rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

/* お知らせアイテム */
.notice-item {
  padding: 1rem 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.notice-item:last-child {
  border-bottom: none;
}

.notice-item h3 {
  margin: 0 0 0.25rem;
  font-size: 1.125rem;
  color: var(--primary-color);
  cursor: pointer;
  display: inline-block;
  transition: color 0.2s ease;
}

.notice-item h3:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.notice-item p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* 「もっと見る」リンク */
.more-link {
  font-size: 0.875rem;
  color: var(--primary-color);
  text-decoration: none;
  font-weight: bold;
  transition: color 0.2s ease;
}

.more-link:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* 汎用ボタンスタイル */
button,
.button {
  padding: 0.6rem 1.25rem;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  display: inline-block;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
  font-family: inherit;
  /* フォントを継承 */
}

button:hover,
.button:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

/* ボタングループ */
.button-group {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-wrap: wrap;
  /* スマホで折り返す */
  gap: 0.75rem;
  /* ボタン間の隙間 */
  justify-content: center;
  /* ボタンを中央揃え */
}

/* --- ここからボタンのバリエーションを追加 --- */
.btn-start {
  background-color: var(--start-color);
}

.btn-start:hover {
  background-color: var(--start-hover);
}

.btn-stop {
  background-color: var(--stop-color);
}

.btn-stop:hover {
  background-color: var(--stop-hover);
}

.btn-secondary {
  background-color: var(--secondary-color);
}

.btn-secondary:hover {
  background-color: var(--secondary-hover);
}

button:disabled,
.button:disabled {
  background-color: var(--secondary-color);
  opacity: 0.65;
  cursor: not-allowed;
  box-shadow: none;
}


/* テーブルスタイル */
table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.07);
  overflow: hidden;
  text-align: left;
}

table th,
table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}

table th {
  background-color: #f9fafb;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.875rem;
  text-transform: uppercase;
}

table td {
  color: var(--text-primary);
  vertical-align: middle;
}

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

/* フォーム/情報グループ */
.info-group {
  margin-bottom: 1.5rem;
  text-align: left;
}

.info-group label {
  display: block;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

/* 読み取り専用の情報表示 */
.info-text {
  background-color: var(--light-bg);
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 1rem;
  color: var(--text-primary);
  word-wrap: break-word;
}

/* --- ここからローディング画面スタイルを追加 --- */
#loadingOverlay {
  display: none;
  /* JSで制御 */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 9999;
  color: white;
  font-size: 1.25rem;
  /* JSでの制御と競合するため、flex関連のプロパティを削除 */
  text-align: center; /* 元のスタイルを維持 */
}

/* JS側で中央寄せするためにマージンを調整 */
#loadingOverlay .spinner {
  margin: 20px auto;
}

.spinner {
  border: 4px solid transparent;
  border-top: 4px solid white;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* MOD一覧リスト */
.mod-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem 0;
  /* 下マージン追加 */
}

.mod-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  /* 縦方向中央揃え */
  padding: 1rem 0.5rem;
  /* パディング調整 */
  border-bottom: 1px solid var(--border-color);
  word-break: break-all;
  /* 長いファイル名を折り返す */
}

.mod-list li:last-child {
  border-bottom: none;
}

/* MOD一覧内のボタンサイズを小さく調整 */
.mod-list li .button {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  margin-left: 1rem;
  /* テキストとの間に隙間 */
  flex-shrink: 0;
  /* ボタンが縮まないように */
}


/* アップロードフォーム */
.upload-form {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  /* 縦並び */
  align-items: center;
  /* 中央揃え */
  gap: 1rem;
  /* 要素間の隙間 */
}

/* ファイル入力欄のスタイル */
input[type="file"] {
  display: block;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background-color: var(--light-bg);
  width: 100%;
  max-width: 400px;
  /* 最大幅を指定 */
}

/* ファイル入力のブラウザ標準ボタンのスタイル（一部ブラウザのみ） */
input[type="file"]::file-selector-button {
  padding: 0.6rem 1.25rem;
  background-color: var(--secondary-color);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: background-color 0.2s ease;
  margin-right: 1rem;
}

input[type="file"]::file-selector-button:hover {
  background-color: var(--secondary-hover);
}

/* フォーム内の送信ボタン */
.upload-form button[type="submit"] {
  /* .button スタイルが自動で適用されるが、幅を調整 */
  width: 100%;
  max-width: 400px;
}

/* --- ここから フォーム入力用スタイルを追加 --- */

/* 汎用フォームコントロール (input, textarea) */
.form-control,
input[type="text"],
input[type="password"],
input[type="email"],
textarea,
select {
  display: block;
  width: 100%;
  /* 親要素の幅に合わせる */
  max-width: 100%;
  /* box-sizingを考慮 */
  box-sizing: border-box;
  /* パディングを含めて幅100%にする */
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--card-bg);
  /* 白背景 */
  border: 1px solid var(--border-color);
  border-radius: 6px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

/* --- ボタン配置用 --- */
.button-group-right {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  /* 右揃え */
  gap: 0.75rem;
}

/* --- ここから サーバー操作ページの詳細表示用スタイル --- */
.detail-list {
  display: flex;
  flex-wrap: wrap;
  /* スペースがなければ折り返す */
  gap: 1rem;
  /* 各アイテム間の隙間 */
  margin-bottom: 1.5rem;
  /* ボタンとの間にマージン */
}

.detail-item {
  flex: 1 1 auto;
  /* 基本の幅を自動にしつつ、伸縮させる */
  min-width: 200px;
  /* 最小幅 */
  background-color: var(--light-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.75rem 1rem;
}

.detail-item label {
  display: block;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.8rem;
  /* ラベルを小さく */
  margin-bottom: 0.15rem;
  /* 値との隙間を狭く */
  text-transform: uppercase;
  /* 大文字風に */
}

.detail-item p {
  margin: 0;
  font-size: 1.1rem;
  /* 値を少し大きく */
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-all;
}

/* --- ここから server.properties 用スタイルを追加 --- */

/* Alert Messages */
.alert {
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 0.9rem;
  text-align: left;
}

.alert-success {
  color: #0f5132;
  background-color: #d1e7dd;
  border-color: #badbcc;
}

.alert-danger {
  color: #842029;
  background-color: #f8d7da;
  border-color: #f5c2c7;
}

/* Key-Value Form Layout (server.properties) */
.prop-form-group {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
  gap: 10px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 15px;
}

.prop-form-group:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.prop-label {
  width: 40%;
  text-align: right;
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-all;
  padding-right: 10px;
  box-sizing: border-box;
}

.prop-input {
  flex: 1;
  /* Take remaining space */
  box-sizing: border-box;
}

/* フォームのレスポンシブ対応 */
@media (max-width: 600px) {
  .prop-form-group {
    flex-direction: column;
    align-items: flex-start;
    /* Align labels left */
    gap: 5px;
  }

  .prop-label {
    width: 100%;
    text-align: left;
    padding-right: 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
  }

  .prop-input {
    width: 100%;
  }
}

/* --- ユーティリティ --- */
.d-none {
  display: none;
}

/* --- ここから IDE / Config Editor 用スタイル --- */

.ide-layout {
  display: flex;
  flex-direction: row;
  background-color: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.07);
  min-height: 70vh; /* 最小の高さを確保 */
  overflow: hidden; /* 角丸のため */
}

.ide-file-tree {
  width: 30%;
  max-width: 300px;
  min-width: 200px;
  border-right: 1px solid var(--border-color);
  background-color: #fcfcfc;
  padding: 1.5rem;
  overflow-y: auto;
  box-sizing: border-box;
}

.ide-file-tree h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.2rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.ide-editor-pane {
  flex-grow: 1; /* 残りの幅をすべて使用 */
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.ide-editor-pane h3 {
  margin-top: 0;
  font-size: 1.2rem;
  color: var(--text-secondary);
  font-weight: 500;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
  word-break: break-all;
}

/* エディタのテキストエリア */
#fileContent.form-control {
  flex-grow: 1; /* 縦方向のスペースを埋める */
  min-height: 400px;
  font-family: monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  resize: vertical; /* 縦方向のみリサイズ可 */
}

/* ファイルツリーのスタイル */
ul.tree {
  list-style: none;
  padding-left: 5px;
  font-size: 0.9rem;
}

ul.tree ul {
  padding-left: 20px;
}

ul.tree li {
  padding: 5px 8px;
  cursor: pointer;
  border-radius: 4px;
  transition: background-color 0.2s ease;
  word-break: break-all;
}

ul.tree li:hover {
  background-color: #f0f4ff;
}

/* フォルダとファイルのアイコン */
ul.tree li.folder::before {
  content: '▸ '; /* 閉じているフォルダ */
  font-size: 0.8rem;
  margin-right: 2px;
}

ul.tree li.file::before {
  content: ' ';
  display: inline-block;
  width: 1.2em; /* フォルダのアイコン幅と合わせる */
}

li.selected {
  background-color: var(--primary-color);
  color: white;
  font-weight: 500;
}

li.selected:hover {
  background-color: var(--primary-hover);
  color: white;
}

/* エディタ操作（保存ボタンなど） */
.editor-actions {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* チェックボックスのスタイル調整 */
.editor-actions .info-group {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.editor-actions .info-group label {
  margin: 0;
  font-weight: 500;
  color: var(--text-primary);
}

/* チェックボックス自体のサイズをリセット */
.editor-actions input[type="checkbox"] {
  width: auto;
  height: auto;
}

/* --- ここから Worldデータ編集用スタイル --- */

/* 警告・読み取り専用の通知 */
.notice-readonly {
  padding: 1rem;
  margin-bottom: 1.5rem;
  background-color: #fffbeb;
  border: 1px solid #fde68a;
  color: #b45309;
  border-radius: 6px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 500;
}

/* 操作グループ */
.action-group {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}
.action-group:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.action-group label {
  display: block;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  font-size: 1.1rem;
}

/* ファイル入力とボタンを横並びにする */
.action-group .file-input-group {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

/* ボタンのバリエーション（削除ボタン） */
.btn-danger {
  background-color: var(--stop-color);
}

.btn-danger:hover {
  background-color: var(--stop-hover);
}

/* --- ここから お知らせ詳細 (news-pick) 用スタイル --- */

.news-article {
  /* .card スタイルを基本とする */
  background-color: var(--card-bg);
  padding: 2rem 2.5rem; /* 少し広めに */
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.07);
  margin-bottom: 2rem;
  text-align: left;
}

.news-title {
  font-size: 2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 0;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.news-date {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  display: block;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1.5rem;
}

.news-content {
  font-size: 1rem;
  color: var(--text-primary);
  line-height: 1.8;
}

.news-content p {
  margin: 0 0 1.5rem;
}

.news-content p:last-child {
  margin-bottom: 0;
}

.back-link {
  display: inline-block;
  margin-top: 2rem;
  font-size: 0.9rem;
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.back-link:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* --- ここから ログビューワー用スタイル --- */

textarea.log-viewer {
  font-family: monospace;
  /* 等幅フォント */
  white-space: pre;
  /* 改行とスペースをそのまま表示 */
  min-height: 500px;
  /* 高さを確保 */
  font-size: 0.9rem;
  line-height: 1.5;
  color: #333;
  /* テキスト色を少し濃く */
  resize: vertical;
  /* 縦方向のリサイズのみ許可 */
}

/* --- ここから サーバー管理リスト用スタイル --- */
.server-list {
  list-style: none;
  padding: 0;
  margin: 0;
  /* .card の中に配置されるので、border-radius や shadow は不要 */
}

.server-list-item {
  display: block;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  text-decoration: none;
  color: var(--text-primary); /* メインのテキスト色 */
  font-size: 1rem;
  font-weight: 500;
  transition: background-color 0.2s ease;
}

.server-list-item:last-child {
  border-bottom: none;
}

.server-list-item:hover {
  background-color: var(--light-bg); /* 薄いグレーのホバー色 */
}

/* 選択可能であることを示す矢印 */
.server-list-item::after {
  content: '›';
  float: right;
  font-weight: bold;
  font-size: 1.5rem;
  color: var(--text-secondary);
  line-height: 1; /* 矢印を上下中央に揃える */
}