/* 清翔会・正翔会 研修サイト — 歯科クリニック仕様 ダーク（YouTube風レイアウト） */
:root {
  --bg-primary: #0c1014;       /* 深いブルーチャコール */
  --bg-secondary: #161c23;     /* カード */
  --bg-elevated: #1a212a;      /* モーダル等 */
  --bg-hover: #232c37;
  --text-primary: #e9eef3;
  --text-secondary: #8c99a8;   /* クールグレー */
  --accent: #2dd4bf;           /* デンタル・ティール */
  --accent-2: #38bdf8;         /* クリニカル・スカイ */
  --accent-hover: #4fe0ce;
  --accent-ink: #04201d;       /* ティール背景上の文字 */
  --brand-grad: linear-gradient(135deg, #2dd4bf 0%, #38bdf8 100%);
  --red: #ff5470;              /* 強調（控えめなコーラル） */
  --green: #34d399;
  --border: rgba(255,255,255,.08);
  --border-strong: rgba(255,255,255,.14);
  --radius: 14px;
  --header-h: 60px;
  --shadow-card: 0 1px 2px rgba(0,0,0,.4);
  --shadow-hover: 0 10px 28px -8px rgba(0,0,0,.6), 0 0 0 1px rgba(45,212,191,.25);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1100px 520px at 80% -10%, rgba(56,189,248,.07), transparent 60%),
    radial-gradient(900px 480px at -5% 0%, rgba(45,212,191,.06), transparent 55%),
    var(--bg-primary);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: "Roboto", "Noto Sans JP", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }
::selection { background: rgba(45,212,191,.3); }
/* スクロールバー */
* { scrollbar-width: thin; scrollbar-color: #2c3744 transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #2c3744; border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #3a4654; background-clip: content-box; }

/* ---------- ヘッダー（すりガラス） ---------- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  background: rgba(12,16,20,.72);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.app-header .brand { display: flex; align-items: center; gap: 11px; font-weight: 700; letter-spacing: .2px; white-space: nowrap; }
/* ブランドマーク（ツース） */
.app-header .brand .logo {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--brand-grad); color: #03261f; font-size: 17px;
  box-shadow: 0 4px 14px -4px rgba(45,212,191,.6);
}
.app-header .brand small { color: var(--text-secondary); font-weight: 500; font-size: 12px; letter-spacing: .3px; }
.search-bar { flex: 1; max-width: 600px; display: flex; }
.search-bar input {
  flex: 1; height: 42px; padding: 0 18px;
  background: var(--bg-secondary); color: var(--text-primary);
  border: 1px solid var(--border); border-right: none;
  border-radius: 42px 0 0 42px; outline: none; font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
.search-bar input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(45,212,191,.15); }
.search-bar button {
  width: 60px; background: var(--bg-hover); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 0 42px 42px 0;
  transition: background .15s;
}
.search-bar button:hover { background: #2b3643; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-secondary); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand-grad); color: var(--accent-ink); font-weight: 700;
  display: grid; place-items: center;
  box-shadow: 0 2px 10px -2px rgba(45,212,191,.5);
}

/* ---------- レイアウト ---------- */
.layout { display: grid; grid-template-columns: 220px 1fr; }
.sidebar { padding: 12px 8px; border-right: 1px solid var(--border); min-height: calc(100vh - var(--header-h)); }
.sidebar a {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 12px; border-radius: 10px; color: var(--text-primary); font-size: 14px;
}
.sidebar a { transition: background .15s, color .15s; }
.sidebar a:hover { background: var(--bg-secondary); }
.sidebar a.active { background: linear-gradient(90deg, rgba(45,212,191,.16), rgba(56,189,248,.05)); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.sidebar a.active i { color: var(--accent); }
.content { padding: 22px 26px 64px; }

/* ---------- フィルターチップ ---------- */
.chips { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 20px; }
.chip {
  padding: 7px 15px; background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 999px; color: var(--text-primary); font-size: 13px; white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { border-color: var(--border-strong); }
.chip.active { background: var(--brand-grad); color: var(--accent-ink); border-color: transparent; font-weight: 600; }

/* ---------- セクション ---------- */
.section { margin-bottom: 38px; }
.section h2 {
  font-size: 18px; margin: 0 0 16px; display: flex; align-items: center; gap: 10px; letter-spacing: .2px;
}
.section h2::before { content: ""; width: 4px; height: 19px; border-radius: 3px; background: var(--brand-grad); }
.grid {
  display: grid; gap: 22px 16px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
/* PC: 常に4列（YouTube風の密度） */
@media (min-width: 900px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- 動画カード ---------- */
.card { cursor: pointer; }
.card .thumb {
  position: relative; aspect-ratio: 16/9; border-radius: var(--radius);
  overflow: hidden; background: var(--bg-secondary);
  box-shadow: var(--shadow-card);
  transition: transform .18s ease, box-shadow .18s ease;
}
.card:hover .thumb { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.card .thumb::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,.35), transparent 38%); pointer-events: none; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card .thumb .placeholder { width: 100%; height: 100%; display: grid; place-items: center; color: #3f4d5c; font-size: 34px; background: radial-gradient(circle at 50% 40%, #1d2630, #141a21); }
.card .thumb .dur {
  position: absolute; right: 7px; bottom: 7px; z-index: 1;
  background: rgba(0,0,0,.82); padding: 2px 6px; border-radius: 5px; font-size: 12px; font-weight: 500;
}
.card .thumb .type-badge {
  position: absolute; left: 7px; top: 7px; z-index: 1; padding: 3px 9px; border-radius: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .3px; color: var(--accent-ink);
  background: var(--brand-grad); box-shadow: 0 2px 8px -2px rgba(0,0,0,.5);
}
.card .meta { display: flex; gap: 10px; padding: 11px 2px 0; }
.card .meta .ttl { font-size: 14.5px; font-weight: 600; line-height: 1.4; max-height: 2.8em; overflow: hidden; }
.card .meta .sub { font-size: 12.5px; color: var(--text-secondary); margin-top: 5px; }
.card .progress { height: 3px; background: var(--bg-hover); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.card .progress > i { display: block; height: 100%; background: var(--brand-grad); }

/* ---------- 共通UI ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 17px; border: none; border-radius: 999px;
  background: var(--bg-hover); color: var(--text-primary); font-size: 14px; font-weight: 600;
  transition: filter .15s, transform .1s, box-shadow .15s, background .15s;
}
.btn.primary { background: var(--brand-grad); color: var(--accent-ink); box-shadow: 0 6px 18px -6px rgba(45,212,191,.7); }
.btn.danger { background: var(--red); color: #fff; }
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; border: 1px solid var(--border-strong); color: var(--text-primary); font-weight: 500; box-shadow: none; }
.btn.ghost:hover { background: var(--bg-secondary); }
.empty { color: var(--text-secondary); padding: 48px; text-align: center; }
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- フォーム ---------- */
label.field { display: block; margin-bottom: 14px; font-size: 13px; color: var(--text-secondary); }
label.field span { display: block; margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; padding: 11px 13px; background: var(--bg-secondary);
  color: var(--text-primary); border: 1px solid var(--border); border-radius: 10px; font-size: 14px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(45,212,191,.15); }
textarea.input { resize: vertical; min-height: 80px; }

/* ---------- テーブル ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
table.data th { color: var(--text-secondary); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: rgba(255,255,255,.03); }
table.data a { color: var(--accent); }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.on { background: rgba(52,211,153,.16); color: #5ee9b5; }
.pill.off { background: rgba(255,84,112,.16); color: #ff8aa0; }

/* 対象職種チップ（管理一覧でその場トグル。オン=対象 / オフ=除外） */
.jt-cell { display: flex; flex-wrap: wrap; gap: 5px; max-width: 240px; }
.jt-chip { border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; cursor: pointer; transition: all .12s; }
.jt-chip.on { background: rgba(52,211,153,.16); color: #5ee9b5; border-color: rgba(52,211,153,.4); }
.jt-chip.off { background: transparent; color: var(--text-secondary); border-color: var(--border); text-decoration: line-through; opacity: .65; }
.jt-chip:hover { filter: brightness(1.15); }

/* 一覧のタイトル インライン編集（編集できると分かるよう、常に枠を表示） */
.title-input { width: 100%; min-width: 180px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px; color: var(--text-primary); font: inherit; font-weight: 600; padding: 6px 8px; transition: border-color .12s, box-shadow .12s; }
.title-input:hover { border-color: var(--border-strong); }
.title-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(45,212,191,.15); }

/* 並べ替え可能な見出し */
th[data-sort] { cursor: pointer; user-select: none; white-space: nowrap; }
th[data-sort]:hover { color: var(--accent); }
.sort-ind { color: var(--accent); font-size: 11px; }

/* スタッフ動画カード: サムネ上の進捗バー＆視聴済みバッジ（YouTube風） */
.thumb-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,.25); }
.thumb-progress > i { display: block; height: 100%; background: var(--brand-grad); }
.watched-badge { position: absolute; left: 6px; top: 6px; display: inline-flex; align-items: center; gap: 4px; background: rgba(12,16,20,.82); color: #5ee9b5; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; }

/* ---------- モーダル ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(4,7,10,.66); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: none; place-items: center; z-index: 100; padding: 20px; }
.modal-bg.open { display: grid; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: 18px; width: min(680px, 100%); max-height: 90vh; overflow: auto; padding: 26px; box-shadow: 0 24px 60px -12px rgba(0,0,0,.7); }
.modal h3 { margin: 0 0 18px; font-size: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ---------- トースト ---------- */
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1f2730; color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 14px; border: 1px solid var(--border-strong); box-shadow: 0 8px 24px rgba(0,0,0,.5); animation: fade .2s ease; }
.toast.err { background: #3a1620; border-color: rgba(255,84,112,.5); }
.toast.ok { background: #11302a; border-color: rgba(52,211,153,.5); }

/* ---------- 症例発表 ---------- */
.embed-16x9 { position: relative; aspect-ratio: 16/9; background: #000; border-radius: var(--radius); overflow: hidden; }
.embed-16x9 iframe, .embed-16x9 video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.embed-doc { aspect-ratio: 16/10; background: var(--bg-secondary); border-radius: var(--radius); overflow: hidden; }
.embed-doc iframe { width: 100%; height: 100%; border: 0; }
.embed-img { width: 100%; border-radius: var(--radius); }
.attach-block { margin-bottom: 20px; }
.attach-block .cap { font-size: 13px; color: var(--text-secondary); margin: 8px 2px 0; display: flex; align-items: center; gap: 8px; }
.case-badge { display: inline-flex; align-items: center; gap: 5px; background: rgba(45,212,191,.12); color: var(--accent); border: 1px solid rgba(45,212,191,.22); border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; }
.kinds { display: flex; gap: 6px; flex-wrap: wrap; }

/* 添付フォームの行 */
.att-row { display: grid; grid-template-columns: 120px 1fr auto; gap: 10px; align-items: start; background: var(--bg-secondary); border: 1px solid var(--border); padding: 14px; border-radius: 12px; margin-bottom: 10px; }
.att-row .src-tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.att-row .src-tabs button { padding: 6px 11px; font-size: 12px; border-radius: 999px; background: var(--bg-hover); border: none; color: var(--text-primary); font-weight: 600; }
.att-row .src-tabs button.active { background: var(--brand-grad); color: var(--accent-ink); }
.att-row .drop { border: 1.5px dashed var(--border-strong); border-radius: 10px; padding: 16px; text-align: center; color: var(--text-secondary); font-size: 13px; cursor: pointer; transition: border-color .15s, color .15s, background .15s; }
.att-row .drop:hover { border-color: var(--accent); color: var(--text-primary); background: rgba(45,212,191,.04); }
.att-row .drop.has { border-style: solid; border-color: rgba(45,212,191,.4); color: var(--text-primary); }

/* ---------- 分析ダッシュボード ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 14px; margin-bottom: 24px; }
.kpi { background: linear-gradient(180deg, var(--bg-secondary), #131922); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brand-grad); }
.kpi .n { font-size: 28px; font-weight: 700; letter-spacing: .5px; }
.kpi .n small { font-size: 15px; color: var(--text-secondary); font-weight: 400; }
.kpi .l { color: var(--text-secondary); font-size: 13px; margin-top: 2px; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.chart-card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 14px; padding: 20px; }
.chart-card h3 { margin: 0 0 14px; font-size: 15px; }
.rate-bar { height: 10px; background: var(--bg-hover); border-radius: 6px; overflow: hidden; }
.rate-bar > i { display: block; height: 100%; background: var(--brand-grad); }
@media (max-width:1024px){ .chart-grid { grid-template-columns: 1fr; } }
@media (max-width:768px){ .att-row { grid-template-columns: 1fr; } }

/* ---------- レスポンシブ ---------- */
@media (max-width: 1024px) {
  .layout { grid-template-columns: 1fr; }
  /* サイドバーを消さず、上部の横スクロールナビに変える（スマホでも症例発表/続きから見る等に行ける） */
  .sidebar {
    display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch;
    min-height: 0; padding: 10px 12px;
    border-right: none; border-bottom: 1px solid var(--border);
    position: sticky; top: var(--header-h); background: var(--bg-primary); z-index: 5;
  }
  .sidebar a { white-space: nowrap; flex: 0 0 auto; gap: 8px; padding: 8px 12px; }
  .sidebar a.active { box-shadow: inset 0 -3px 0 var(--accent); }
}
@media (max-width: 768px) {
  /* スマホ: カードは2列でYouTubeらしく */
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px 10px; }
  .search-bar { max-width: none; }
  .app-header { gap: 8px; padding: 0 12px; }
  .app-header .brand small { display: none; }
  .app-header .brand { font-size: 15px; }
  .header-right { gap: 6px; }
  .user-chip { display: none; }          /* 名前は隠してアイコンだけ */
  .content { padding: 14px; }
  /* 列の多い管理テーブルは横スクロールで崩さない */
  table.data { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .toolbar { flex-wrap: wrap; }
  .stat-row { overflow-x: auto; }
}
@media (max-width: 380px) {
  .grid { grid-template-columns: 1fr 1fr; }
}
