/* ========================================
   EK Management - Modal CSS
   モーダルとフォームの共通スタイル
   ======================================== */

/* ========================================
   1. モーダル基本構造
   ======================================== */

.modal {
  position: fixed;
  top: 0; 
  left: 0; 
  right: 0; 
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.modal-overlay {
  position: fixed;
  top: 0; 
  left: 0; 
  right: 0; 
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.modal-overlay.is-open,
.modal-overlay.show {
  display: flex;
}

.modal-content {
  background: #fff;
  border-radius: 8px;
  box-sizing: border-box;
  position: relative;
  width: 70%;
  max-width: 600px;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  margin: 1% auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* ========================================
   2. モーダルヘッダー
   ======================================== */

.modal-header {
  padding: 20px;
  border-bottom: 1px solid #ddd;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #f8f9fa;
  border-radius: 8px 8px 0 0;
}

.modal-header h3 {
  margin: 0;
  color: #333;
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  color: #aaa;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  background: none;
  border: none;
  line-height: 1;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  color: #000;
}

/* ========================================
   3. モーダルボディ・フッター
   ======================================== */

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 20px;
  border-top: 1px solid #ddd;
  text-align: right;
  background-color: #f8f9fa;
  border-radius: 0 0 8px 8px;
}

/* ========================================
   4. フォーム基本スタイル
   ======================================== */

.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  color: #333;
  font-size: 14px;
}

.modal .form-group input,
.modal .form-group text,
.modal .form-group select,
.modal .form-group textarea {
  width: 100% !important;
  padding: 12px 16px 12px 12px !important;
  border: 1px solid #ddd !important;
  border-radius: 6px !important;
  font-size: 14px !important;
  transition: all 0.2s ease !important;
  box-sizing: border-box !important;
  margin-top: 0 !important;
  background-color: #fff !important;
}

.modal .form-group input:focus,
.modal .form-group select:focus,
.modal .form-group textarea:focus {
  outline: none !important;
  border-color: #007bff !important;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25) !important;
}

/* 特殊な入力タイプは基本スタイルを継承 */

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

.modal .form-group input[type="checkbox"],
.modal .form-group input[type="radio"] {
  width: auto !important;
  margin-right: 8px;
  margin-top: 0;
}

/* ========================================
   5. フォームバリデーション
   ======================================== */

.modal .form-group .error-message {
  color: #dc3545;
  font-size: 12px;
  margin-top: 4px;
  display: none;
}

.modal .form-group.has-error .error-message {
  display: block;
}

.modal .form-group.has-error input,
.modal .form-group.has-error select,
.modal .form-group.has-error textarea {
  border-color: #dc3545 !important;
}

.modal .form-group.required label::after {
  content: " *";
  color: #dc3545;
}

/* ========================================
   6. フォームレイアウト
   ======================================== */

.form-row {
  display: flex;
  gap: 15px;
  margin-bottom: 15px;
}

.form-row .form-group {
  flex: 1;
  margin-bottom: 0;
}

.search-group {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
}

.search-group label {
  margin-bottom: 0;
  white-space: nowrap;
}

.search-group input,
.search-group select {
  flex: 1;
  margin-bottom: 0;
}

.form-help {
  font-size: 12px;
  color: #6c757d;
  margin-top: 4px;
}

/* ========================================
   6.5. 検索結果スタイル
   ======================================== */

.search-result-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #eee;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.search-result-item:hover {
  background-color: #f8f9fa;
}

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

/* キーボード選択時のスタイル */
.search-result-item.keyboard-selected {
  background-color: #94aac2 !important;
  color: #fff !important;
}

/* 検索結果なしメッセージ */
.search-no-results {
  padding: 8px 12px;
  color: #666;
  text-align: center;
}

/* ========================================
   7. フォームセクション
   ======================================== */

.form-section {
  margin-bottom: 30px;
  padding: 20px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background-color: #f9f9f9;
}

.form-section h5 {
  margin: 0 0 20px 0;
  color: #333;
  font-size: 16px;
  font-weight: 600;
  border-bottom: 2px solid #007bff;
  padding-bottom: 8px;
}

/* セクションのバリエーション */
.form-section.primary {
  border-color: #007bff;
  background-color: #f8f9ff;
}

.form-section.success {
  border-color: #28a745;
  background-color: #f8fff9;
}

.form-section.warning {
  border-color: #ffc107;
  background-color: #fffdf8;
}

.form-section.danger {
  border-color: #dc3545;
  background-color: #fff8f8;
}

/* ========================================
   8. ボタンスタイル
   ======================================== */

/* .btn {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  margin-left: 5px;
  text-decoration: none;
  display: inline-block;
  transition: all 0.2s ease;
  font-weight: 500;
} */

.btn-primary {
  background-color: #007bff;
  color: white;
}

.btn-primary:hover {
  background-color: #0056b3;
}

.btn-success {
  background-color: #28a745;
  color: white;
}

.btn-success:hover {
  background-color: #1e7e34;
}

.btn-secondary {
  background-color: #6c757d;
  color: white;
}

.btn-secondary:hover {
  background-color: #545b62;
}

.btn-outline-success {
  background-color: transparent;
  color: #28a745;
  border: 1px solid #28a745;
}

.btn-outline-success:hover {
  background-color: #28a745;
  color: white;
}

.btn-danger {
  background-color: #dc3545;
  color: white;
}

.btn-danger:hover {
  background-color: #c82333;
}

.btn-warning {
  background-color: #ffc107;
  color: #212529;
}

.btn-warning:hover {
  background-color: #e0a800;
}

.btn-info {
  background-color: #17a2b8;
  color: white;
}

.btn-info:hover {
  background-color: #138496;
}

/* ========================================
   9. フォームフッター
   ======================================== */

.form-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #e0e0e0;
}
.edit-form-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}
.button-row {
  display: flex;
  gap: 15px;
  justify-content: center;
}
.button-row .btn {
  flex: 1 1 0;
  min-width: 200px;
}
.button-row .btn-delete {
  max-width: 150px;
}
.form-footer .btn {
  margin-left: 0;
}
.button-row .btn-save {
  background-color: var(--unit-color);
  color: white;
}
.button-row .btn-save:hover {
  background-color: rgb(81, 123, 169);
}
.button-row .btn-cancel {
  background-color: #6c757d;
  color: white;
}
.button-row .btn-cancel:hover {
  background-color: #545b62;
}
.btn-delete {
  background-color: #dc3545;
  color: white;
}
.btn-delete:hover {
  background-color: #c82333;
}



/* ========================================
   10. 特殊モーダル（画像表示など）
   ======================================== */

#image-modal img {
  max-width: 90%;
  max-height: 90%;
  box-shadow: 0 2px 16px rgba(0,0,0,0.5);
  border-radius: 8px;
  background: #fff;
  padding: 4px;
}

.modal-content button.btn.btn-delete {
  background-color: #f5f5f5;
  border: 1px solid #ccc;
  padding: 0.5rem 1rem;
  font-size: 14px;
  border-radius: 4px;
  color: #333;
  cursor: pointer;
  margin-right: 12px;
  align-self: flex-end;
}

button.btn.btn-delete:hover {
  background-color: #eee;
}

.modal-content .button-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 32px;
}

.modal-content .button-footer button {
  min-width: 80px;
}

.modal-content .button-footer .btn-delete {
  background-color: #f5f5f5;
  border: 1px solid #ccc;
  color: #333;
}

.modal-content .button-footer .btn-delete:hover {
  background-color: #eee;
}

/* ========================================
   11. 共通ユーティリティクラス
   ======================================== */

.avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #ddd;
  transition: all 0.3s ease;
  object-fit: cover;
}

.avatar-placeholder {
  width: 50px;
  height: 50px;
  background-color: #f0f0f0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  font-size: 12px;
  border: 2px solid #ddd;
  cursor: pointer;
  transition: all 0.3s ease;
}

.card {
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  padding: 20px;
  background-color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: all 0.3s ease;
}

.result-item {
  padding: 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

/* ========================================
   12. レスポンシブ対応
   ======================================== */

@media (max-width: 768px) {
  .modal-content {
    width: 95%;
    margin: 2% auto;
    max-height: calc(100vh - 20px);
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .form-row .form-group {
    margin-bottom: 15px;
  }

  .search-group {
    flex-direction: column;
    align-items: stretch;
  }

  .form-footer {
    flex-direction: column;
  }

  .form-footer .btn {
    width: 100%;
    margin-bottom: 10px;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 15px;
  }
}

@media (max-width: 480px) {
  .modal-content {
    width: 98%;
    margin: 1% auto;
  }

  .modal-header h3 {
    font-size: 16px;
  }

  .form-section {
    padding: 15px;
  }
}

/* ========================================
   13. マーク追加モーダル専用スタイル
   ======================================== */

/* マークセクションのヘッダー */
.mark-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.mark-section-header .section-title {
  margin-bottom: 0;
}

/* 新規マーク追加ボタン */

  button.btn.btn-add-mark {
    margin: 0;
  transition: filter 0.3s ease;
}


.btn-add-mark:hover {
  filter: brightness(0.85);
}

/* マークモーダル */
#mark-modal.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  justify-content: center;
  align-items: center;
}

#mark-modal .modal-content {
  background: white;
  padding: 30px;
  max-width: 500px;
  width: 90%;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  position: relative;
}

#mark-modal .modal-close {
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 28px;
  font-weight: bold;
  color: #aaa;
  cursor: pointer;
  transition: color 0.3s;
}

#mark-modal .modal-close:hover {
  color: #000;
}

#mark-modal h3 {
  margin-top: 0;
  margin-bottom: 20px;
}

#mark-modal form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

#mark-modal form > div label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
}

#mark-modal form > div label span {
  color: red;
}

#mark-modal form input[type="text"],
#mark-modal form input[type="number"],
#mark-modal form select {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 14px;
}

/* カラーピッカーのコンテナ */
.color-picker-container {
  display: flex;
  
}

.color-picker-container label {
  width: 17%;
}

.color-picker-container input[type="color"] {
  width: 58%;
  height: 40px;
  cursor: pointer;
  border: 1px solid #ddd;
  border-radius: 5px;
}

/* 旧スタイル（後方互換性のため保持） */

#mark-modal .button-group {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

#mark-modal .button-group button {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 0.3s;
}

#mark-modal .button-group .btn-cancel {
  background-color: #6c757d;
  color: white;
}

#mark-modal .button-group .btn-cancel:hover {
  background-color: #5a6268;
}

#mark-modal .button-group .btn-save {
  background-color: #28a745;
  color: white;
}

#mark-modal .button-group .btn-save:hover {
  background-color: #218838;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .mark-section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .btn-add-mark {
    width: 100%;
  }

  #mark-modal .modal-content {
    width: 95%;
    padding: 20px;
  }
}

@media (max-width: 480px) {
  .mark-section-header .section-title {
    font-size: 16px;
  }

  .btn-add-mark {
    font-size: 13px;
    padding: 0.4rem 0.8rem;
  }

  #mark-modal .modal-content {
    width: 98%;
    padding: 15px;
  }

  #mark-modal h3 {
    font-size: 18px;
  }

  #mark-modal form input[type="text"],
  #mark-modal form input[type="number"],
  #mark-modal form select {
    font-size: 16px;
  }
}

/* ========================================
   14. 画像モーダル専用
   ======================================== */

#image-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

/* ========================================
   15. モーダルオープン時のbody制御
   ======================================== */

.modal-open {
  overflow: hidden;
}

     