/* ===== cms.css — 管理者UI表示制御・CMSモーダル ===== */

/* ---- admin-only 表示制御 ---- */

.admin-only {
  display: none !important;
}

body.is-admin .admin-only {
  display: inline-flex !important;
}

body.is-admin .modal-edit-row.admin-only {
  display: flex !important;
}

.modal-edit-row .icon-btn {
  display: inline-flex;
}

/* ---- CMSモーダル内フォーム ---- */

.cms-textarea {
  width: 100%;
  min-height: 130px;
  padding: 10px;
  border: 1px solid #888;
  background: var(--paper);
  color: var(--ink, #000);
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.75;
  resize: vertical;
  box-sizing: border-box;
  display: block;
}

.cms-textarea:focus {
  outline: none;
  border-color: #000;
}

/* ---- 画像エリア ---- */

.cms-image-section {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.cms-image-section[hidden] {
  display: none !important;
}

.cms-image-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--muted, #555);
  border: 1px solid #888;
  padding: 4px 12px;
  background: #ddd;
  user-select: none;
  font-family: inherit;
}

.cms-image-label[hidden] {
  display: none !important;
}

.cms-image-label:hover {
  background: #bbb;
  border-color: #000;
  color: #000;
}

.cms-image-label svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  flex-shrink: 0;
}

.cms-image-input {
  display: none;
}

.cms-image-preview-wrap {
  position: relative;
  display: inline-flex;
  width: fit-content;
  margin-top: 10px;
  overflow: hidden;
}

.cms-image-preview-wrap[hidden] {
  display: none !important;
}

.cms-modal-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cms-author-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.76rem;
  color: var(--muted, #555);
  white-space: nowrap;
}

.cms-author-badge[hidden] {
  display: none !important;
}

.cms-author-badge-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.cms-image-preview {
  display: block;
  width: auto;
  max-width: min(100%, 240px);
  max-height: 180px;
  object-fit: contain;
  background: #eee;
}

.cms-image-preview[hidden] {
  display: none !important;
}

.cms-image-replace {
  position: absolute;
  left: 50%;
  top: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 4px 12px;
  border: 1px solid #888;
  background: #ddd;
  color: var(--muted, #555);
  font-size: 0.76rem;
  font-family: inherit;
  cursor: pointer;
  z-index: 1;
  user-select: none;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  line-height: 1;
  max-width: calc(100% - 16px);
  box-sizing: border-box;
}

.cms-image-replace[hidden] {
  display: none !important;
}

.cms-image-replace:hover {
  background: #bbb;
  border-color: #000;
  color: #000;
}

.cms-image-clear {
  display: block;
  margin-top: 6px;
  font-size: 0.78rem;
  color: #c00;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  text-decoration: underline;
}

.cms-image-clear[hidden] {
  display: none !important;
}

.cms-image-clear:hover {
  color: #900;
}

/* ---- ステータス ---- */

.cms-status {
  margin-top: 10px;
  font-size: 0.82rem;
  min-height: 1.3em;
  color: var(--muted, #555);
}

/* ---- ボタン群 ---- */

.cms-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  position: relative;
}

.cms-btn-icon {
  position: absolute;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  color: #aaa;
}

.cms-btn-icon:hover {
  color: #c00;
}

.cms-btn-icon:active:not(:disabled) {
  transform: translate(1px, 1px);
}

.cms-btn-icon[hidden] {
  display: none !important;
}

.cms-btn-icon:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.cms-btn {
  padding: 6px 18px;
  border: 1px solid #888;
  background: #ddd;
  color: #000;
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  letter-spacing: 0.04em;
}

.cms-btn:hover {
  background: #bbb;
  border-color: #000;
}

.cms-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.cms-btn:active:not(:disabled) {
  transform: translate(1px, 1px);
}

.cms-btn-primary {
  background: #000;
  color: #fff;
  border-color: #000;
}

.cms-btn-primary:hover {
  background: #333;
}

.cms-btn-danger {
  color: #c00;
  border-color: #c00;
  background: #fff;
}

.cms-btn-danger:hover {
  background: #c00;
  color: #fff;
  border-color: #c00;
}

/* ---- 削除確認画面 ---- */

#cmsDeleteScreen p {
  font-size: 0.92rem;
  margin: 0 0 18px;
  line-height: 1.75;
}

/* ---- モーダル右下の編集ボタン行 ---- */

.modal-edit-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

/* ---- フィールドラベル（ページ編集時） ---- */

.cms-field-label {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted, #555);
  margin-top: 14px;
  margin-bottom: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid #ccc;
}

#cmsExtraField {
  margin-top: 10px;
}

/* ---- ローダー（modal-loader を流用） ---- */

#cmsLoader.modal-loader {
  border-radius: 0;
}

/* CMS保存中：左→右のウェーブを繰り返す */
@keyframes pixelCmsRoll {
  0%   { background: #ddd; }
  10%  { background: #000; }
  40%  { background: #000; }
  50%  { background: #ddd; }
  100% { background: #ddd; }
}

#cmsLoader .pixel-loader-bar span {
  animation-name: pixelCmsRoll;
  animation-duration: 1s;
  animation-timing-function: steps(1);
  animation-iteration-count: infinite;
  animation-fill-mode: none;
}

#cmsLoader .pixel-loader-bar span:nth-child(1) { animation-delay:   0ms; }
#cmsLoader .pixel-loader-bar span:nth-child(2) { animation-delay: 150ms; }
#cmsLoader .pixel-loader-bar span:nth-child(3) { animation-delay: 300ms; }
#cmsLoader .pixel-loader-bar span:nth-child(4) { animation-delay: 450ms; }
#cmsLoader .pixel-loader-bar span:nth-child(5) { animation-delay: 600ms; }
