/* ==========================================================================
   admin.css — kichifu/admi CMS 管理画面（依存ゼロ・モダン・高速）
   MINERVA の grey-skin/MDB は踏襲せず、可読性と余白を重視したクリーンUI
   ========================================================================== */
:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #fbfafc;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e6e7ee;
  --accent: #d6218a;          /* 落ち着いたマゼンタ（ブランド寄り・非ネオン） */
  --accent-soft: #fce7f3;
  --ok: #15a36e;
  --danger: #e0395e;
  --sidebar: #1d1b2e;         /* 深い紫グレー */
  --sidebar-soft: #2a2740;
  --sidebar-text: #cfc9e6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 8px 24px -12px rgba(16,24,40,.18);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea, button { font: inherit; }

/* ---------- layout shell ---------- */
.l-wrap { display: flex; min-height: 100vh; }
.l-sidebar {
  width: 248px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-text);
  position: fixed; inset: 0 auto 0 0; height: 100vh; overflow-y: auto; z-index: 40;
  transition: transform .25s ease;
}
.l-main { flex: 1; min-width: 0; margin-left: 248px; display: flex; flex-direction: column; }
.l-topbar {
  height: 60px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 20px; position: sticky; top: 0; z-index: 30;
}
.l-content { padding: 24px; flex: 1; }
.l-content-narrow { max-width: 920px; }

/* sidebar brand + nav */
.s-brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px; font-weight: 800; font-size: 18px; color: #fff; letter-spacing: .5px; }
.s-brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.s-group { padding: 10px 12px 4px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: #7d77a0; }
.s-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 18px; color: var(--sidebar-text);
  font-size: 14px; border-left: 3px solid transparent;
}
.s-link:hover { background: var(--sidebar-soft); text-decoration: none; color: #fff; }
.s-link.active { background: var(--sidebar-soft); color: #fff; border-left-color: var(--accent); font-weight: 600; }
.s-link .ic { width: 18px; text-align: center; opacity: .9; }

/* topbar bits */
.shop-switch { display: flex; align-items: center; gap: 8px; }
.shop-switch select { border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; background: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.btn-burger { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; width: 38px; height: 38px; cursor: pointer; }

/* ---------- cards / page head ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; margin: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat .n { font-size: 28px; font-weight: 800; }
.stat .l { color: var(--muted); font-size: 13px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border-radius: 9px; border: 1px solid var(--border); background: #fff; color: var(--text); cursor: pointer; font-weight: 600; transition: .15s; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.05); background: var(--accent); color:#fff; }
.btn-danger { color: var(--danger); border-color: #f0c2cd; }
.btn-sm { padding: 6px 11px; font-size: 13px; }

/* ---------- tables ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.search { flex: 1; min-width: 200px; max-width: 360px; display: flex; }
.search input { flex: 1; border: 1px solid var(--border); border-radius: 9px; padding: 9px 12px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab { padding: 7px 16px; border-radius: 999px; background: #fff; border: 1px solid var(--border); color: var(--muted); }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th, table.tbl td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.tbl thead th { background: var(--surface-2); font-size: 12px; color: var(--muted); position: sticky; top: 0; }
table.tbl tbody tr:hover { background: var(--surface-2); }
.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--accent-soft); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-on { background: #e7f7ef; color: var(--ok); }
.badge-off { background: #fdecef; color: var(--danger); }
.badge-new { background: var(--accent-soft); color: var(--accent); }

/* toggle (display on/off, no reload) */
.toggle { width: 42px; height: 24px; border-radius: 999px; border: none; background: #d4d6e0; position: relative; cursor: pointer; transition: .2s; }
.toggle.on { background: var(--ok); }
.toggle::after { content:""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .2s; }
.toggle.on::after { left: 21px; }

/* row action menu */
.rowmenu { position: relative; }
.rowmenu-btn { border: 1px solid var(--border); background:#fff; border-radius: 8px; width: 34px; height: 34px; cursor: pointer; }
.rowmenu-list { position: absolute; right: 0; top: 38px; background:#fff; border:1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); min-width: 140px; display: none; z-index: 1001; overflow: hidden; }
.rowmenu.open .rowmenu-list { display: block; }
.rowmenu-list a, .rowmenu-list button { display: flex; width: 100%; gap: 8px; padding: 9px 14px; background: none; border: none; text-align: left; cursor: pointer; color: var(--text); }
.rowmenu-list a:hover, .rowmenu-list button:hover { background: var(--surface-2); text-decoration: none; }
.rowmenu-list .danger { color: var(--danger); }

/* ---------- forms ---------- */
.form-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }   /* 中の長い1行（URL等）で枠ごと画面より広がり、ページが左右に動いていた（2026-11-04） */
.form-grid > * { min-width: 0; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.field .hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.field input[type=text], .field input[type=number], .field input[type=email], .field input[type=tel], .field input[type=url], .field input[type=search], .field input[type=date], .field input[type=time], .field input[type=datetime-local], .field input[type=password], .field select, .field textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.checks { display: flex; flex-wrap: wrap; gap: 12px; }
.check { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 9px; cursor: pointer; }
/* プレイ項目を区分ごとに行分け（基本 / 応用 / オプション）— 店長要望 2026-08-11 */
.play-group { margin-top: 12px; }
.play-group + .play-group { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.play-group-label { font-size: 12px; font-weight: 700; color: var(--muted, #7a8288); letter-spacing: .04em; margin-bottom: 7px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }

/* ---------- flash / pagination / login ---------- */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; }
.flash-ok { background: #e7f7ef; color: var(--ok); }
.flash-err { background: #fdecef; color: var(--danger); }
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.pager a, .pager span { padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border); background: #fff; }
.pager .cur { background: var(--accent); border-color: var(--accent); color: #fff; }
.muted { color: var(--muted); }

.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--sidebar); padding: 20px; }
.login-card { background: #fff; border-radius: 16px; padding: 34px 30px; width: 100%; max-width: 380px; box-shadow: 0 20px 60px -20px rgba(0,0,0,.5); }
.login-card h1 { font-size: 22px; margin: 0 0 4px; }
.login-card .sub { color: var(--muted); margin: 0 0 22px; font-size: 13px; }
.field-hint { color: var(--muted); font-size: 12px; margin: 4px 0 0; }

/* ---------- お知らせ: 女の子の登録画像からサムネ選択 ---------- */
.girl-img-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.girl-img-thumb { padding: 0; border: 2px solid var(--border); border-radius: 8px; background: none; cursor: pointer; overflow: hidden; line-height: 0; transition: .12s; }
.girl-img-thumb img { width: 48px; height: 64px; object-fit: cover; display: block; }
.girl-img-thumb:hover { border-color: var(--accent); }
.girl-img-thumb.sel { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
/* 紹介動画のタイル（お知らせのサムネ選択・店長要望 2026-08-20） */
.girl-img-thumb.is-video { position: relative; }
.girl-img-thumb.is-video video { width: 48px; height: 64px; object-fit: cover; display: block; background: #000; }
.girl-img-play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; text-shadow: 0 1px 4px rgba(0,0,0,.7); pointer-events: none; }

/* ---------- 店舗別掲載トグル（女性一覧・owner用）---------- */
.shop-toggles { display: flex; flex-direction: column; gap: 4px; }
.shop-toggle { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.shop-toggle-label { font-size: 12px; color: var(--muted); min-width: 48px; }
/* 編集フォーム用: チェックボックスをトグルスイッチ見た目に（フォーム送信はそのまま shops[]） */
.shop-toggle-cb { position: absolute; opacity: 0; width: 1px; height: 1px; }
.shop-toggle-cb + .toggle { cursor: pointer; }
.shop-toggle-cb:checked + .toggle { background: var(--ok); }
.shop-toggle-cb:checked + .toggle::after { left: 21px; }
.shop-toggle-cb:focus-visible + .toggle { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- body preview ---------- */
.body-preview {
  min-height: 200px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
  line-height: 1.7;
  overflow-wrap: break-word;
}
.body-preview img { max-width: 100%; height: auto; border-radius: 6px; }
/* 編集可能プレビュー（contenteditable）: クリックで直接編集、focusで枠を強調 */
.body-preview[contenteditable="true"] { cursor: text; }
.body-preview[contenteditable="true"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .l-sidebar { transform: translateX(-100%); }
  body.nav-open .l-sidebar { transform: translateX(0); }
  .l-main { margin-left: 0; }
  .btn-burger { display: inline-flex; align-items: center; justify-content: center; }
  .row2 { grid-template-columns: 1fr; }
  /* 名前と年齢・身長とバストのような短い欄は、狭くても2つ横に並べる（店長要望 2026-11-04）。
     画像の選択や長文の欄があるものだけ縦に積む */
  .row2:not(:has(input[type=file], textarea)) { grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px; }
}
/* iPhone の日付欄は幅を無視して枠からはみ出すので、見た目を外して枠いっぱいに収める（2026-11-04） */
.field input[type=date], .field input[type=time], .field input[type=datetime-local] { -webkit-appearance: none; appearance: none; display: block; min-width: 0; min-height: 44px; text-align: left; }
.field input[type=date]::-webkit-date-and-time-value { text-align: left; }

/* ---------- OPS の枠（iframe）の中: サイドバーを隠し、メニューは OPS 側に任せる（2026-11-03） ---------- */
body.embed .l-sidebar { display: none; }
body.embed .l-main { margin-left: 0; }
body.embed .btn-burger { display: none !important; }
body.embed .l-content { padding: 16px; }
.embed-only { display: none; }
body.embed .embed-only { display: inline; }
body.embed .embed-hide { display: none; }

/* ---------- スマホでは表を横スクロールさせず、1行＝1枚のカードにする（店長要望 2026-11-04） ----------
   _lib.php の layout_footer() が各セルに見出し名（data-label）を写し、表に .tbl-cards を付ける。
   1列目（名前など）は1行まるごと、残りは「見出し 値」を横に詰めて折り返す。
   カードにしない表は data-no-cards を付ける（10日先まで一覧のような日付の升目など） */
@media (max-width: 640px) {
  .table-wrap:has(> table.tbl-cards), div:has(> table.tbl-cards) { overflow-x: visible !important; }
  table.tbl-cards { min-width: 0 !important; width: 100% !important; }
  table.tbl-cards, table.tbl-cards > tbody { display: block; }
  table.tbl-cards > thead, table.tbl-cards > tbody > tr.tc-head { display: none; }
  table.tbl-cards > tbody > tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
    padding: 10px 12px; border-bottom: 1px solid var(--border); }
  table.tbl-cards > tbody > tr > td { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap;
    padding: 0 !important; border: none !important; white-space: normal !important; text-align: left !important;
    min-width: 0 !important; max-width: 100%; width: auto !important; }
  table.tbl-cards > tbody > tr > td[data-label]:not([data-label=""])::before {
    content: attr(data-label); font-size: 11px; color: var(--muted); font-weight: 600; white-space: nowrap; }
  table.tbl-cards > tbody > tr > td.tc-first { flex-basis: 100%; font-size: 15px; order: -1; }
  table.tbl-cards > tbody > tr > td.tc-first::before { display: none; }
  table.tbl-cards > tbody > tr > td.tc-full { flex-basis: 100%; }
  table.tbl-cards > tbody > tr > td[colspan] { flex-basis: 100%; justify-content: center; }
  table.tbl-cards > tbody > tr > td:empty { display: none; }
  table.tbl-cards td img.thumb { width: 44px; height: 44px; }
  /* 「⋯」メニューはカードの右上に固定（属性が無い子だけ回り込んでいた・2026-11-04） */
  table.tbl-cards > tbody > tr { position: relative; }
  table.tbl-cards > tbody > tr > td:has(> .rowmenu) { position: absolute; top: 8px; right: 10px; }
  table.tbl-cards > tbody > tr:has(> td > .rowmenu) > td.tc-first { padding-right: 48px !important; }
  table.tbl-cards > tbody > tr > td.tc-blank { display: none; }
}
/* スマホのヘッダー: 「店舗」「アドミ↗」などが1文字ずつ縦に折れていたので、折り返さず小さめに（2026-11-04） */
@media (max-width: 640px) {
  .l-topbar { flex-wrap: wrap; row-gap: 6px; height: auto; min-height: 56px; padding-top: 8px; padding-bottom: 8px; }
  .l-topbar .shop-switch, .l-topbar .shop-switch .muted, .topbar-right a, .topbar-right span { white-space: nowrap; }
  .topbar-right { gap: 10px; font-size: 13px; flex-wrap: wrap; justify-content: flex-end; }
}
/* iPhone ではファイル選択欄（「ファイルを選択 選択されていません」）が横に長く、キャスト編集の画像欄で
   ページが左右に動いていた（2026-11-04）。画像・動画・埋め込みも枠の幅までに抑える */
.l-content input[type=file] { max-width: 100%; min-width: 0; }
.l-content img, .l-content video, .l-content iframe { max-width: 100%; }
@media (max-width: 640px) {
  /* 念のための保険: 何かが少しはみ出しても、スマホでページごと横に動かないようにする */
  html, body { overflow-x: clip; }
}
/* スマホは外側の余白を詰めて、入力欄を横に並べられる幅を確保する（2026-11-04） */
@media (max-width: 640px) {
  .l-content, body.embed .l-content { padding: 12px; }
  .card-pad { padding: 14px; }
}

/* 並び替えのピル型ボタン（girls.php / schedules.php / news-edit.php / 共通。店長要望 2026-11-07「キャストを探す画面は全部同じ仕様で」） */
.sort-btns { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.sort-btns .btn { padding: 4px 10px; font-size: 12px; }

/* ==========================================================================
   システム風テーマ（body.theme-system）— OPS の 🖥️ と連動（店長要望 2026-11-07「フロントもシステム版に」）
   OPS（同じオリジン）が localStorage.opsTheme=system を持っていれば _lib.php が body に付ける。
   角丸ゼロ・影ゼロ・1px罫線、マゼンタ→スレート＋青のアクセント。読みやすさ（文字色・地色）はそのまま。
   ========================================================================== */
body.theme-system {
  --bg: #eef1f5; --surface: #fbfcfd; --surface-2: #f3f5f8; --text: #232b36; --muted: #4b5a69;   /* 純白・純黒は避ける（目の負担・2026-11-07） */
  --border: #cbd3dc; --accent: #2563eb; --accent-soft: #dbeafe;
  --sidebar: #1e293b; --sidebar-soft: #334155; --sidebar-text: #cbd5e1;
  --radius: 0; --shadow: none;
}
body.theme-system *, body.theme-system *::before, body.theme-system *::after { border-radius: 0 !important; }
body.theme-system * { box-shadow: none !important; text-shadow: none !important; }
body.theme-system .s-brand .dot { background: #60a5fa; }
body.theme-system .s-group { color: #94a3b8; }
body.theme-system .l-topbar { border-bottom: 1px solid var(--border); }
body.theme-system .btn { border-color: #94a3b8; }
body.theme-system .btn-primary { background: #2563eb; border-color: #2563eb; }
body.theme-system .btn-outline { border-color: #94a3b8; color: #1e293b; }
body.theme-system input, body.theme-system select, body.theme-system textarea { border-color: #94a3b8; }
body.theme-system table.tbl thead th { background: #e2e8f0; color: #334155; }
body.theme-system .badge-on { background: #dcfce7; color: #166534; }
body.theme-system .badge-off { background: #fee2e2; color: #991b1b; }
