﻿/* OChemBoard whiteboard â€” adapted from Chemdu classroom.html
   Scoped under to avoid clashes with Tailwind/ochemboard styles. */

{
  --blue: #1a3c5e;
  --blue-dark: #122c46;
  --blue-light: #2a557f;
  --yellow: #f4c542;
  --yellow-dark: #d9ad2c;
  --bg-light: #f8f9fa;
  --text-dark: #212529;
  --text-muted: #5a6470;
  --border: #dee2e6;
  --shadow: 0 2px 8px rgba(26, 60, 94, 0.08);
  --shadow-lg: 0 8px 24px rgba(26, 60, 94, 0.12);
  --radius-lg: 14px;

  font-family: 'Open Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--text-dark);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.page-header {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-light) 100%);
  color: #fff;
  padding: 2rem 0;
  margin-bottom: 1.5rem;
}
.page-header h1 {
  font-family: 'Poppins', system-ui, sans-serif;
  color: #fff;
  margin: 0 0 0.5rem;
  font-size: 1.85rem;
}
.page-header p {
  color: rgba(255,255,255,0.9);
  margin: 0;
  max-width: 760px;
}

.note {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.tool-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 2rem;
}

/* Generic small button styles used inside the whiteboard chrome only */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.5rem 0.85rem;
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  line-height: 1;
}
.btn-sm { padding: 0.4rem 0.65rem; font-size: 0.8rem; }
.btn-outline {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-color: rgba(255,255,255,0.55);
}
.btn-outline:hover { background: rgba(255,255,255,0.22); }
.btn-secondary {
  background: var(--yellow);
  color: var(--blue);
  border-color: var(--yellow-dark);
}
.btn-secondary:hover { background: var(--yellow-dark); }

/* ===== Whiteboard ===== */
.wb-card.fs {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999;
  margin: 0 !important;
  border-radius: 0;
  display: flex;
  flex-direction: column;
}
.wb-card.fs .wb-shell { flex: 1; min-height: 0; }
.wb-card.fs .wb-toolbar { flex-shrink: 0; }

.tool-head {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-light) 100%);
  color: #fff;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.tool-head h2,
.tool-head h3 { color: #fff; margin: 0; font-size: 1.15rem; font-family: 'Poppins', sans-serif; }
.tool-head .tool-sub { color: rgba(255,255,255,0.85); font-size: 0.9rem; }

.wb-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 0.85rem;
  background: var(--bg-light);
  border-bottom: 1px solid var(--border);
}
.wb-toolbar-secondary {
  background: #fff;
  border-bottom: 1px solid var(--border);
  transition: padding 0.18s ease, opacity 0.18s ease;
  overflow: hidden;
}
.wb-toolbar-secondary.collapsed {
  padding: 0;
  height: 0;
  border-bottom: 0;
  opacity: 0;
  pointer-events: none;
}
#wb-more-toggle.active { background: var(--blue); color: #fff; }
.wb-toolbar > .wb-sep {
  width: 1px; height: 28px; background: var(--border); margin: 0 0.25rem;
}
.wb-tool-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  background: #fff; border: 1px solid var(--border); border-radius: 7px;
  padding: 0.4rem 0.6rem;
  font: 500 0.85rem 'Open Sans', sans-serif;
  color: var(--blue); cursor: pointer;
  transition: border-color 0.1s, background 0.1s, transform 0.05s;
  min-width: 36px; height: 36px;
}
.wb-tool-btn:hover { border-color: var(--blue); }
.wb-tool-btn.active { background: var(--blue); color: #fff; border-color: var(--blue-dark); }
.wb-tool-btn svg { width: 18px; height: 18px; }
.wb-pens {
  display: inline-flex; align-items: flex-end; gap: 0.2rem; padding: 0 0.15rem;
}
.wb-pen {
  width: 36px; height: 44px;
  border: 0; padding: 0; background: transparent;
  cursor: pointer; border-radius: 4px;
  position: relative;
  transition: transform 0.12s ease, filter 0.15s ease;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.18));
}
.wb-pen svg { display: block; width: 100%; height: 100%; }
.wb-pen:hover { transform: translateY(-3px); filter: drop-shadow(0 4px 6px rgba(0,0,0,0.22)); }
.wb-pen.active { transform: translateY(-6px); filter: drop-shadow(0 6px 8px rgba(0,0,0,0.28)); }
.wb-pen.active::after {
  content: ""; position: absolute; left: 4px; right: 4px; bottom: -7px;
  height: 4px; background: var(--yellow); border-radius: 2px;
  box-shadow: 0 1px 3px rgba(244,197,66,0.5);
}
.wb-toolbar label { font-size: 0.85rem; color: var(--text-muted); margin: 0 0.15rem; }
.wb-toolbar select,
.wb-toolbar input[type="color"] {
  padding: 0.35rem 0.5rem; border: 1px solid var(--border); border-radius: 6px;
  font: inherit; font-size: 0.85rem; height: 36px;
}
.wb-toolbar input[type="color"] { padding: 2px; width: 36px; }

.wb-save-menu {
  position: absolute; top: calc(100% + 4px); right: 0;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow-lg); z-index: 20; min-width: 220px; padding: 0.3rem;
  flex-direction: column; display: none;
}
.wb-save-menu.open { display: flex; }
.wb-save-menu[hidden] { display: none; }
.wb-save-menu button {
  background: transparent; border: 0; padding: 0.55rem 0.75rem;
  font: 500 0.9rem 'Open Sans', sans-serif; color: var(--blue);
  cursor: pointer; border-radius: 6px; text-align: left;
}
.wb-save-menu button:hover { background: var(--bg-light); }

.wb-page-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 56px; height: 36px; padding: 0 0.6rem;
  background: var(--blue); color: #fff;
  font-family: 'Poppins', sans-serif; font-weight: 600; font-size: 0.85rem;
  border-radius: 6px;
}

.wb-shell {
  display: grid; grid-template-columns: 280px 1fr; gap: 0;
  transition: grid-template-columns 0.25s ease;
}
.wb-shell.collapsed { grid-template-columns: 36px 1fr; }
.wb-shell.collapsed .wb-palette > *:not(.wb-collapse) { display: none; }
.wb-shell.collapsed .wb-palette { padding: 0.5rem 0; align-items: center; }
.wb-collapse {
  display: flex; align-items: center; justify-content: center;
  width: 100%; background: #fff; border: 1px solid var(--border); border-radius: 6px;
  padding: 0.35rem; font-size: 1rem; cursor: pointer; margin-bottom: 0.85rem;
  font-family: 'Poppins', sans-serif; font-weight: 600; color: var(--blue);
  transition: background 0.15s ease;
}
.wb-collapse:hover { background: var(--bg-light); }
.wb-shell.collapsed .wb-collapse { margin-bottom: 0; border: 0; background: transparent; }
@media (max-width: 820px) {
  .wb-shell { grid-template-columns: 1fr; }
  .wb-shell.collapsed { grid-template-columns: 1fr; }
  .wb-collapse { display: none; }
}

.wb-palette {
  background: var(--bg-light); border-right: 1px solid var(--border);
  padding: 0.85rem; overflow-y: auto; max-height: 580px;
}
.wb-card.fs .wb-palette { max-height: none; }
@media (max-width: 820px) {
  .wb-palette { border-right: 0; border-bottom: 1px solid var(--border); max-height: 280px; }
}

.wb-tabs {
  display: flex; gap: 0.25rem; margin-bottom: 0.85rem;
  background: #fff; border: 1px solid var(--border); border-radius: 7px; padding: 3px;
}
.wb-tab {
  flex: 1; background: transparent; border: 0; padding: 0.4rem 0.5rem;
  font: 600 0.82rem 'Poppins', sans-serif; color: var(--text-muted);
  cursor: pointer; border-radius: 5px;
}
.wb-tab.active { background: var(--blue); color: #fff; }
.wb-panel { display: none; }
.wb-panel.active { display: block; }

.wb-palette h4 {
  color: var(--blue); font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.07em; margin: 0.85rem 0 0.4rem; font-weight: 700;
  font-family: 'Poppins', sans-serif;
}
.wb-palette h4:first-of-type { margin-top: 0.25rem; }

.wb-stamps {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem;
}
.wb-stamp {
  aspect-ratio: 1 / 1; background: #fff; border: 1px solid var(--border);
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 4px;
  transition: border-color 0.1s ease, transform 0.1s ease;
}
.wb-stamp:hover { border-color: var(--blue); transform: translateY(-1px); }
.wb-stamp svg { width: 100%; height: 100%; }
.wb-stamp.active {
  border-color: var(--yellow-dark); border-width: 2px;
  box-shadow: 0 0 0 2px rgba(244,197,66,0.25);
}

.wb-ptable {
  display: grid; grid-template-columns: repeat(18, 1fr);
  grid-auto-rows: minmax(0, auto); gap: 2px;
  font-family: 'Poppins', sans-serif;
}
.wb-elem {
  aspect-ratio: 1 / 1; border: 1px solid var(--border); background: #fff;
  font-weight: 700; font-size: 0.65rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; border-radius: 3px; color: var(--blue);
  padding: 1px; text-align: center; line-height: 1; user-select: none;
}
.wb-elem:hover { background: var(--yellow); border-color: var(--yellow-dark); }
.wb-elem.cat-1 { background: #fde7d8; }
.wb-elem.cat-2 { background: #f9d39c; }
.wb-elem.cat-3 { background: #cfe6f6; }
.wb-elem.cat-4 { background: #d6e3f7; }
.wb-elem.cat-5 { background: #d0e9d4; }
.wb-elem.cat-6 { background: #fff5b8; }
.wb-elem.cat-7 { background: #f7c8c4; }
.wb-elem.cat-8 { background: #c5e0fa; }
.wb-elem.cat-9 { background: #e6d2ec; }
.wb-elem.cat-10 { background: #f1c9d8; }
.wb-elem.spacer { background: transparent; border: 0; cursor: default; pointer-events: none; }
.wb-elem.spacer:hover { background: transparent; }
.wb-ptable-legend {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.35rem 0.6rem;
  margin-top: 0.6rem; font-size: 0.72rem; color: var(--text-muted);
}
.wb-ptable-legend span::before {
  content: ""; display: inline-block; width: 10px; height: 10px;
  border-radius: 2px; margin-right: 0.35rem; vertical-align: -1px;
}
.leg-1::before { background: #fde7d8; }
.leg-2::before { background: #f9d39c; }
.leg-3::before { background: #cfe6f6; }
.leg-4::before { background: #d6e3f7; }
.leg-5::before { background: #d0e9d4; }
.leg-6::before { background: #fff5b8; }
.leg-7::before { background: #f7c8c4; }
.leg-8::before { background: #c5e0fa; }
.leg-9::before { background: #e6d2ec; }
.leg-10::before { background: #f1c9d8; }

.wb-sel-handle {
  position: absolute; width: 12px; height: 12px;
  background: var(--yellow); border: 2px solid var(--blue);
  border-radius: 3px; z-index: 7; box-sizing: border-box;
}
.wb-sel-nw { top: -6px;  left: -6px;  cursor: nwse-resize; }
.wb-sel-n  { top: -6px;  left: 50%; margin-left: -6px; cursor: ns-resize; }
.wb-sel-ne { top: -6px;  right: -6px; cursor: nesw-resize; }
.wb-sel-e  { top: 50%; margin-top: -6px; right: -6px; cursor: ew-resize; }
.wb-sel-se { bottom: -6px; right: -6px; cursor: nwse-resize; }
.wb-sel-s  { bottom: -6px; left: 50%; margin-left: -6px; cursor: ns-resize; }
.wb-sel-sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.wb-sel-w  { top: 50%; margin-top: -6px; left: -6px; cursor: ew-resize; }

.wb-place-preview {
  position: absolute; border: 2px dashed var(--yellow-dark);
  background: rgba(244,197,66,0.08); pointer-events: none; z-index: 4;
}
.wb-place-preview img { width: 100%; height: 100%; object-fit: contain; opacity: 0.85; }
.wb-place-hint {
  position: absolute; background: var(--blue); color: #fff;
  font-size: 0.75rem; padding: 2px 6px; border-radius: 3px;
  pointer-events: none; z-index: 4; font-family: 'Poppins', sans-serif;
}

.wb-stage {
  position: relative; background: #fff; height: 540px;
}
.wb-card.fs .wb-stage { flex: 1; height: auto; }
#wb-grid-canvas,
#whiteboard {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
}
#whiteboard {
  background: transparent; cursor: crosshair; touch-action: none; z-index: 1;
}
#wb-grid-canvas { z-index: 0; pointer-events: none; }
.wb-card.fs #wb-grid-canvas,
.wb-card.fs #whiteboard { position: absolute; }
.wb-card.fs .wb-toolbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg-light); border-bottom: 1px solid var(--border);
}
.wb-card.fs #wb-grid { background: var(--yellow); color: var(--blue); }

.wb-text-input {
  position: absolute; border: 2px dashed var(--blue);
  background: rgba(255,255,255,0.95); padding: 4px 8px;
  font: 600 16px 'Open Sans', sans-serif; color: var(--blue);
  outline: none; border-radius: 4px; z-index: 5;
  min-width: 100px; display: inline-block; min-height: 1.2em;
  white-space: nowrap; caret-color: var(--blue); line-height: 1.4;
}
.wb-text-input sub,
.wb-text-input sup { font-size: 0.7em; line-height: 0; }
.wb-text-input sub { vertical-align: sub; }
.wb-text-input sup { vertical-align: super; }

.wb-text-obj {
  position: absolute; white-space: pre-wrap;
  word-break: break-word; overflow-wrap: break-word;
  font: 600 18px 'Open Sans', sans-serif; color: var(--blue);
  cursor: pointer; z-index: 4; padding: 2px 4px;
  border: 1px solid transparent; user-select: none; line-height: 1.4;
}
.wb-text-obj sub,
.wb-text-obj sup { font-size: 0.7em; line-height: 0; }
.wb-text-obj sub { vertical-align: sub; }
.wb-text-obj sup { vertical-align: super; }
.wb-text-obj:hover { border-color: rgba(244,197,66,0.5); }
.wb-text-obj.selectable { cursor: pointer; }
.wb-text-obj.selectable:hover {
  border-color: var(--blue); background: rgba(26, 60, 94, 0.04);
  box-shadow: 0 0 0 1px rgba(26, 60, 94, 0.15);
}
.wb-text-obj.selected {
  border: 2px dashed #f4c542; cursor: move;
  box-shadow: 0 0 0 1px rgba(244,197,66,0.25);
}
.wb-text-obj[contenteditable="true"] {
  outline: 2px dashed var(--blue); cursor: text;
  user-select: text; background: rgba(255,255,255,0.96);
}
.wb-text-edit {
  position: absolute; top: -28px; right: -28px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--blue); color: #fff; border: 0; cursor: pointer;
  font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center; z-index: 8;
}
.wb-text-edit:hover { background: var(--blue-dark); }

