@charset "UTF-8";

/* 文書テンプレート管理ページのスタイル */
.template-container {
  padding: 20px;
  background-color: #fff;
}

.template-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 30px;
  background-color: #fff !important;
  cursor: default;
}

.btn-add-template {
  background-color: #5ba7d4;
  color: #fff !important;
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.3s;
}

.btn-add-template:hover {
  background-color: #4a96c3;
  opacity: 1;
}

.btn-add-template i {
  color: #fff !important;
}

/* テンプレート一覧に戻るボタン */
.btn-back-to-list {
  background-color: #6c757d;
  color: white !important;
  border: none;
  border-radius: 5px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.3s;
}

.btn-back-to-list:hover {
  background-color: #5a6268;
  color: white !important;
}

.btn-back-to-list i {
  color: white !important;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.template-card {
  background-color: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  cursor: pointer;
}

.template-card:hover {
  background-color: #5ba7d4;
  color: #fff;
}

.template-card:hover .template-title {
  color: #fff;
}

.template-card:hover .template-dates {
  color: #fff;
}

.template-card-header {
  background-color: #f8f9fa;
  padding: 15px 20px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background-color 0.3s ease;
}

.template-card:hover .template-card-header {
  background-color: #5ba7d4;
}

.template-title {
  font-size: 16px;
  font-weight: bold;
  color: #333;
  margin: 0;
  transition: color 0.3s ease;
}

.template-card-body {
  padding: 15px 20px;
}

.template-dates {
  font-size: 14px;
  color: #666;
  line-height: 1.4;
  margin-bottom: 0;
  transition: color 0.3s ease;
}

.template-dates div {
  margin-bottom: 2px;
}

.template-dates div:last-child {
  margin-bottom: 0;
}

/* レスポンシブ対応 */
@media screen and (max-width: 768px) {
  .template-container {
    padding: 15px;
  }
  
  .template-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .template-header {
    justify-content: center;
    margin-bottom: 20px;
  }
  
  .btn-add-template {
    width: auto;
    font-size: 14px;
    padding: 8px 16px;
  }
  
  .template-card-header {
    padding: 12px 15px;
  }
  
  .template-title {
    font-size: 14px;
  }
  
  .template-card-body {
    padding: 12px 15px;
  }
  
  .template-dates {
    font-size: 12px;
  }
}

/* 文書テンプレート編集エリアのスタイル */
.template-edit-area {
  background-color: #fff;
  border-radius: 10px;
  padding: 20px;
  margin-top: 20px;
}

.edit-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 15px;
  border-bottom: 1px solid #e0e0e0;
}

.edit-header h3 {
  margin: 0;
  font-size: 20px;
  color: #333;
}

.edit-actions {
  display: flex;
  gap: 10px;
}

.btn-cancel {
  background-color: #6c757d;
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.3s;
}

.btn-cancel:hover {
  background-color: #5a6268;
}

.btn-save {
  background-color: #5ba7d4;
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.3s;
}

.btn-save:hover {
  background-color: #4a96c3;
}

/* テンプレート名セクション */
.template-name-section {
  margin-bottom: 30px;
}

.template-name-section label {
  display: block;
  font-weight: bold;
  color: #333;
}

.template-name-section .required {
  color: #dc3545;
}

.template-name-section input[type="text"] {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 16px;
}

/* 条項セクション */
.clauses-section {
  background-color: #f8f9fa;
  border-radius: 8px;
  padding: 20px;
}

.clauses-container {
  margin-bottom: 20px;
}

.clause-item {
  background-color: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  margin-bottom: 15px;
  padding: 3px 15px;
}

.clause-controls {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.order-controls {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-right: 5px;
}

.btn-move-up,
.btn-move-down {
  background-color: #f8f9fa;
  border: 1px solid #ddd;
  border-radius: 3px;
  width: 30px;
  height: 25px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #666;
  transition: all 0.2s;
}

.btn-move-up:hover,
.btn-move-down:hover {
  background-color: #e9ecef;
  color: #333;
}

.clause-content {
  flex: 1;
}

.main-headline-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 16px;
  font-weight: bold;
}

.sub-content {
  display: flex;
  gap: 15px;
  align-items: flex-start;
}

.sub-headline-input {
  width: 200px;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 16px;
  flex-shrink: 0;
}

.content-textarea {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 16px;
  min-height: 80px;
  resize: vertical;
}

.content-only .content-textarea {
  width: 100%;
}

.btn-delete-clause {
  background-color: #dc3545;
  color: #fff;
  border: none;
  border-radius: 5px;
  width: 35px;
  height: 35px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background-color 0.3s;
  margin-left: 10px;
}

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

/* 条項追加ボタン */
.add-clause-container {
  position: relative;
  text-align: center;
  margin: 10px 0;
}

.btn-add-clause {
  background-color: #28a745;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.3s;
}

.btn-add-clause:hover {
  background-color: #218838;
  transform: scale(1.1);
}

.clause-type-menu {
  position: absolute;
  top: 45px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 100;
  min-width: 180px;
}

.clause-type-btn {
  display: block;
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  color: #333;
  transition: background-color 0.2s;
}

.clause-type-btn:hover {
  background-color: #f8f9fa;
}

.clause-type-btn:not(:last-child) {
  border-bottom: 1px solid #e9ecef;
}

/* レスポンシブ対応 - 編集エリア */
@media screen and (max-width: 768px) {
  .template-edit-area {
    padding: 15px;
  }
  
  .edit-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }
  
  .edit-actions {
    align-self: flex-end;
  }
  
  .sub-content {
    flex-direction: column;
    gap: 10px;
  }
  
  .sub-headline-input {
    width: 100%;
  }
  
  .clause-controls {
    flex-direction: column;
    gap: 10px;
  }
  
  .order-controls {
    flex-direction: row;
    justify-content: center;
  }
  
  .btn-delete-clause {
    margin-left: 0;
    align-self: flex-end;
  }
}

/* 文書テンプレート編集エリアのスタイル */
.template-edit-area {
  background-color: #fff;
  border-radius: 10px;
  padding: 20px;
  margin-top: 20px;
  width: 100%;
  max-width: 1000px;
  margin-left: auto;
  margin-right: auto;
}

/* コントロールヘッダー */
.edit-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 15px;
  border-bottom: 1px solid #e0e0e0;
}

/* 閲覧/編集モードトグル */
.view-mode-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  gap: 10px;
}

.toggle-switch input[type="checkbox"] {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: relative;
  width: 50px;
  height: 24px;
  background-color: #ccc;
  border-radius: 24px;
  transition: background-color 0.3s;
}

.toggle-slider:before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background-color: #fff;
  border-radius: 50%;
  transition: transform 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: #5ba7d4;
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(26px);
}

.toggle-label {
  font-weight: 500;
  color: #333;
}

/* アクションボタン */
.action-buttons {
  display: flex;
  gap: 10px;
}

.template-edit-area .btn-cancel {
  background-color: #6c757d;
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.3s;
}

.template-edit-area .btn-cancel:hover {
  background-color: #5a6268;
}

.template-edit-area .btn-save {
  background-color: #5ba7d4;
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.3s;
}

.template-edit-area .btn-save:hover {
  background-color: #4a96c3;
}

/* テンプレート名セクション */
.template-name-section {
  margin-bottom: 30px;
}

.template-name-display h1 {
  margin: 0;
  font-size: 24px;
  font-weight: bold;
  color: #333;
  line-height: 1.4;
  text-align: center;
}

.template-name-edit {
  display: flex;
  align-items: center;
  gap: 15px;
  justify-content: flex-start;
}

.template-name-label {
  font-size: 16px;
  font-weight: 500;
  color: #333;
  white-space: nowrap;
  flex-shrink: 0;
}

.template-name-label .required {
  color: #dc3545;
  font-weight: bold;
}

.template-name-edit input[type="text"] {
  flex: 1;
  max-width: 600px;
  padding: 10px 0;
  border: none;
  border-bottom: 2px solid #5ba7d4;
  font-size: 24px;
  font-weight: bold;
  color: #333;
  background-color: transparent;
  outline: none;
  text-align: left;
}

/* 文書内容エリア */
.document-content {
  line-height: 1.6;
}

.clauses-container {
  min-height: 200px;
}

/* 条項アイテム */
.clause-item {
  position: relative;
  margin-bottom: 8px;
  border-radius: 5px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.clause-content-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  min-height: 38px;
  flex: 1;
}

/* 表示順コントロール - 左右配置 */
.order-controls {
  display: flex;
  flex-direction: row;
  gap: 4px;
  opacity: 1;
  transition: opacity 0.2s;
  margin-right: 5px;
}

.btn-move-up,
.btn-move-down {
  background-color: #f8f9fa;
  border: 1px solid #ddd;
  border-radius: 3px;
  width: 20px;
  height: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #666;
  transition: all 0.2s;
}

.btn-move-up:hover,
.btn-move-down:hover {
  background-color: #e9ecef;
  color: #333;
}

/* 削除ボタン（ホバー時表示・右外側配置） */
.btn-delete-clause {
  background-color: #dc3545;
  color: #fff;
  border: none;
  border-radius: 3px;
  width: 24px;
  height: 24px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  transition: background-color 0.3s;
  margin-left: 5px;
}

.clause-item:hover .btn-delete-clause {
  display: flex;
}

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

/* 条項内容 */
.clause-content {
  flex: 1;
  min-height: 24px;
}

/* 大見出し */
.clause-item.main-headline .clause-content {
  font-weight: bold;
  font-size: 14px;
  color: #333;
  padding: 2px 0;
}

.main-headline-input {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 16px;
  font-weight: bold;
  color: #333;
  padding: 8px;
  outline: none;
  resize: none;
  overflow: hidden;
  min-height: 38px;
  height: 38px !important;
  line-height: 1.4;
  white-space: nowrap;
  box-sizing: border-box;
}

.main-headline-display {
  font-weight: bold;
  font-size: 14px;
  color: #333;
  padding: 2px 0;
}

/* 小見出し＋内容 */
.clause-item.sub-with-content .clause-content .sub-content {
  display: flex;
  gap: 15px;
  align-items: flex-start;
}

.sub-headline-display {
  min-width: 80px;
  max-width: 120px;
  font-weight: 500;
  color: #555;
}

.sub-headline-input {
  min-width: 80px;
  max-width: 120px;
  border: none;
  background: transparent;
  font-weight: 500;
  color: #555;
  padding: 8px;
  outline: none;
  resize: none;
  overflow: hidden;
  min-height: 38px;
  height: 38px !important;
  line-height: 1.4;
  white-space: nowrap;
  box-sizing: border-box;
}

.content-display {
  flex: 1;
  color: #333;
}

.content-textarea {
  flex: 1;
  border: none;
  background: transparent;
  color: #333;
  padding: 8px;
  outline: none;
  resize: none;
  overflow: hidden;
  min-height: 38px;
  height: 38px;
  line-height: 1.4;
  box-sizing: border-box;
}

/* 内容のみ */
.content-only-display {
  width: 100%;
  color: #333;
}

.content-only-textarea {
  width: 100%;
  border: none;
  background: transparent;
  color: #333;
  padding: 8px;
  outline: none;
  resize: none;
  overflow: hidden;
  min-height: 38px;
  height: 38px;
  line-height: 1.4;
  box-sizing: border-box;
}

/* 空行とホバーボタン - 横線＋右側ボタン */
.empty-line {
  position: relative;
  height: 12px;
  margin: 8px 0;
  display: flex;
  align-items: center;
}

.empty-line::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background-color: #e0e0e0;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity 0.2s;
}

.empty-line:hover::before {
  opacity: 1;
}

.add-clause-hover {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity 0.2s;
}

.empty-line:hover .add-clause-hover {
  opacity: 1;
}

.btn-add-clause {
  background-color: #5ba7d4;
  color: #fff;
  border: none;
  border-radius: 3px;
  width: 20px;
  height: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all 0.3s;
}

.btn-add-clause:hover {
  background-color: #4a96c3;
}

/* 条項タイプメニュー */
.clause-type-menu {
  position: absolute;
  top: 30px;
  right: 0;
  background-color: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 100;
  min-width: 150px;
  display: none;
}

.clause-type-menu.show {
  display: block;
}

.clause-type-btn {
  display: block;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  color: #333;
  transition: background-color 0.2s;
}

.clause-type-btn:hover {
  background-color: #f8f9fa;
}

.clause-type-btn:not(:last-child) {
  border-bottom: 1px solid #e9ecef;
}

/* 編集モード時のスタイル */
.edit-mode .main-headline-input,
.edit-mode .sub-headline-input,
.edit-mode .content-textarea,
.edit-mode .content-only-textarea {
  border-bottom: 1px solid #e0e0e0;
  background-color: rgba(91, 167, 212, 0.05);
  padding: 8px;
}

.edit-mode .main-headline-input:focus,
.edit-mode .sub-headline-input:focus,
.edit-mode .content-textarea:focus,
.edit-mode .content-only-textarea:focus {
  border-bottom-color: #5ba7d4;
  background-color: rgba(91, 167, 212, 0.1);
}

/* 閲覧モード時は編集要素を非表示・完成書類の見た目 */
.view-mode .order-controls {
  display: none;
}

.view-mode .btn-delete-clause {
  display: none !important;
}

.view-mode .empty-line {
  display: none;
}

/* 閲覧モード時の条項スタイル - 完成書類の見た目 */
.view-mode .clause-item {
  background-color: transparent;
  border: none;
  margin-bottom: 4px;
  border-radius: 0;
}

.view-mode .clause-item:hover {
  background-color: transparent;
}

.view-mode .clause-content-wrapper {
  padding: 0;
}

/* 閲覧モード時の大見出し - 左寄せで統一 */
.view-mode .main-headline-display {
  font-size: 16px;
  font-weight: bold;
  text-align: left;
  margin: 8px 0 4px 0;
  padding: 2px 0;
}

/* 閲覧モード時の小見出し＋内容 */
.view-mode .sub-headline-display {
  font-weight: bold;
  min-width: 80px;
  max-width: 120px;
  margin-right: 10px;
}

.view-mode .content-display,
.view-mode .content-only-display {
  line-height: 1.8;
  margin-bottom: 8px;
  white-space: pre-wrap;
}

/* buttonタグのテンプレートカード用スタイル調整 */
button.template-card {
  border: none;
  text-align: left;
  width: 100%;
}

/* テンプレートカードがボタンタグの場合の追加スタイル */
button.template-card:focus {
  outline: 2px solid #5ba7d4;
  outline-offset: 2px;
}

/* レスポンシブ対応 - 編集エリア */
@media screen and (max-width: 768px) {
  .template-edit-area {
    padding: 15px;
  }
  
  .edit-controls {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }
  
  .action-buttons {
    align-self: flex-end;
  }
  
  .clause-item.sub-with-content .clause-content .sub-content {
    flex-direction: column;
    gap: 5px;
  }
  
  .sub-headline-input {
    min-width: auto;
    max-width: none;
    width: 100%;
  }
  
  .template-name-display h1 {
    font-size: 20px;
  }
  
  .template-name-edit input[type="text"] {
    font-size: 20px;
  }
}