/* Biology 30 Portal — shared viewer styling */

:root {
  --bio30-bg: #f5f7fb;
  --bio30-card: #ffffff;
  --bio30-border: #dbe3ef;
  --bio30-text: #1f2937;
  --bio30-muted: #64748b;
  --bio30-accent: #1d4ed8;
  --bio30-header-bg: #0f2744;
  --bio30-header-text: #f8fafc;
  --bio30-pass: #067647;
  --bio30-pass-bg: #ecfdf3;
  --bio30-warning: #b54708;
  --bio30-warning-bg: #fffaeb;
  --bio30-action: #b42318;
  --bio30-action-bg: #fef3f2;
  --bio30-info-bg: #e8f0fe;
}

* { box-sizing: border-box; }

body.bio30-viewer {
  margin: 0;
  background: var(--bio30-bg);
  color: var(--bio30-text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

.bio30-header {
  background: var(--bio30-header-bg);
  color: var(--bio30-header-text);
  padding: 16px 20px;
}

.bio30-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.bio30-brand {
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.85;
  margin: 0 0 4px;
}

.bio30-header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.bio30-header-sub {
  margin: 4px 0 0;
  font-size: 14px;
  opacity: 0.9;
}

.bio30-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.back-link {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--bio30-accent);
  text-decoration: none;
  font-size: 14px;
}

.back-link:hover { text-decoration: underline; }

.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
}

.status-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bio30-info-bg);
  color: #1a4d8f;
  font-size: 12px;
  font-weight: 600;
}

.card {
  background: var(--bio30-card);
  border: 1px solid var(--bio30-border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 1.15rem;
}

.card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.stat-card {
  background: #f8fafc;
  border: 1px solid #eef2f7;
  border-radius: 8px;
  padding: 14px;
}

.stat-label {
  font-size: 12px;
  color: var(--bio30-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 4px;
}

.muted { color: var(--bio30-muted); font-size: 14px; }

.error { color: var(--bio30-action); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-pass {
  background: var(--bio30-pass-bg);
  color: var(--bio30-pass);
  border: 1px solid #bbf7d0;
}

.badge-warning {
  background: var(--bio30-warning-bg);
  color: var(--bio30-warning);
  border: 1px solid #fedf89;
}

.badge-action {
  background: var(--bio30-action-bg);
  color: var(--bio30-action);
  border: 1px solid #fecdca;
}

.badge-info {
  background: var(--bio30-info-bg);
  color: #1a4d8f;
  border: 1px solid #bfdbfe;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  border: 1px solid #eef2f7;
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  background: #f8fafc;
  font-weight: 600;
}

.data-table tr:nth-child(even) td {
  background: #fafbfc;
}

.material-link {
  color: var(--bio30-accent);
  text-decoration: none;
}

.material-link:hover { text-decoration: underline; }

.material-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.material-tile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: #f8fafc;
  border: 1px solid #eef2f7;
  border-radius: 10px;
  min-height: 96px;
}

.material-tile-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--bio30-text);
  line-height: 1.35;
}

.material-btn {
  display: inline-block;
  align-self: flex-start;
  padding: 8px 14px;
  background: var(--bio30-accent);
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid #1e40af;
  transition: background 0.15s ease;
}

.material-btn:hover {
  background: #1e40af;
  text-decoration: none;
}

.section-intro {
  margin: 0 0 4px;
}

.sessions-table-wrap {
  overflow-x: auto;
  margin-top: 8px;
}

.sessions-table td,
.sessions-table th {
  white-space: nowrap;
}

.sessions-table td:nth-child(5),
.sessions-table td:nth-child(6),
.sessions-table th:nth-child(5),
.sessions-table th:nth-child(6) {
  white-space: normal;
  min-width: 140px;
}

.session-id,
.session-tz {
  font-size: 12px;
}

.materials-ref {
  font-size: 12px;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
}

.stat-value-sm {
  font-size: 1rem;
  line-height: 1.35;
}

.whiteboard-main {
  padding-bottom: 32px;
}

.whiteboard-toolbar-card {
  padding-bottom: 12px;
}

.whiteboard-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.tool-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tool-btn {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: var(--bio30-text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.tool-btn:hover {
  background: #eef2f7;
}

.tool-btn.active {
  background: var(--bio30-accent);
  color: #fff;
  border-color: #1e40af;
}

.tool-btn.secondary-tool {
  background: #fff;
}

.tool-label {
  font-size: 12px;
  color: var(--bio30-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-label input[type="color"] {
  width: 36px;
  height: 28px;
  padding: 0;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  cursor: pointer;
}

.tool-label input[type="range"] {
  width: 90px;
}

.template-select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  font-size: 13px;
  background: #fff;
}

.import-label {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.whiteboard-note {
  margin: 10px 0 0;
  font-size: 13px;
}

.whiteboard-sync-status {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--bio30-pass);
  font-weight: 600;
}

.whiteboard-sync-status.error {
  color: var(--bio30-action);
}

.sync-debug {
  margin-top: 10px;
  font-size: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 10px;
  background: #f8fafc;
}

.sync-debug summary {
  cursor: pointer;
  font-weight: 600;
  color: #334155;
}

.sync-debug-panel {
  margin-top: 8px;
}

.sync-debug-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 12px;
  margin: 0;
}

.sync-debug-grid dt {
  color: #64748b;
  font-weight: 600;
}

.sync-debug-grid dd {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.whiteboard-stage-card {
  padding: 12px;
}

.whiteboard-stage {
  width: 100%;
  min-height: 480px;
  height: calc(100vh - 340px);
  max-height: 720px;
  background: #fff;
  border: 1px solid #eef2f7;
  border-radius: 8px;
  overflow: hidden;
}

#board {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  background: #fff;
}

@media (max-width: 640px) {
  .whiteboard-stage {
    min-height: 360px;
    height: 55vh;
  }
  .tool-btn {
    padding: 7px 10px;
    font-size: 12px;
  }
}

.key-value {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 8px 16px;
  margin: 8px 0;
  font-size: 14px;
}

.key-value dt { color: var(--bio30-muted); font-weight: 600; }
.key-value dd { margin: 0; }

.question-block { margin-top: 12px; }

.blank-row {
  margin: 10px 0;
  padding: 12px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #eef2f7;
}

.blank-resolved {
  background: #f0f9ff;
  padding: 2px 6px;
  border-radius: 4px;
  border-bottom: 2px solid #93c5fd;
}

.answer-key {
  margin-top: 10px;
  padding: 12px;
  background: var(--bio30-pass-bg);
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  font-size: 14px;
}

.technical-panel {
  margin-top: 24px;
  border: 1px solid var(--bio30-border);
  border-radius: 10px;
  background: #fafbfc;
  padding: 12px 16px;
}

.technical-panel summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--bio30-muted);
  font-size: 13px;
}

.technical-panel pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  margin: 12px 0 0;
  max-height: 400px;
  overflow: auto;
}

ul.compact { margin: 8px 0; padding-left: 20px; }

@media (max-width: 640px) {
  .key-value { grid-template-columns: 1fr; }
  .data-table { font-size: 13px; }
  .data-table th, .data-table td { padding: 8px; }
}

.portal-wrap { max-width: 1100px; margin: 24px auto; padding: 0 16px 40px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.login-grid { display: grid; gap: 12px; max-width: 420px; }
.login-grid input, .login-grid button { padding: 10px 12px; font-size: 15px; }
.hidden { display: none; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
button.secondary { background: #eef2f7; color: #1f2937; border: 1px solid #cbd5e1; }
.refresh-msg { margin-top: 10px; font-size: 14px; min-height: 18px; }
.refresh-msg.success { color: #067647; }
.refresh-msg.error { color: #b42318; }
.refresh-msg.info { color: #1d4ed8; }
.section-card { border-top: 1px solid #eef2f7; padding-top: 12px; margin-top: 12px; }

@media print {
  body.bio30-viewer, body { background: #fff; }
  .back-link, .technical-panel, .actions, .login-grid { display: none; }
  .card { break-inside: avoid; border-color: #ccc; }
  .bio30-header { background: #333; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .material-btn { color: #000; background: #eee; border-color: #999; }
  .sessions-table-wrap { overflow: visible; }
}
