/* Bodin plus — global styles */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Thai:wght@300;400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  /* Brand */
  --bp-indigo:   oklch(0.46 0.22 270);
  --bp-blue:     oklch(0.58 0.20 250);
  --bp-sky:      oklch(0.72 0.15 230);
  --bp-violet:   oklch(0.56 0.24 295);
  --bp-purple:   oklch(0.48 0.22 305);
  --bp-pink:     oklch(0.70 0.18 325);

  --bp-grad:     linear-gradient(135deg, oklch(0.50 0.22 265) 0%, oklch(0.58 0.24 295) 60%, oklch(0.66 0.22 320) 100%);
  --bp-grad-soft:linear-gradient(135deg, oklch(0.96 0.04 270) 0%, oklch(0.97 0.03 290) 50%, oklch(0.96 0.04 320) 100%);
  --bp-grad-deep:linear-gradient(155deg, oklch(0.28 0.14 270) 0%, oklch(0.32 0.18 290) 60%, oklch(0.36 0.18 320) 100%);

  --bp-ink:      oklch(0.18 0.04 270);
  --bp-ink-2:    oklch(0.36 0.04 270);
  --bp-ink-3:    oklch(0.55 0.03 270);
  --bp-mute:     oklch(0.72 0.02 270);

  --bp-line:     oklch(0.92 0.01 270);
  --bp-line-2:   oklch(0.88 0.015 270);
  --bp-surface:  #ffffff;
  --bp-canvas:   oklch(0.985 0.005 270);
  --bp-soft:     oklch(0.96 0.02 280);

  --bp-success:  oklch(0.62 0.16 155);
  --bp-warning:  oklch(0.72 0.16 75);
  --bp-danger:   oklch(0.60 0.22 25);

  --bp-radius:   16px;
  --bp-radius-lg:24px;

  --bp-shadow-sm: 0 1px 2px rgba(45, 30, 110, 0.05), 0 1px 1px rgba(45, 30, 110, 0.04);
  --bp-shadow:    0 2px 6px rgba(45, 30, 110, 0.06), 0 12px 28px -16px rgba(45, 30, 110, 0.18);
  --bp-shadow-lg: 0 8px 16px rgba(45, 30, 110, 0.08), 0 28px 60px -20px rgba(45, 30, 110, 0.30);
}

/* Dark mode */
:root[data-theme="dark"] {
  --bp-ink:      oklch(0.96 0.01 270);
  --bp-ink-2:    oklch(0.78 0.02 270);
  --bp-ink-3:    oklch(0.60 0.02 270);
  --bp-mute:     oklch(0.45 0.02 270);

  --bp-line:     oklch(0.30 0.02 270);
  --bp-line-2:   oklch(0.34 0.02 270);
  --bp-surface:  oklch(0.20 0.025 270);
  --bp-canvas:   oklch(0.14 0.02 270);
  --bp-soft:     oklch(0.24 0.025 280);

  --bp-grad-soft:linear-gradient(135deg, oklch(0.22 0.05 270) 0%, oklch(0.24 0.05 290) 50%, oklch(0.23 0.05 320) 100%);

  --bp-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.30), 0 1px 1px rgba(0, 0, 0, 0.25);
  --bp-shadow:    0 4px 12px rgba(0, 0, 0, 0.40), 0 16px 36px -16px rgba(0, 0, 0, 0.55);
  --bp-shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.45), 0 32px 64px -20px rgba(0, 0, 0, 0.65);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'IBM Plex Sans Thai', 'Space Grotesk', system-ui, sans-serif;
  color: var(--bp-ink);
  background: var(--bp-canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'kern', 'liga', 'cv02';
}

.font-mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; }
.font-display { font-family: 'Space Grotesk', 'IBM Plex Sans Thai', sans-serif; letter-spacing: -0.01em; }
.font-num { font-family: 'Space Grotesk', sans-serif; font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }

/* ── Mobile web shell (student) ──────────────────────── */
.bp-web-stage {
  min-height: 100vh;
  background:
    radial-gradient(60% 50% at 85% 0%, oklch(0.85 0.10 305 / 0.28), transparent 60%),
    radial-gradient(50% 40% at 0% 100%, oklch(0.78 0.12 250 / 0.22), transparent 60%),
    var(--bp-canvas);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px 16px;
  position: relative;
}
.bp-mobile-shell {
  position: relative;
  width: 100%;
  max-width: 460px;
  height: calc(100vh - 48px);
  background: var(--bp-canvas);
  border-radius: 28px;
  overflow: hidden;
  box-shadow:
    0 24px 80px -20px rgba(45, 30, 110, 0.30),
    0 0 0 1px rgba(45, 30, 110, 0.05);
}
.bp-mobile-scroll {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: oklch(0.85 0.02 270) transparent;
}
.bp-mobile-scroll::-webkit-scrollbar { width: 6px; }
.bp-mobile-scroll::-webkit-scrollbar-thumb { background: oklch(0.85 0.02 270); border-radius: 3px; }
.bp-mobile-scroll::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 520px) {
  .bp-web-stage { padding: 0 !important; }
  .bp-mobile-shell {
    max-width: none !important;
    height: 100vh !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }
}

/* "View as ..." floating chip on desktop */
.bp-view-switch {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 14px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  box-shadow: 0 8px 22px rgba(45, 30, 110, 0.12);
  font-size: 12px;
  color: var(--bp-ink-2);
}
.bp-view-switch button {
  appearance: none;
  border: 0;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bp-grad);
  color: #fff;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 4px 10px rgba(80, 50, 180, 0.25);
}
.bp-view-switch button.ghost {
  background: transparent;
  color: var(--bp-ink-2);
  box-shadow: none;
}

/* Back chip (top-left) */
.bp-back-chip {
  position: fixed;
  top: 24px;
  left: 24px;
  z-index: 50;
  appearance: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px 8px 11px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  box-shadow: 0 8px 22px rgba(45, 30, 110, 0.12);
  color: var(--bp-ink-2);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  transition: transform .18s ease, box-shadow .18s ease, color .18s ease;
}
.bp-back-chip:hover {
  color: var(--bp-ink);
  transform: translateX(-2px);
  box-shadow: 0 12px 28px rgba(45, 30, 110, 0.16);
}

@media (max-width: 520px) {
  .bp-view-switch { display: none; }
  .bp-back-chip {
    top: 12px;
    left: 12px;
    padding: 6px 12px 6px 9px;
    font-size: 12px;
  }
}

/* Stage */
.bp-stage {
  min-height: 100vh;
  width: 100%;
  background:
    radial-gradient(60% 50% at 80% 0%, oklch(0.85 0.10 305 / 0.35), transparent 60%),
    radial-gradient(50% 40% at 0% 100%, oklch(0.78 0.12 250 / 0.30), transparent 60%),
    var(--bp-canvas);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 24px 80px;
  gap: 24px;
  position: relative;
}

/* Toggle pill */
.bp-role-toggle {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  padding: 4px;
  box-shadow: 0 6px 24px rgba(45, 30, 110, 0.10), 0 0 0 1px rgba(45, 30, 110, 0.04);
  font-size: 13px;
  font-weight: 500;
  position: relative;
  z-index: 5;
}
.bp-role-toggle button {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-family: inherit;
  color: var(--bp-ink-2);
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: color .18s ease, background .18s ease;
}
.bp-role-toggle button.active {
  background: var(--bp-grad);
  color: #fff;
  box-shadow: 0 4px 12px rgba(80, 50, 180, 0.30);
}
.bp-role-toggle button:not(.active):hover { color: var(--bp-ink); }

/* Stripe placeholder (for photos we don't have) */
.bp-photo {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  padding: 10px;
  color: rgba(255, 255, 255, 0.95);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  line-height: 1.3;
  letter-spacing: 0.02em;
  background:
    repeating-linear-gradient(135deg,
      rgba(255, 255, 255, 0.08) 0,
      rgba(255, 255, 255, 0.08) 14px,
      rgba(255, 255, 255, 0.03) 14px,
      rgba(255, 255, 255, 0.03) 28px),
    var(--ph-bg, linear-gradient(135deg, #4A5BD9, #7B3FE4));
}
.bp-photo::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.50) 0%, transparent 50%);
  pointer-events: none;
}
.bp-photo .lbl {
  position: relative;
  z-index: 1;
  text-transform: uppercase;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.bp-photo .lbl .tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-weight: 500;
  width: max-content;
}

/* Pill / badge */
.bp-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bp-soft);
  color: var(--bp-ink-2);
  white-space: nowrap;
}
.bp-pill.pending  { background: oklch(0.93 0.06 75); color: oklch(0.36 0.10 60); }
.bp-pill.progress { background: oklch(0.92 0.06 250); color: oklch(0.34 0.16 260); }
.bp-pill.resolved { background: oklch(0.92 0.07 155); color: oklch(0.32 0.10 155); }
.bp-pill.urgent   { background: oklch(0.92 0.08 25); color: oklch(0.40 0.18 25); }
.bp-pill.dot::before {
  content:'';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}

/* card */
.bp-card {
  background: var(--bp-surface);
  border-radius: var(--bp-radius);
  border: 1px solid var(--bp-line);
  box-shadow: var(--bp-shadow-sm);
}

/* Reset for embedded button */
button { font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ── Responsive: teacher app ──────────────────────────── */
.bp-teacher-root { display: flex; height: 100%; }
.bp-teacher-main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.bp-teacher-content { flex: 1; overflow: auto; position: relative; }

.bp-grid-2col { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.6fr); gap: 20px; }
.bp-grid-detail { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; }
.bp-grid-stats { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 14px; }
.bp-grid-photos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bp-grid-meta3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

.bp-sidebar-backdrop { display: none; }
.bp-mobile-menu-btn { display: none; }

@media (max-width: 960px) {
  /* sidebar becomes a slide-in drawer */
  .bp-teacher-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 0 0 40px rgba(45, 30, 110, 0.20);
  }
  .bp-teacher-sidebar.open { transform: translateX(0); }
  .bp-sidebar-backdrop {
    display: block;
    position: fixed; inset: 0;
    background: rgba(20, 14, 60, 0.4);
    backdrop-filter: blur(4px);
    z-index: 55;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
  }
  .bp-sidebar-backdrop.open { opacity: 1; pointer-events: auto; }
  .bp-mobile-menu-btn { display: inline-flex; }

  .bp-grid-2col, .bp-grid-detail { grid-template-columns: 1fr !important; }
  .bp-grid-meta3 { grid-template-columns: 1fr 1fr !important; }
}

@media (max-width: 640px) {
  .bp-grid-stats { grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; }
  .bp-grid-photos { grid-template-columns: 1fr !important; }
  .bp-grid-meta3 { grid-template-columns: 1fr !important; }
  .bp-topbar-search { display: none !important; }
  .bp-topbar { padding: 12px 16px !important; gap: 10px !important; }
  .bp-teacher-content > div { padding: 16px !important; }
}

/* Issue table → card list on small */
.bp-issue-table-head { display: grid; }
.bp-issue-row { display: grid; }
@media (max-width: 860px) {
  .bp-issue-table-head { display: none !important; }
  .bp-issue-row {
    grid-template-columns: 56px 1fr !important;
    grid-template-rows: auto auto !important;
    row-gap: 8px !important;
    padding: 14px !important;
  }
  .bp-issue-row .bp-cell-cat,
  .bp-issue-row .bp-cell-reporter,
  .bp-issue-row .bp-cell-urgency,
  .bp-issue-row .bp-cell-time {
    grid-column: 2 !important;
  }
  .bp-issue-row .bp-cell-status {
    grid-column: 2 !important;
    justify-self: start;
  }
  .bp-issue-row .bp-cell-meta {
    grid-column: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
  }
}

/* Login responsive */
.bp-login-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(420px, 480px); gap: 56px; }
@media (max-width: 880px) {
  .bp-login-grid {
    grid-template-columns: 1fr !important;
    gap: 28px !important;
    max-width: 480px !important;
  }
  .bp-login-grid > div:first-child { text-align: center; align-items: center; }
  .bp-login-stats { justify-content: center; flex-wrap: wrap; }
}

/* Role-picker cards responsive */
.bp-role-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 640px) {
  .bp-role-grid { grid-template-columns: 1fr !important; }
}

/* Sign-up form responsive */
@media (max-width: 480px) {
  .bp-su-row2 { grid-template-columns: 1fr !important; }
}

/* ── Progress slider (teacher) ────────────────────────── */
.bp-prog-slider {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--bp-soft);
  outline: none;
  margin: 8px 0 0;
  cursor: grab;
}
.bp-prog-slider:active { cursor: grabbing; }
.bp-prog-slider::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background:
    linear-gradient(to right,
      var(--bp-slider-color, var(--bp-blue)) 0%,
      var(--bp-slider-color, var(--bp-blue)) var(--bp-slider-pct, 0%),
      transparent var(--bp-slider-pct, 0%));
}
.bp-prog-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--bp-slider-color, var(--bp-blue));
  box-shadow: 0 4px 10px rgba(45, 30, 110, 0.18);
  margin-top: -7px;
  transition: transform .12s ease;
}
.bp-prog-slider::-webkit-slider-thumb:hover { transform: scale(1.1); }
.bp-prog-slider::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: var(--bp-soft);
}
.bp-prog-slider::-moz-range-progress {
  height: 8px;
  border-radius: 999px;
  background: var(--bp-slider-color, var(--bp-blue));
}
.bp-prog-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--bp-slider-color, var(--bp-blue));
  box-shadow: 0 4px 10px rgba(45, 30, 110, 0.18);
}
