/* =========================================================
   Pマーク学習サイト CSS
   - Layout:  l-*
   - Component: c-*
   - Page: p-*
   - Utility: u-*
   - State: is-*
   既存画面互換のため、.card / .grid / .actions なども維持します。
   ========================================================= */

/* 1. Design tokens */
:root {
  --bg: #f7f8fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-soft: #dbeafe;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warning-soft: #fef3c7;
  --surface-subtle: #f9fafb;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --radius-md: 10px;
  --radius-lg: 14px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 20px;
  --space-2xl: 28px;
}

/* 2. Base */
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }

/* 3. Layout */
.container,
.l-container { max-width: 1080px; margin: 0 auto; padding: var(--space-xl); }
.l-page { min-height: 100vh; display: flex; flex-direction: column; }
.site-header,
.l-site-header { background: var(--card); border-bottom: 1px solid var(--line); }
.header-inner,
.l-header-inner { display: flex; justify-content: space-between; align-items: center; gap: var(--space-lg); }
.l-main { flex: 1 0 auto; width: 100%; }
.site-footer,
.l-site-footer { color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); background: var(--card); margin-top: var(--space-2xl); }
.l-footer-inner { display: flex; justify-content: space-between; gap: var(--space-md); flex-wrap: wrap; }

/* 4. Header / Global navigation */
.brand,
.c-site-brand { font-weight: 700; font-size: 18px; color: var(--text); }
.nav,
.c-global-nav { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.c-global-nav__link { color: var(--text); font-weight: 600; }
.c-global-nav__link:hover { color: var(--primary); }

/* 5. Generic components */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-xl); margin: 18px 0; box-shadow: var(--shadow-sm); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-lg); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: var(--space-lg); }
label { display: block; font-weight: 600; margin: 12px 0 6px; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-md); font: inherit; background: #fff; }
button, .button { display: inline-block; border: 0; border-radius: var(--radius-md); background: var(--primary); color: white; padding: 10px 16px; font-weight: 700; cursor: pointer; }
button:hover, .button:hover { text-decoration: none; filter: brightness(.97); }
.button.secondary { background: #4b5563; }
.button.danger { background: var(--danger); }

/* 6. Tables */
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { border-bottom: 1px solid var(--line); padding: 10px; text-align: left; vertical-align: top; }
th { background: #f3f4f6; }
.c-table-card { overflow-x: auto; }

/* 7. Badges / Flash messages */
.badge { display: inline-block; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 700; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.ng { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--primary-soft); color: var(--primary-dark); }
.flash,
.c-flash { padding: 12px 14px; border-radius: var(--radius-md); margin: 16px 0; background: #eef2ff; }
.flash.error,
.c-flash--error { background: var(--danger-soft); color: var(--danger); }
.flash.success,
.c-flash--success { background: var(--ok-soft); color: var(--ok); }

/* 8. Training / exam compatibility */
.question { border-top: 1px solid var(--line); padding-top: 18px; margin-top: 18px; }
.choice { display: block; font-weight: 400; margin: 8px 0; }
.choice input { width: auto; margin-right: 8px; }

/* 9. Admin menu */
.admin-menu,
.c-admin-menu { margin-top: var(--space-xl); }
.c-admin-menu__header { margin-bottom: var(--space-lg); }
.c-admin-menu__title { display: block; font-size: 18px; }
.c-admin-menu__lead { margin: 6px 0 0; }
.admin-menu-grid,
.c-admin-menu__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-top: 14px; }
.admin-menu-section,
.c-admin-menu__section { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px; background: var(--surface-subtle); }
.c-admin-menu__section--primary { border-color: #bfdbfe; background: #eff6ff; }
.c-admin-menu__section--sub { background: #ffffff; }
.c-admin-menu__section--system { background: #f3f4f6; }
.admin-menu-section h2,
.c-admin-menu__section-title { font-size: 16px; margin: 0 0 10px; }
.c-admin-menu__links { display: grid; gap: 8px; }
.c-admin-menu__link { display: block; border: 1px solid var(--line); border-radius: var(--radius-md); padding: 10px 12px; background: var(--card); color: var(--text); }
.c-admin-menu__link:hover { text-decoration: none; border-color: #bfdbfe; background: #eff6ff; }
.c-admin-menu__link.is-active { border-color: var(--primary); background: var(--primary-soft); }
.c-admin-menu__link-label { display: block; font-weight: 700; }
.c-admin-menu__link-desc { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; line-height: 1.4; }

/* 10. Admin dashboard / operation flow */
.p-admin-dashboard__header { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-lg); margin-bottom: var(--space-lg); }
.c-page-kicker { color: var(--primary-dark); font-size: 12px; font-weight: 700; letter-spacing: .04em; margin: 0 0 4px; }
.c-section-heading { margin-bottom: var(--space-md); }
.c-section-heading h2 { margin: 0 0 4px; }
.c-operation-panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-xl); margin: 18px 0; box-shadow: var(--shadow-sm); }
.c-operation-panel--primary { border-color: #bfdbfe; background: linear-gradient(180deg, #eff6ff 0%, #ffffff 100%); }
.c-action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-md); }
.c-action-grid--main { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.c-action-card { display: block; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-lg); background: var(--card); color: var(--text); }
.c-action-card:hover { text-decoration: none; border-color: #bfdbfe; background: #eff6ff; }
.c-action-card--primary { border-color: #93c5fd; }
.c-action-card__title { display: block; font-size: 17px; font-weight: 700; }
.c-action-card__desc { display: block; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.c-metric-grid { margin-top: var(--space-md); }
.c-metric-card h3 { margin-top: 0; font-size: 15px; }
.c-metric-card__value { font-size: 32px; font-weight: 700; margin: 8px 0 0; }
.c-dashboard-status-grid { margin: 18px 0; }
.c-notice-card { background: var(--warning-soft); }

/* 11. Logs */
.c-log-detail { white-space: pre-wrap; max-width: 420px; margin: 0; font-size: 12px; }

/* 12. Utilities */
.muted,
.u-text-muted { color: var(--muted); }
.u-text-small { font-size: 12px; }
.u-mt-0 { margin-top: 0; }
.u-mb-0 { margin-bottom: 0; }

/* 13. Responsive */
@media (max-width: 720px) {
  .container,
  .l-container { padding: 14px; }
  .header-inner,
  .l-header-inner { align-items: flex-start; flex-direction: column; }
  .nav,
  .c-global-nav { gap: 10px; }
  .p-admin-dashboard__header { display: block; }
  .c-action-card__title { font-size: 16px; }
  .c-metric-card__value { font-size: 28px; }
}

/* 14. Button consistency / inline forms */
.c-button-row { align-items: center; }
.c-inline-form { display: inline-flex; margin: 0; }
button.c-button,
.button.c-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  font-size: 15px;
  line-height: 1.2;
  text-align: center;
}
.c-learning-material-actions .c-inline-form { margin: 0; }
.c-learning-material-actions__confirm-button { min-width: 12em; }
.c-page-bottom-actions { margin-top: var(--space-xl); }

/* 15. Account role separation */
.c-account-note { border-color: #bfdbfe; background: #eff6ff; }
.c-role-badge-note { display: block; margin-top: 2px; }

/* 教材配信フォーム */
.c-form-section { margin: 22px 0; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius-md); background: #fbfdff; }
.c-form-section h3 { margin-top: 0; }

/* 16. Question list / pagination / web editing */
.c-filter-form .grid { align-items: end; }
.c-list-header { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-md); margin-bottom: var(--space-md); }
.c-list-header h2 { margin: 0 0 4px; }
.c-pagination-summary { color: var(--muted); font-size: 13px; white-space: nowrap; }
.c-question-list__text { max-width: 420px; }
.c-table-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
button.c-button--small,
.button.c-button--small { min-height: 34px; padding: 7px 10px; font-size: 13px; }
.c-pagination { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: var(--space-lg); }
.c-pagination__link { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; min-height: 36px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--card); color: var(--text); font-weight: 700; }
.c-pagination__link:hover { text-decoration: none; border-color: #bfdbfe; background: #eff6ff; }
.c-pagination__link.is-active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); }
.is-disabled { opacity: .45; pointer-events: none; }

/* 17. Practice mode */
.p-practice__header { margin-bottom: var(--space-lg); }
.c-practice-dashboard-card { border-color: #bfdbfe; background: linear-gradient(180deg, #eff6ff 0%, #ffffff 100%); }
.c-practice-start .grid { align-items: end; }
.c-practice-progress { padding: var(--space-lg); }
.c-practice-progress__bar { height: 10px; border-radius: 999px; background: #e5e7eb; overflow: hidden; }
.c-practice-progress__bar span { display: block; height: 100%; background: var(--primary); border-radius: inherit; }
.c-practice-question__text { font-size: 17px; line-height: 1.8; }
.c-practice-choice { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 10px 12px; background: var(--card); }
.c-practice-choice:hover { border-color: #bfdbfe; background: #eff6ff; }
.c-practice-choice input { margin-right: 10px; }
.c-practice-answer { margin: var(--space-lg) 0; padding: var(--space-lg); border-radius: var(--radius-md); border: 1px solid var(--line); }
.c-practice-answer.is-correct { background: var(--ok-soft); border-color: #bbf7d0; }
.c-practice-answer.is-wrong { background: var(--danger-soft); border-color: #fecaca; }
.c-practice-result__score { font-size: 24px; font-weight: 700; margin: 8px 0; }

/* Practice mode button variants */
button.c-button,
.button.c-button {
  border: 1px solid transparent;
}
button.c-button--primary,
.button.c-button--primary {
  background: var(--primary);
  color: #ffffff;
}
button.c-button--secondary,
.button.c-button--secondary,
button.secondary.c-button,
.button.secondary.c-button {
  background: #4b5563;
  color: #ffffff;
}
button.c-button--outline,
.button.c-button--outline {
  background: var(--card);
  color: var(--text);
  border-color: var(--line);
}
button.c-button--outline:hover,
.button.c-button--outline:hover {
  border-color: #bfdbfe;
  background: #eff6ff;
}
