/* file path: public/style.css */

:root {
  --bg: #f6f7fb;
  --bg-soft: #fbfbfe;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-soft: rgba(79, 70, 229, 0.08);
  --success: #059669;
  --success-soft: rgba(16, 185, 129, 0.12);
  --warning: #d97706;
  --warning-soft: rgba(245, 158, 11, 0.14);
  --danger: #dc2626;
  --danger-soft: rgba(239, 68, 68, 0.12);
  --shadow: 0 16px 40px rgba(17, 24, 39, 0.08);

  --chat-user-bg: #4f46e5;
  --chat-user-fg: #ffffff;
  --chat-bot-bg: #ffffff;
  --chat-bot-fg: #111827;
  --chat-system-bg: rgba(17, 24, 39, 0.04);
  --chat-system-fg: #374151;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(99, 102, 241, 0.14), transparent 28%),
    linear-gradient(180deg, #eef2ff 0%, var(--bg) 34%, #ffffff 100%);
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial,
    "Noto Sans JP",
    sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--brand);
  text-decoration: none;
  transition: opacity 120ms ease;
}

a:hover {
  text-decoration: underline;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

::selection {
  background: rgba(79, 70, 229, 0.16);
}

/* =====================
   Layout / Common
===================== */

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px;
}

.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 0 22px;
}

.nav > div:first-child {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.nav .right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.nav .right a {
  font-weight: 700;
  color: var(--text);
  opacity: 0.86;
}

.nav .right a:hover {
  opacity: 1;
  text-decoration: none;
}

.card {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(229, 231, 235, 0.92);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.card + .card {
  margin-top: 18px;
}

.card h1,
.card h2,
.card h3,
.card h4 {
  margin-top: 0;
  letter-spacing: -0.02em;
}

.card h2 {
  margin-bottom: 10px;
}

.card p {
  margin: 0 0 14px;
  color: var(--muted);
}

.row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.row > * {
  flex: 1;
}

.stack {
  display: grid;
  gap: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}

.section {
  margin-top: 18px;
}

.section-title {
  margin: 0 0 14px;
  font-size: 28px;
  line-height: 1.15;
}

.section-lead {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.8;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.center {
  text-align: center;
}

.hidden {
  display: none !important;
}

/* =====================
   Buttons / Inputs
===================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  line-height: 1;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    background 120ms ease,
    border-color 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(17, 24, 39, 0.08);
  text-decoration: none;
}

.btn:active {
  transform: translateY(0);
}

.btn.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  border-color: transparent;
}

.btn.primary:hover {
  box-shadow: 0 16px 28px rgba(79, 70, 229, 0.24);
}

.btn.subtle {
  background: rgba(79, 70, 229, 0.08);
  border-color: rgba(79, 70, 229, 0.16);
  color: var(--brand);
}

.btn.danger {
  background: #fff;
  border-color: rgba(220, 38, 38, 0.18);
  color: var(--danger);
}

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

input,
textarea,
select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 15px;
  background: #fff;
  color: var(--text);
  transition:
    border-color 120ms ease,
    box-shadow 120ms ease,
    background 120ms ease;
}

input::placeholder,
textarea::placeholder {
  color: #9ca3af;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(79, 70, 229, 0.45);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

label {
  display: block;
  margin: 14px 0 6px;
  font-weight: 800;
  color: var(--text);
}

/* =====================
   Badges / Alerts
===================== */

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 900;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.badge-open {
  background: rgba(79, 70, 229, 0.10);
  border-color: rgba(79, 70, 229, 0.22);
}

.badge-progress {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.25);
}

.badge-closed {
  background: rgba(16, 185, 129, 0.14);
  border-color: rgba(16, 185, 129, 0.25);
}

.badge-sub {
  background: rgba(17, 24, 39, 0.06);
}

.badge-camp {
  background: rgba(79, 70, 229, 0.08);
}

.alert {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid transparent;
  font-weight: 700;
}

.alert.info {
  background: rgba(79, 70, 229, 0.08);
  border-color: rgba(79, 70, 229, 0.16);
}

.alert.success {
  background: var(--success-soft);
  border-color: rgba(16, 185, 129, 0.22);
  color: #065f46;
}

.alert.warning {
  background: var(--warning-soft);
  border-color: rgba(245, 158, 11, 0.22);
  color: #92400e;
}

.alert.error {
  background: var(--danger-soft);
  border-color: rgba(239, 68, 68, 0.22);
  color: #991b1b;
}

/* =====================
   KPI / Stat cards
===================== */

.stat-card,
.metric-card {
  position: relative;
  overflow: hidden;
}

.stat-card::before,
.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
}

.stat-value,
.metric-value {
  font-size: 32px;
  line-height: 1;
  font-weight: 900;
  margin-bottom: 8px;
  letter-spacing: -0.03em;
}

.stat-label,
.metric-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

/* =====================
   List / Detail helpers
===================== */

.list {
  display: grid;
  gap: 14px;
}

.item {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(17, 24, 39, 0.02);
}

.item-title {
  margin: 0 0 8px;
  font-size: 20px;
}

.item-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.detail-grid {
  display: grid;
  gap: 10px;
}

.detail-row {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.detail-row:first-child {
  border-top: 0;
  padding-top: 0;
}

/* =====================
   Subscribe UI
===================== */

.subscribe-card {
  position: relative;
}

.subscribe-checkbox {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.subscribe-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(79, 70, 229, 0.04);
  cursor: pointer;
  user-select: none;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    background 120ms ease;
}

.subscribe-label:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(17, 24, 39, 0.08);
  background: rgba(79, 70, 229, 0.06);
}

.subscribe-icon {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  border: 2px solid rgba(79, 70, 229, 0.35);
  background: #fff;
  position: relative;
  flex: 0 0 auto;
  margin-top: 2px;
}

.subscribe-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.subscribe-title {
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}

.subscribe-desc {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.subscribe-checkbox:checked + .subscribe-label {
  background: rgba(79, 70, 229, 0.10);
  border-color: rgba(79, 70, 229, 0.25);
}

.subscribe-checkbox:checked + .subscribe-label .subscribe-icon {
  background: var(--brand);
  border-color: transparent;
}

.subscribe-checkbox:checked + .subscribe-label .subscribe-icon::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 7px;
  height: 12px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.subscribe-checkbox:focus-visible + .subscribe-label {
  outline: 3px solid rgba(79, 70, 229, 0.25);
  outline-offset: 2px;
}

.subscribe-extra {
  margin-top: 10px;
}

/* =====================
   Segmented / Toolbar
===================== */

.admin-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 10px 0 12px;
}

.admin-toolbar input {
  flex: 1;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: #fff;
}

.seg-btn {
  border: 0;
  background: transparent;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 800;
  color: var(--muted);
}

.seg-btn + .seg-btn {
  border-left: 1px solid var(--line);
}

.seg-btn.is-active {
  background: rgba(79, 70, 229, 0.12);
  color: var(--text);
}

/* =====================
   Admin item
===================== */

.admin-item {
  padding: 14px;
}

.admin-item-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.admin-item-main {
  flex: 1;
  min-width: 0;
}

.admin-item-title {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.admin-item-actions {
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-item-meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.admin-item-body {
  margin-top: 10px;
}

.admin-item-snippet {
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =====================
   Preview box
===================== */

.admin-preview {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}

.admin-preview-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 24, 39, 0.03);
}

.admin-preview-note {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}

.admin-preview-body {
  padding: 12px;
}

/* =====================
   Chat UI
===================== */

.chatbox {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.95);
  height: 360px;
  min-height: 260px;
  max-height: 75vh;
  overflow: auto;
  resize: vertical;
  display: flex;
  flex-direction: column;
  gap: 14px;
  white-space: normal;
}

.msg-row {
  display: flex;
  width: 100%;
}

.msg-row.user {
  justify-content: flex-end;
}

.msg-row.bot {
  justify-content: flex-start;
}

.msg-row.system {
  justify-content: center;
}

.msg-bubble {
  max-width: min(680px, 86%);
  border-radius: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(17, 24, 39, 0.06);
}

.msg-bubble.user {
  background: var(--chat-user-bg);
  color: var(--chat-user-fg);
  border-color: transparent;
  border-bottom-right-radius: 6px;
}

.msg-bubble.bot {
  background: var(--chat-bot-bg);
  color: var(--chat-bot-fg);
  border-bottom-left-radius: 6px;
}

.msg-bubble.system {
  background: var(--chat-system-bg);
  color: var(--chat-system-fg);
  border-color: rgba(17, 24, 39, 0.08);
  box-shadow: none;
}

.msg-text {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
  font-size: 14px;
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial,
    "Noto Sans JP",
    sans-serif;
}

/* =====================
   Tables
===================== */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

.table th,
.table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.table th {
  background: rgba(17, 24, 39, 0.03);
  font-size: 13px;
  color: var(--muted);
  font-weight: 800;
}

.table tr:last-child td {
  border-bottom: 0;
}

/* =====================
   Hero / Marketing helpers
===================== */

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(79, 70, 229, 0.1);
  color: var(--brand);
  font-weight: 800;
  font-size: 14px;
}

.hero-card {
  padding: 28px;
}

.hero-title {
  margin: 0 0 16px;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.08;
  letter-spacing: -0.04em;
}

.hero-lead {
  font-size: 18px;
  line-height: 1.9;
  color: var(--muted);
}

/* =====================
   Utility spacing
===================== */

.mt-0 { margin-top: 0 !important; }
.mt-8 { margin-top: 8px !important; }
.mt-10 { margin-top: 10px !important; }
.mt-12 { margin-top: 12px !important; }
.mt-14 { margin-top: 14px !important; }
.mt-16 { margin-top: 16px !important; }
.mt-18 { margin-top: 18px !important; }
.mt-20 { margin-top: 20px !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-8 { margin-bottom: 8px !important; }
.mb-10 { margin-bottom: 10px !important; }
.mb-12 { margin-bottom: 12px !important; }
.mb-14 { margin-bottom: 14px !important; }
.mb-16 { margin-bottom: 16px !important; }
.mb-18 { margin-bottom: 18px !important; }
.mb-20 { margin-bottom: 20px !important; }

/* =====================
   Responsive
===================== */

@media (max-width: 960px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 720px) {
  .container {
    padding: 18px;
  }

  .nav {
    flex-direction: column;
    align-items: stretch;
  }

  .nav .right {
    justify-content: flex-start;
  }

  .row,
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .admin-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-item-top {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-item-actions {
    min-width: 0;
  }

  .hero-card {
    padding: 22px;
  }

  .btn {
    width: 100%;
  }

  .segmented {
    width: 100%;
  }

  .seg-btn {
    flex: 1;
  }
}
