/* ══════════════════════════════════════════
   App Design System
   ──────────────────────────────────────────
   Shared styles for all app pages
   (index, settings, view, etc.)
   NOT for the slide canvas or editor.
   ══════════════════════════════════════════ */

/* ── Tokens ── */
:root {
  /* Brand */
  --app-accent: #10BBC7;
  --app-accent-hover: #0ea8b4;
  --app-accent-light: rgba(16, 187, 199, 0.08);
  --app-accent-border: rgba(16, 187, 199, 0.3);

  /* Surface */
  --app-bg: #f5f6f8;
  --app-surface: #fff;
  --app-border: #e2e5ea;

  /* Text */
  --app-text: #334455;
  --app-muted: #778899;
  --app-danger: #e55;

  /* Shape */
  --app-radius-sm: 6px;
  --app-radius: 10px;
  --app-radius-lg: 14px;

  /* Spacing (8px grid) */
  --app-space-xs: 4px;
  --app-space-sm: 8px;
  --app-space-md: 16px;
  --app-space-lg: 24px;
  --app-space-xl: 40px;

  /* Typography */
  --app-font: 'Zen Kaku Gothic New', sans-serif;
  --app-text-xs: 12px;
  --app-text-sm: 13px;
  --app-text-md: 14px;
  --app-text-lg: 16px;
  --app-text-xl: 18px;
  --app-text-2xl: 20px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--app-font);
  background: var(--app-bg);
  color: var(--app-text);
  font-size: var(--app-text-md);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ── */
.app-header {
  background: var(--app-surface);
  border-bottom: 1px solid var(--app-border);
  padding: var(--app-space-md) var(--app-space-xl);
  display: flex;
  align-items: center;
  gap: var(--app-space-md);
  height: 60px;
}
.app-header-title {
  font-size: var(--app-text-2xl);
  font-weight: 700;
  color: var(--app-text);
}
.app-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--app-space-sm);
}
.app-header-meta {
  font-size: var(--app-text-sm);
  color: var(--app-muted);
}

/* ── Main container ── */
.app-main {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--app-space-xl);
}
.app-main--wide {
  max-width: 1200px;
}

/* ── Button ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-sm);
  background: var(--app-surface);
  color: var(--app-text);
  font-size: var(--app-text-md);
  font-family: var(--app-font);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}
.btn:hover {
  background: var(--app-bg);
}
.btn--accent {
  background: var(--app-accent);
  color: #fff;
  border-color: var(--app-accent);
}
.btn--accent:hover {
  background: var(--app-accent-hover);
}
.btn--sm {
  padding: 4px 10px;
  font-size: var(--app-text-xs);
  border-radius: var(--app-radius-sm);
}
.btn--ghost {
  border-color: transparent;
  background: transparent;
  color: var(--app-muted);
}
.btn--ghost:hover {
  background: var(--app-bg);
  color: var(--app-text);
}
.btn--danger:hover {
  background: #fee;
  color: var(--app-danger);
  border-color: #fcc;
}

/* ── Card / Section ── */
.app-card {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-lg);
  padding: var(--app-space-lg);
  margin-bottom: var(--app-space-lg);
}
.app-card-title {
  font-size: var(--app-text-lg);
  font-weight: 700;
  margin-bottom: 2px;
}
.app-card-desc {
  font-size: var(--app-text-sm);
  color: var(--app-muted);
  margin-bottom: var(--app-space-md);
}

/* ── Section header (for grouped lists) ── */
.app-section {
  margin-bottom: var(--app-space-xl);
}
.app-section-header {
  display: flex;
  align-items: baseline;
  gap: var(--app-space-sm);
  margin-bottom: var(--app-space-md);
  padding-bottom: var(--app-space-sm);
  border-bottom: 2px solid var(--app-border);
}
.app-section-title {
  font-size: var(--app-text-xl);
  font-weight: 700;
}
.app-section-count {
  font-size: var(--app-text-sm);
  color: var(--app-muted);
}

/* ── Group (sub-section) ── */
.app-group {
  margin-bottom: var(--app-space-lg);
}
.app-group-name {
  font-size: var(--app-text-md);
  font-weight: 700;
  color: var(--app-muted);
  margin-bottom: var(--app-space-sm);
  padding-bottom: var(--app-space-xs);
  border-bottom: 1px solid var(--app-border);
}

/* ── Grid layouts ── */
.app-grid {
  display: grid;
  gap: var(--app-space-md);
}
.app-grid--cards {
  grid-template-columns: repeat(auto-fill, minmax(480px, 1fr));
}
.app-grid--compact {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* ── List (stacked rows) ── */
.app-list {
  display: flex;
  flex-direction: column;
  gap: var(--app-space-sm);
}
.app-list-row {
  display: flex;
  align-items: center;
  gap: var(--app-space-sm);
  padding: 10px var(--app-space-md);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  font-size: var(--app-text-md);
}

/* ── Badge / Tag ── */
.app-badge {
  display: inline-block;
  font-size: var(--app-text-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  line-height: 1.6;
}
.app-badge--accent {
  background: var(--app-accent-light);
  color: var(--app-accent);
}
.app-badge--muted {
  background: var(--app-bg);
  color: var(--app-muted);
}

/* ── Form elements ── */
.app-input {
  padding: 8px 12px;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-sm);
  font-size: var(--app-text-md);
  font-family: var(--app-font);
  color: var(--app-text);
  background: var(--app-surface);
  transition: border-color 0.15s;
  width: 100%;
}
.app-input:focus {
  outline: none;
  border-color: var(--app-accent);
}
.app-label {
  display: block;
  font-size: var(--app-text-sm);
  font-weight: 500;
  color: var(--app-muted);
  margin-bottom: 4px;
}
.app-input-row {
  display: flex;
  gap: var(--app-space-sm);
  align-items: center;
}

/* ── Modal ── */
.app-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.app-modal {
  background: var(--app-surface);
  border-radius: var(--app-radius-lg);
  padding: var(--app-space-lg);
  width: 480px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
}
.app-modal-title {
  font-size: var(--app-text-xl);
  font-weight: 700;
  margin-bottom: var(--app-space-md);
}
.app-modal-actions {
  display: flex;
  gap: var(--app-space-sm);
  justify-content: flex-end;
  margin-top: var(--app-space-lg);
}

/* ── Empty state ── */
.app-empty {
  text-align: center;
  padding: 80px var(--app-space-xl);
  color: var(--app-muted);
}
.app-empty-icon {
  font-size: 48px;
  margin-bottom: var(--app-space-md);
}
.app-empty-text {
  font-size: var(--app-text-lg);
  margin-bottom: var(--app-space-lg);
}

/* ── Loading ── */
.app-loading {
  text-align: center;
  padding: 80px;
  color: var(--app-muted);
  font-size: var(--app-text-lg);
}

/* ── Tabs ── */
.app-tabs {
  display: flex;
  gap: 4px;
  background: var(--app-bg);
  border-radius: var(--app-radius-sm);
  padding: 3px;
}
.app-tab {
  padding: 6px 16px;
  font-size: var(--app-text-sm);
  font-family: var(--app-font);
  font-weight: 600;
  color: var(--app-muted);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.app-tab:hover { color: var(--app-text); background: var(--app-surface); }
.app-tab--active {
  color: var(--app-text);
  background: var(--app-surface);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ── Avatar row ── */
.avatar-row {
  display: flex;
  align-items: center;
}
.avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--app-surface);
  object-fit: cover;
  flex-shrink: 0;
  font-size: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.avatar + .avatar { margin-left: -6px; }
.avatar--initial {
  background: var(--app-accent-light);
  color: var(--app-accent);
  font-weight: 700;
}
.avatar--more {
  background: var(--app-bg);
  color: var(--app-muted);
  font-size: 9px;
  font-weight: 700;
}

/* ── Timeline (compact nav) ── */
.timeline-container {
  overflow-x: auto;
  padding: 4px 0 12px;
  margin-bottom: var(--app-space-md);
}
.timeline-track {
  display: flex;
  gap: 0;
  min-width: max-content;
  position: relative;
  padding-top: 12px;
}
.timeline-track::before {
  content: '';
  position: absolute;
  top: 16px;
  left: 20px;
  right: 20px;
  height: 2px;
  background: var(--app-border);
}
.timeline-event {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 100px;
  padding: 0 8px;
  position: relative;
}
.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--app-accent);
  border: 2px solid var(--app-surface);
  box-shadow: 0 0 0 2px var(--app-accent);
  z-index: 1;
  margin-bottom: 6px;
  flex-shrink: 0;
}
.timeline-dot--pending {
  background: var(--app-border);
  box-shadow: 0 0 0 2px var(--app-border);
}
.timeline-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--app-text);
  text-align: center;
  line-height: 1.3;
  white-space: nowrap;
}
.timeline-date {
  font-size: 10px;
  color: var(--app-muted);
  text-align: center;
}

/* ── Stat row (for dashboard cards) ── */
.stat-row {
  display: flex;
  gap: var(--app-space-md);
  font-size: var(--app-text-xs);
  color: var(--app-muted);
  margin-top: 8px;
}
.stat-item {
  display: flex;
  align-items: center;
  gap: 4px;
}
.stat-value {
  font-weight: 700;
  color: var(--app-text);
}

/* ── Utilities ── */
.text-muted { color: var(--app-muted); }
.text-accent { color: var(--app-accent); }
.text-sm { font-size: var(--app-text-sm); }
.text-xs { font-size: var(--app-text-xs); }
.font-bold { font-weight: 700; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.gap-sm { gap: var(--app-space-sm); }
.gap-md { gap: var(--app-space-md); }
.mt-md { margin-top: var(--app-space-md); }
.mt-lg { margin-top: var(--app-space-lg); }
.pt-md { padding-top: var(--app-space-md); }
.border-t { border-top: 1px solid var(--app-border); }
