/* 管理画面 (/admin) スタイル — 公開サイトとは独立 */

:root {
  --a-bg: #f6f7f9;
  --a-card: #fff;
  --a-text: #1f2937;
  --a-mute: #6b7280;
  --a-border: #e5e7eb;
  --a-primary: #E89028;
  --a-primary-dark: #c97718;
  --a-success: #10b981;
  --a-danger: #ef4444;
  --a-radius: 8px;
  --a-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; }
body.admin {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Sans", "Yu Gothic", sans-serif;
  background: var(--a-bg);
  color: var(--a-text);
  line-height: 1.6;
}

a { color: var(--a-primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 旧トップヘッダー (新サイドバーレイアウトでは未使用、互換のため残置) */
.admin-header { display: none; }

.flash {
  padding: 12px 16px;
  border-radius: var(--a-radius);
  margin-bottom: 16px;
  font-size: 14px;
}
.flash-notice { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.flash-alert  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* === ヘッダー === */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-head h1 {
  font-size: 22px;
  margin: 0;
  font-weight: 700;
}
.page-head .right { display: flex; gap: 8px; }

/* === カード === */
.card {
  background: var(--a-card);
  border-radius: var(--a-radius);
  box-shadow: var(--a-shadow);
  padding: 20px;
  border: 1px solid var(--a-border);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--a-card);
  border: 1px solid var(--a-border);
  border-radius: var(--a-radius);
  padding: 16px 20px;
}
.stat-card .label { color: var(--a-mute); font-size: 12px; font-weight: 600; }
.stat-card .value { font-size: 28px; font-weight: 700; margin-top: 4px; }

/* === ボタン === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--a-border);
  background: #fff;
  color: var(--a-text);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.05s;
}
.btn:hover { background: #f3f4f6; text-decoration: none; border-color: #9ca3af; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--a-primary); color: #fff; border-color: var(--a-primary); box-shadow: 0 1px 2px rgba(232, 144, 40, 0.15); }
.btn-primary:hover { background: var(--a-primary-dark); border-color: var(--a-primary-dark); color: #fff; box-shadow: 0 2px 4px rgba(232, 144, 40, 0.25); }
.btn-success { background: var(--a-success); color: #fff; border-color: var(--a-success); }
.btn-danger { background: #fff; color: var(--a-danger); border-color: var(--a-danger); }
.btn-danger:hover { background: var(--a-danger); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* === テーブル === */
.table {
  width: 100%;
  background: var(--a-card);
  border: 1px solid var(--a-border);
  border-radius: var(--a-radius);
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}
.table th, .table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--a-border);
  font-size: 14px;
}
.table th {
  background: #f9fafb;
  color: var(--a-mute);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f9fafb; }

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.status-draft     { background: #f3f4f6; color: #6b7280; }
.status-reviewing { background: #fef3c7; color: #92400e; }
.status-published { background: #d1fae5; color: #065f46; }

/* === フォーム === */
.form-grid {
  display: grid;
  gap: 16px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--a-mute);
}
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="url"],
.field input[type="tel"],
.field input[type="search"],
.field input[type="date"],
.field input[type="datetime-local"],
.field select,
.field textarea,
.toolbar input[type="text"],
.toolbar input[type="search"],
.toolbar input[type="email"],
.toolbar input[type="number"],
.toolbar select {
  padding: 9px 12px;
  border: 1px solid var(--a-border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--a-text);
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field textarea { resize: vertical; min-height: 80px; line-height: 1.6; }

.field input:hover:not(:focus):not(:disabled),
.field select:hover:not(:focus):not(:disabled),
.field textarea:hover:not(:focus):not(:disabled),
.toolbar input:hover:not(:focus):not(:disabled),
.toolbar select:hover:not(:focus):not(:disabled) {
  border-color: #9ca3af;
}
.field input:focus,
.field select:focus,
.field textarea:focus,
.toolbar input:focus,
.toolbar select:focus {
  outline: none;
  border-color: var(--a-primary);
  box-shadow: 0 0 0 3px rgba(232, 144, 40, 0.15);
}
.field input::placeholder,
.toolbar input::placeholder { color: #9ca3af; }
.field input:disabled,
.field select:disabled,
.field textarea:disabled {
  background: #f3f4f6;
  color: var(--a-mute);
  cursor: not-allowed;
}

/* select に custom dropdown arrow を付ける */
.field select,
.toolbar select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%236b7280' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M2.5 4.5l3.5 3.5 3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  padding-right: 32px;
  cursor: pointer;
}
.field select:focus,
.toolbar select:focus {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%23E89028' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M2.5 4.5l3.5 3.5 3.5-3.5'/%3E%3C/svg%3E");
}

/* checkbox / radio の微調整 */
.field input[type="checkbox"],
.field input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--a-primary);
  cursor: pointer;
}
.field label.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: var(--a-text);
  cursor: pointer;
}

/* toolbar 内のフォーム要素は inline */
.toolbar input,
.toolbar select { width: auto; min-width: 180px; }

.field .help { font-size: 12px; color: var(--a-mute); }
.field .error { font-size: 12px; color: var(--a-danger); }

/* 文字数カウンター */
.char-counter {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: #f3f4f6;
  color: #6b7280;
}
[data-char-counter-state="ideal"] .char-counter { background: #d1fae5; color: #065f46; }
[data-char-counter-state="too-short"] .char-counter { background: #fef3c7; color: #92400e; }
[data-char-counter-state="too-long"] .char-counter { background: #fee2e2; color: #991b1b; }
[data-char-counter-state="empty"] .char-counter { background: #f3f4f6; color: #6b7280; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 720px) { .field-row { grid-template-columns: 1fr; } }

.errors {
  background: #fee2e2;
  color: #991b1b;
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13px;
}
.errors ul { margin: 4px 0 0; padding-left: 20px; }

/* === Editor.js コンテナ === */
.editor-container {
  background: #fff;
  border: 1px solid var(--a-border);
  border-radius: var(--a-radius);
  padding: 32px 40px;
  min-height: 500px;
}
.editor-container .ce-block__content,
.editor-container .ce-toolbar__content {
  max-width: 100% !important;
}

/* レイアウト */
.form-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}
.form-side .card { margin-bottom: 16px; }
@media (max-width: 960px) {
  .form-layout { grid-template-columns: 1fr; }
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.muted { color: var(--a-mute); font-size: 13px; }

/* ───────────────────────────────────────
   サイドバーレイアウト (3セクション)
─────────────────────────────────────── */
.admin-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.admin-sidebar {
  background: #1f2937;
  color: #d1d5db;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.admin-brand-block {
  padding: 18px 18px 14px;
  border-bottom: 1px solid #374151;
}
.admin-brand {
  display: flex;
  flex-direction: column;
  text-decoration: none;
}
.admin-brand:hover { text-decoration: none; opacity: 0.85; }
.admin-brand-name { color: #fff; font-weight: 700; font-size: 15px; }
.admin-brand-sub  { color: var(--a-primary); font-size: 11px; margin-top: 2px; }

.admin-sidenav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidenav-item {
  display: block;
  padding: 8px 12px;
  border-radius: 6px;
  color: #d1d5db;
  font-size: 13px;
  text-decoration: none;
  transition: background 0.1s;
}
.sidenav-item:hover { background: #374151; color: #fff; text-decoration: none; }
.sidenav-item.is-active { background: var(--a-primary); color: #fff; font-weight: 600; }
.sidenav-item.is-active:hover { background: var(--a-primary-dark); }

.sidenav-section {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidenav-section-title {
  padding: 6px 12px;
  color: #9ca3af;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.admin-sidenav .sidenav-section .sidenav-item {
  padding-left: 28px;
  font-size: 13px;
}

/* サブセクション (例: DB管理 > 商品マスタ / 施設マスタ) */
.sidenav-subsection {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 8px;
  border-left: 2px solid #374151;
  margin-left: 12px;
}
.sidenav-subsection-title {
  padding: 4px 8px 2px;
  color: #d1d5db;
  font-size: 11px;
  font-weight: 600;
}
.admin-sidenav .sidenav-section .sidenav-subsection .sidenav-item {
  padding-left: 16px;
}

/* 準備中アイテム (リンク不可) */
.sidenav-item.is-coming {
  color: #6b7280;
  cursor: default;
  font-style: italic;
}
.sidenav-item.is-coming:hover {
  background: transparent;
  color: #6b7280;
}
.sidenav-item.is-coming small {
  background: #4b5563;
  color: #9ca3af;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-style: normal;
  margin-left: 4px;
}

.admin-sidebar.is-collapsed { display: none; }

/* メイン */
.admin-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.admin-topbar {
  background: #fff;
  border-bottom: 1px solid var(--a-border);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.admin-sidebar-toggle {
  background: transparent;
  border: 1px solid var(--a-border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 16px;
  cursor: pointer;
  display: none;
}
.admin-topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.admin-topbar-link { color: var(--a-mute); }
.admin-current-user { color: var(--a-text); font-weight: 500; }

.admin-content {
  padding: 24px 32px;
  width: 100%;
  flex: 1;
}

/* 記事エディタなど、特定コンテンツのみ読みやすさのため幅制限 */
.admin-content .editor-container,
.admin-content .form-layout {
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

/* レスポンシブ */
@media (max-width: 768px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 240px;
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 0.2s;
  }
  .admin-sidebar.is-open { transform: translateX(0); }
  .admin-sidebar-toggle { display: inline-block; }
}

/* ───────────────────────────────────────
   ログイン画面 (current_admin なし)
─────────────────────────────────────── */
.admin-auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--a-bg);
}
.admin-login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: var(--a-radius);
  box-shadow: var(--a-shadow);
  padding: 32px;
}
.admin-login-card h1 {
  font-size: 18px;
  margin: 0 0 4px;
}
.admin-login-card .lead {
  color: var(--a-mute);
  font-size: 13px;
  margin: 0 0 24px;
}

/* バッジ・補助 */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: #e5e7eb;
  color: #374151;
}
.badge-yes { background: #d1fae5; color: #065f46; }
.badge-no  { background: #fee2e2; color: #991b1b; }
.badge-success { background: #d1fae5; color: #065f46; }

/* ─── credit-picker (記事編集の 執筆者/監修者/執筆犬) ─── */
.credit-picker {
  border: 1px solid var(--a-border);
  border-radius: var(--a-radius);
  padding: 16px;
  margin-bottom: 16px;
  background: #fafbfc;
}
.credit-picker:last-child { margin-bottom: 0; }
.credit-picker-head { margin-bottom: 12px; }
.credit-picker-title {
  font-size: 14px;
  font-weight: 800;
  margin: 0 0 4px;
  color: var(--a-text);
}
.credit-picker-help {
  font-size: 12px;
  color: var(--a-mute);
  margin: 0;
}
.credit-picker-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.credit-picker-select {
  flex: 1 1 200px;
  min-width: 0;
}
.credit-picker-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.credit-picker-list--pets {
  flex-direction: row;
  flex-wrap: wrap;
}
.credit-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 8px;
  background: #fff;
  border: 1px solid var(--a-border);
  border-radius: 10px;
}
.credit-picker-item--pet {
  flex: 0 0 auto;
  padding: 8px 12px 8px 8px;
  background: linear-gradient(180deg, #fef3e8 0%, #fff 100%);
  border-color: #f5d6b2;
}
.credit-picker-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: #e5e7eb;
}
.credit-picker-avatar--pet {
  width: 36px; height: 36px;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.credit-picker-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.credit-picker-remove {
  background: transparent;
  border: 1px solid var(--a-border);
  border-radius: 6px;
  width: 26px; height: 26px;
  cursor: pointer;
  color: var(--a-mute);
  font-size: 12px;
  line-height: 1;
  padding: 0;
}
.credit-picker-remove:hover {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}
.credit-picker-empty {
  font-size: 12px;
  margin: 4px 0 0;
}

