/*
 * 体験コーナー(操作デモ)共通スタイル
 * - .demo-section / .demo / .demo-bar / .demo-stage / .demo-note : 枠組み
 * - .kd-*  : kintone 風の部品(アプリバー・ボタン・一覧テーブル・フォーム・カード・トースト・モーダル)
 * 各プラグインの demo.js は .kd-* を組み合わせて画面を作る。色は kintone の標準UIに寄せている。
 */
.demo-section { background: linear-gradient(180deg, #fbfbee 0%, #f7f7e4 100%); border-top: 1px solid #ecebc9; border-bottom: 1px solid #ecebc9; }
.demo-section .sec-lead { margin-bottom: 32px; }

.demo {
  position: relative; background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(26,43,74,.10); overflow: hidden; max-width: 960px; margin: 0 auto;
}
.demo-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--bg-soft); border-bottom: 1px solid var(--border); font-size: .82rem; color: var(--text-soft);
}
.demo-badge {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--ink);
  background: var(--accent); border-radius: 999px; padding: 2px 12px; font-size: .74rem; letter-spacing: .04em; white-space: nowrap;
}
.demo-badge::before { content: "👆"; font-size: .9em; }
.demo-hint { flex: 1; min-width: 200px; }
.demo-reset {
  border: 1px solid var(--border); background: #fff; color: var(--navy); border-radius: 999px;
  padding: 4px 14px; font-size: .78rem; font-weight: 700; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s;
}
.demo-reset:hover { background: #fff8d6; border-color: var(--accent); }
.demo-stage { position: relative; background: #fff; min-height: 240px; }
.demo-note { text-align: left; font-size: .75rem; color: var(--text-soft); opacity: .8; padding: 12px 16px 14px; border-top: 1px solid var(--border); background: #fff; margin: 0; }
.demo-steps { display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: center; margin: 0 auto 24px; padding: 0; list-style: none; font-size: .86rem; color: var(--text); max-width: 900px; }
.demo-steps li { display: inline-flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 6px 16px 6px 8px; }
.demo-steps li b { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--ink); font-size: .74rem; }

/* ---- kintone 風の部品 ---- */
.kd { font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif; font-size: 14px; line-height: 1.5; color: #333; }
.kd *, .kd *::before, .kd *::after { box-sizing: border-box; }
.kd-appbar {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: #f7f9fa; border-bottom: 1px solid #e3e7e8;
}
.kd-appbar .kd-appicon { width: 28px; height: 28px; border-radius: 6px; background: linear-gradient(135deg, #3498db, #2c81ba); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; flex: none; }
.kd-appbar .kd-appname { font-weight: 700; color: #333; font-size: 15px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kd-appbar .kd-tools { display: flex; gap: 6px; align-items: center; }
.kd-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 14px; background: #fff; border-bottom: 1px solid #e3e7e8; }
.kd-toolbar .kd-spacer { flex: 1; }

.kd-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 14px;
  border: 1px solid #e3e7e8; border-radius: 3px; background: #f7f9fa; color: #3498db; font-size: 13px; font-weight: 700;
  cursor: pointer; white-space: nowrap; transition: background .12s; font-family: inherit; line-height: 1;
}
.kd-btn:hover { background: #fff; border-color: #c8d3d8; }
.kd-btn:disabled { opacity: .5; cursor: not-allowed; }
.kd-btn-primary { background: #3498db; border-color: #3498db; color: #fff; }
.kd-btn-primary:hover { background: #2c81ba; border-color: #2c81ba; }
.kd-btn-sm { height: 26px; padding: 0 10px; font-size: 12px; }
.kd-btn-icon { width: 32px; padding: 0; font-size: 16px; color: #666; }
.kd-btn-danger { color: #d8574f; }
.kd-icon-plus::before { content: "+"; font-size: 18px; line-height: 1; margin-top: -2px; }

/* 一覧テーブル */
.kd-table-wrap { overflow: auto; }
.kd-table { width: 100%; border-collapse: collapse; background: #fff; font-size: 13px; }
.kd-table th, .kd-table td { border: 1px solid #e3e7e8; padding: 8px 10px; text-align: left; vertical-align: middle; white-space: nowrap; }
.kd-table th { background: #f7f9fa; color: #333; font-weight: 700; }
.kd-table th.kd-sortable { cursor: pointer; user-select: none; }
.kd-table th.kd-sortable:hover { background: #eef2f4; }
.kd-table th.kd-sort-asc::after { content: " ▲"; color: #3498db; font-size: 10px; }
.kd-table th.kd-sort-desc::after { content: " ▼"; color: #3498db; font-size: 10px; }
.kd-table tbody tr:hover { background: #f5faff; }
.kd-table tbody tr.kd-selected { background: #e8f3fc; }
.kd-table td.kd-num { text-align: right; font-variant-numeric: tabular-nums; }
.kd-table a.kd-link, .kd a.kd-link { color: #3498db; text-decoration: none; cursor: pointer; }
.kd a.kd-link:hover { text-decoration: underline; }
.kd-table input[type="checkbox"] { width: 15px; height: 15px; }

/* レコードフォーム(詳細・編集画面風) */
.kd-form { padding: 16px 18px; display: grid; gap: 14px 20px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.kd-form .kd-field.kd-wide { grid-column: 1 / -1; }
.kd-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kd-field > label, .kd-field .kd-label { font-size: 12px; color: #666; font-weight: 700; }
.kd-field .kd-req { color: #e74c3c; margin-left: 4px; font-weight: 400; }
.kd-field .kd-value { min-height: 24px; padding: 2px 0; border-bottom: 1px solid transparent; word-break: break-all; }
.kd-input, .kd-select, .kd-textarea {
  height: 34px; padding: 0 8px; border: 1px solid #e3e7e8; border-radius: 3px; background: #fff; font: inherit; font-size: 14px; color: #333;
  outline: none; width: 100%; box-shadow: inset 0 1px 2px rgba(0,0,0,.06);
}
.kd-textarea { height: auto; min-height: 80px; padding: 6px 8px; resize: vertical; }
.kd-input:focus, .kd-select:focus, .kd-textarea:focus { border-color: #3498db; box-shadow: 0 0 0 2px rgba(52,152,219,.2); }
.kd-input[readonly] { background: #f7f9fa; color: #666; }
.kd-input.kd-invalid, .kd-select.kd-invalid, .kd-textarea.kd-invalid { border-color: #e74c3c; background: #fff5f5; }
.kd-error { font-size: 12px; color: #e74c3c; }
.kd-help { font-size: 12px; color: #888; }
.kd-field-hidden { display: none; }
.kd-field-disabled .kd-input, .kd-field-disabled .kd-select { background: #f0f2f3; color: #999; pointer-events: none; }
.kd-check { display: inline-flex; align-items: center; gap: 6px; margin-right: 12px; cursor: pointer; font-size: 14px; }

/* チップ・バッジ */
.kd-chip { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 700; line-height: 1; white-space: nowrap; }
.kd-chip-red { background: #fde8e6; color: #c0392b; }
.kd-chip-orange { background: #fdf0dd; color: #b9770e; }
.kd-chip-yellow { background: #fbf8d6; color: #7f7f1f; }
.kd-chip-green { background: #e3f6e8; color: #1e8449; }
.kd-chip-blue { background: #e3f0fb; color: #1f6fa8; }
.kd-chip-purple { background: #efe6fb; color: #6c3fb0; }
.kd-chip-gray { background: #eceff1; color: #546e7a; }
.kd-avatar { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: #dfe6ec; color: #345; font-size: 11px; font-weight: 700; flex: none; }

/* カード(カンバン等) */
.kd-card {
  background: #fff; border: 1px solid #e3e7e8; border-radius: 6px; padding: 10px 12px; box-shadow: 0 1px 3px rgba(0,0,0,.06);
  cursor: grab; user-select: none; -webkit-user-select: none; touch-action: pan-y;
}
.kd-card:hover { border-color: #b8cbd8; box-shadow: 0 3px 10px rgba(0,0,0,.09); }
.kd-card .kd-card-title { font-weight: 700; color: #333; font-size: 13px; line-height: 1.4; }
.kd-card .kd-card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; font-size: 11px; color: #666; }
.kd-card.kd-overdue { background: #fff2f0; border-color: #f5b7b1; }

/* ドラッグ中 */
.kd-ghost {
  position: fixed; left: 0; top: 0; z-index: 3000; pointer-events: none; opacity: .92;
  transform-origin: 0 0; box-shadow: 0 14px 30px rgba(0,0,0,.25) !important; cursor: grabbing;
}
.kd-placeholder { border: 2px dashed #9fc5e8; border-radius: 6px; background: #eef6fd; }
body.kd-dragging, body.kd-dragging * { cursor: grabbing !important; }
.kd-drop-hover { outline: 2px dashed #3498db; outline-offset: -2px; background: #eef6fd; }
.kd-nest-hover { background: #d9ecfa !important; box-shadow: inset 0 0 0 2px #3498db; }

/* タブ */
.kd-tabs { display: flex; gap: 2px; padding: 8px 14px 0; background: #fff; border-bottom: 1px solid #e3e7e8; overflow-x: auto; }
.kd-tab {
  padding: 8px 14px; border: 1px solid transparent; border-bottom: none; border-radius: 6px 6px 0 0; color: #666; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap; background: none; font-family: inherit; margin-bottom: -1px;
}
.kd-tab:hover { color: #3498db; }
.kd-tab.kd-active { color: #333; background: #fff; border-color: #e3e7e8; border-bottom: 1px solid #fff; }

/* トースト・モーダル */
.kd-toast {
  position: absolute; left: 50%; bottom: 16px; transform: translate(-50%, 20px); z-index: 20; opacity: 0;
  background: rgba(30,40,50,.92); color: #fff; padding: 9px 18px; border-radius: 6px; font-size: 13px; pointer-events: none;
  transition: opacity .18s, transform .18s; max-width: 90%; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.kd-toast.kd-show { opacity: 1; transform: translate(-50%, 0); }
.kd-toast.kd-ok::before { content: "✓ "; color: #7ed49a; }
.kd-modal-bg { position: absolute; inset: 0; z-index: 15; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; padding: 16px; }
.kd-modal { background: #fff; border-radius: 6px; box-shadow: 0 16px 40px rgba(0,0,0,.3); width: 100%; max-width: 520px; max-height: 100%; overflow: auto; }
.kd-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid #e3e7e8; font-weight: 700; font-size: 15px; }
.kd-modal-body { padding: 16px; }
.kd-modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid #e3e7e8; background: #f7f9fa; }

/* 誘導ダイアログ(体験できない機能に触れたとき) */
.demo-gate { position: fixed; inset: 0; z-index: 1200; background: rgba(11,20,36,.7); display: flex; align-items: center; justify-content: center; padding: 20px; opacity: 0; transition: opacity .18s; }
.demo-gate.is-open { opacity: 1; }
.demo-gate-box { background: #fff; border-radius: 16px; max-width: 460px; width: 100%; padding: 32px 28px 26px; text-align: center; box-shadow: 0 24px 80px rgba(0,0,0,.4); transform: translateY(8px); transition: transform .18s; }
.demo-gate.is-open .demo-gate-box { transform: none; }
.demo-gate-ic { font-size: 2rem; line-height: 1; margin-bottom: 10px; }
.demo-gate h3 { font-size: 1.15rem; color: var(--navy); margin: 0 0 10px; font-weight: 900; }
.demo-gate p { font-size: .9rem; color: var(--text-soft); margin: 0 0 22px; line-height: 1.8; }
.demo-gate p b { color: var(--navy); }
.demo-gate .btn { display: block; width: 100%; padding: 14px 20px; }
.demo-gate .demo-gate-back { display: inline-block; margin-top: 14px; background: none; border: none; color: var(--text-soft); font-size: .84rem; cursor: pointer; text-decoration: underline; font-family: inherit; }
.demo-gate .demo-gate-back:hover { color: var(--navy); }

/* スマホ */
@media (max-width: 640px) {
  .demo-bar { padding: 8px 12px; gap: 8px; }
  .demo-hint { flex-basis: 100%; order: 3; }
  .kd { font-size: 13px; }
  .kd-form { grid-template-columns: 1fr; padding: 12px; }
}
