/* ベースフォント */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  margin: 0;
  padding: 12px;
  background: #f9f9f9;
  color: #333;
  -webkit-font-smoothing: antialiased;
}
h1, h2 {
  margin: 0 0 8px 0;
  font-weight: 700;
}

/* コンテナ */
#container {
  max-width: 900px;
  margin: 0 auto;
}

/* 折りたたみ用ボタン */
#toggleFormBtn {
  background: #007bff;
  color: white;
  font-weight: 700;
  border: none;
  padding: 12px 20px;
  border-radius: 4px;
  cursor: pointer;
  width: 100%;
  margin-bottom: 12px;
  font-size: 1.1rem;
  user-select: none;
  transition: background-color 0.3s ease;
}
#toggleFormBtn:hover,
#toggleFormBtn:focus {
  background: #0056b3;
  outline: 2px solid #0056b3;
}

/* 登録フォームエリア */
#formContainer {
  background: white;
  border-radius: 8px;
  padding: 16px 20px 24px 20px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  margin-bottom: 24px;
}
#formContainer.collapsed {
  display: none;
}

/* 入力行 */
.form-row {
  margin-bottom: 14px;
}
label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 1rem;
}
input[type="text"],
input[type="datetime-local"],
input[type="file"],
select,
textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: 5px;
  border: 1.8px solid #ccc;
  font-size: 1rem;
  font-weight: 400;
  transition: border-color 0.2s ease;
}
input[type="text"]:focus,
input[type="datetime-local"]:focus,
input[type="file"]:focus,
select:focus,
textarea:focus {
  border-color: #007bff;
  outline: none;
}
textarea {
  resize: vertical;
  min-height: 60px;
}

/* ボタン群 */
#formButtons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}
button {
  cursor: pointer;
  background: #007bff;
  color: white;
  border: none;
  padding: 12px 22px;
  font-weight: 700;
  font-size: 1rem;
  border-radius: 6px;
  flex: 1 1 auto;
  min-width: 120px;
  transition: background-color 0.3s ease;
}
button:hover,
button:focus {
  background: #0056b3;
}
button.btn-ghost {
  background: transparent;
  color: #007bff;
  border: 2px solid #007bff;
  font-weight: 600;
}
button.btn-ghost:hover,
button.btn-ghost:focus {
  background: #007bff;
  color: white;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.form-group select, .form-group input {
    flex: 1;
}
.flex-row {
    display: flex;
    gap: 10px;
    align-items: center;
    width: 100%;
}
.flex-row input[type="text"] {
    flex: 1;
}
.flex-row button {
    min-width: fit-content;
    padding: 10px 12px;
}
.flex-row select {
  flex: 0 1 auto;
}
.flex-row select + input {
  flex: 1 1 auto;
}
.flex-row select.full-width {
  flex: 1 1 100%;
}

/* テーブル */
#archiveContainer {
  background: white;
  padding: 16px 20px 24px 20px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

#archiveHeader {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
#archiveHeader h2 {
  margin-bottom: 8px;
}
#searchInput {
  padding: 8px 12px;
  font-size: 1rem;
  border-radius: 5px;
  border: 1.8px solid #ccc;
  max-width: 240px;
}
#searchInput:focus {
  border-color: #007bff;
  outline: none;
}

#tableWrapper {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 700px; /* 小さすぎると見づらいので最低幅を設定 */
}
thead tr {
  background-color: #007bff;
  color: white;
}
th, td {
  padding: 10px 12px;
  border: 1px solid #ddd;
  font-size: 0.9rem;
  vertical-align: top;
  white-space: normal; /* テキストの折り返しを許可 */
}
th {
  font-weight: 700;
  white-space: nowrap;
}
td {
  word-break: break-word;
}

/* 画像サムネイル用のセル */
td.image-cell {
  text-align: center;
}
td.image-cell img {
  max-width: 60px;
  max-height: 60px;
  display: block;
  margin: 0 auto;
  border: 1px solid #ccc;
  object-fit: contain;
  border-radius: 4px;
}

/* 操作ボタン */
.btn-ghost {
  background: none;
  border: none;
  color: #007bff;
  padding: 4px 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  margin-right: 6px;
  border-radius: 4px;
  user-select: none;
}
.btn-ghost:hover,
.btn-ghost:focus {
  background-color: #cce4ff;
  outline: none;
}

/* モーダル */
.modal {
  display: none;
  position: fixed;
  z-index: 1;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.4);
  justify-content: center;
  align-items: center;
}
.modal-content {
  background-color: #fefefe;
  margin: auto;
  padding: 20px;
  border: 1px solid #888;
  width: 80%;
  max-width: 600px;
  border-radius: 8px;
  position: relative;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}
.close {
  color: #aaa;
  position: absolute;
  top: 10px;
  right: 20px;
  font-size: 28px;
  font-weight: bold;
}
.close:hover,
.close:focus {
  color: #000;
  text-decoration: none;
  cursor: pointer;
}
.modal-item {
  margin-bottom: 10px;
}
.modal-item strong {
  display: inline-block;
  width: 120px;
}
.modal-image {
  max-width: 100%;
  display: block;
  margin-top: 15px;
}

/* スマホ対応 */
@media screen and (max-width: 700px) {
  body {
    padding: 8px;
  }
  #formButtons {
    flex-direction: column;
  }
  button {
    width: 100% !important;
    min-width: auto !important;
  }
  #archiveHeader {
    flex-direction: column;
    align-items: flex-start;
  }
  #searchInput {
    max-width: 100%;
    margin-top: 6px;
  }
  table {
      min-width: 0; /* スマホでは最低幅を解除 */
  }
  th, td {
    font-size: 0.85rem;
    padding: 8px 6px;
    /* スマホではテキストを折り返す */
    white-space: normal;
  }
  .flex-row {
      flex-direction: column;
  }
  .flex-row button {
      width: 100%;
  }
  .modal-content {
      width: 95%;
  }
}