/* Lock the teacher page to the viewport and prevent any bottom band/scroll */
body.teacher { height: 100dvh; overflow: hidden; }
.teacher .centered { min-height: 0; }
.teacher .container {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: visible;
  box-sizing: border-box;
}
.teacher #mainApp { min-height: 0; }
/* Center everything within main app as a safety net */
.teacher #mainApp {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: visible;
  box-sizing: border-box;
}

/* Base theme - Light mode is now default */
:root {
  /* Light theme colors - New color scheme */
  --bg-light: #d8c1b0;
  --panel-light: #f5f0ed;
  --text-light: #2b1c1e;
  --muted-light: #5e2c31;
  --good-light: #8c3f3b;
  --confused-light: #8c3f3b;
  --novote-light: #d8c1b0;
  --accent-light: #8c3f3b;
  --border-light: #a4695b;
  --input-bg-light: #f5f0ed;
  
  /* Dark theme colors - Darker versions */
  --bg-dark: #46272a;
  --panel-dark: #5e2c31;
  --text-dark: #d8c1b0;
  --muted-dark: #a4695b;
  --good-dark: #8c3f3b;
  --confused-dark: #8c3f3b;
  --novote-dark: #5e2c31;
  --accent-dark: #d8c1b0;
  --border-dark: rgba(216, 193, 176, 0.2);
  --input-bg-dark: rgba(94, 44, 49, 0.3);
  
  /* Default to light theme */
  --bg: #d8c1b0;
  --panel: #f5f0ed;
  --text: #2b1c1e;
  --muted: #5e2c31;
  --good: #8c3f3b;
  --confused: #a4695b;
  --novote: #d8c1b0;
  --accent: #8c3f3b;
  --border: #a4695b;
  --input-bg: #f5f0ed;
}

/* Force override test - make sure colors are applied */
body {
  background: var(--bg) !important;
  color: var(--text) !important;
  position: relative;
  overflow-x: hidden;
}

/* Artistic background streaks - solid colors facing northeast */
.streak-left {
  position: fixed;
  top: -30%;
  left: -5%;
  width: 8%;
  height: 160%;
  background: #a4695b;
  transform: rotate(45deg);
  pointer-events: none;
  z-index: 0;
}

.streak-right {
  position: fixed;
  top: -10%;
  right: -5%;
  width: 8%;
  height: 160%;
  background: #a4695b;
  transform: rotate(45deg);
  pointer-events: none;
  z-index: 0;
}

/* Dark mode streaks */
[data-theme="dark"] .streak-left {
  background: #d8c1b0;
}

[data-theme="dark"] .streak-right {
  background: #d8c1b0;
}

.container {
  background: var(--bg) !important;
}

.card {
  background: var(--panel) !important;
}

.home-container {
  background: var(--bg) !important;
}

.home-card {
  background: var(--panel) !important;
}

/* Fullscreen overlay (teacher room prompt) */
.overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
  z-index: 50;
}
.overlay .panel {
  width: min(560px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
}
.overlay .row { justify-content: flex-start; }
.overlay input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.04);
  color: var(--text);
}

/* Dark theme override */
[data-theme="dark"] {
  --bg: var(--bg-dark);
  --panel: var(--panel-dark);
  --text: var(--text-dark);
  --muted: var(--muted-dark);
  --good: var(--good-dark);
  --confused: var(--confused-dark);
  --novote: #d8c1b0;
  --accent: var(--accent-dark);
  --border: var(--border-dark);
  --input-bg: var(--input-bg-dark);
}

/* Keep subtitles #d8c1b0 in dark mode */
[data-theme="dark"] .home-subtitle,
[data-theme="dark"] .subtle,
[data-theme="dark"] .action-card p {
  color: #d8c1b0 !important;
}

/* Keep button text #d8c1b0 in dark mode */
[data-theme="dark"] .btn,
[data-theme="dark"] .btn-primary,
[data-theme="dark"] .btn-secondary {
  color: #d8c1b0 !important;
}

/* Keep room status text #d8c1b0 in dark mode */
[data-theme="dark"] .room-status {
  color: #d8c1b0 !important;
}

/* Center modal titles */
.modal-header h2 {
  text-align: center;
}

/* Default theme styling (previously light theme) */
.bar-stack {
  border: 1px solid var(--border) !important;
}

input[type="text"] {
  border: 1px solid var(--border) !important;
}

.btn {
  border: 1px solid var(--border) !important;
}

html, body { height: 100%; margin: 0; }
html { background: var(--bg); }

/* Mobile: allow scrolling, Desktop: prevent scrolling */
@media (max-width: 768px) {
  body.student { overflow: auto; }
  body:not(.teacher) { overflow: auto; }
}
@media (min-width: 769px) {
  body.student { overflow: hidden; }
  body:not(.teacher) { overflow: hidden; }
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: var(--bg);
}

/* Remove all glow layers */

/* Layout */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
  overflow: visible;
}

/* Prevent tiny extra scroll area on teacher page root */
#mainApp { min-height: auto; }

.centered {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.card {
  width: 100%;
  background: var(--panel);
  box-shadow: 0 14px 36px rgba(0,0,0,0.35);
  border-radius: 20px;
  padding: 20px;
  border: 1px solid rgba(255,255,255,0.08);
  overflow: visible;
}

/* Add breathing room on very small screens so shadows aren't visually cut at edges */
@media (max-width: 420px) {
  .teacher .container { padding: 20px; }
  .teacher #mainApp { padding: 20px; }
}

.title {
  font-size: clamp(22px, 3.5vw, 32px);
  font-weight: 700;
  letter-spacing: 0.4px;
  margin: 6px 0 12px;
}

.subtle { color: var(--muted); }

.topbar { display:flex; justify-content:flex-end; align-items:center; }

.teacher-wrap {
  display: grid;
  grid-template-columns: 1.2fr 1fr; /* Left wider for bars */
  gap: 20px;
  align-items: stretch;
  min-height: 360px;
}
.teacher-wrap .col-left {
  display: flex;
  flex-direction: column;
  justify-content: center; /* center responses vertically */
  gap: 14px;
}
.teacher-wrap .col-right {
  display: flex;
  flex-direction: column;
  align-items: stretch; /* allow topbar to span full width */
  gap: 12px;
  position: relative;
  padding-top: 48px; /* space for top-right toggle */
}
.topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  position: absolute;
  top: 8px;
  right: 8px;
}

.row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
}

.btn {
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 600;
  background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.06));
  color: var(--text);
  cursor: pointer;
  transition: transform 0.06s ease, filter 0.2s ease;
  border: 1px solid rgba(255,255,255,0.1);
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn-primary { background: linear-gradient(180deg, rgba(140, 63, 59, 0.35), rgba(140, 63, 59, 0.18)); border-color: rgba(140, 63, 59, 0.45); }
.btn-danger {
  background: var(--confused);
  border-color: var(--confused);
  color: #fff;
}
.btn-danger:hover {
  background: #8c3f3b;
  border-color: #8c3f3b;
}
.btn-danger:active {
  background: #5e2c31;
  border-color: #5e2c31;
}
.btn-danger:disabled { opacity: 0.6; cursor: not-allowed; }

.qr {
  width: 200px;
  height: 200px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  overflow: visible;
}

.linkbox {
  width: 100%;
  word-break: break-all;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 8px 10px;
}

/* Room overlay input + circular submit button */

/* Input with an in-field submit button (messaging-style) */
.input-wrap {
  position: relative;
  width: 100%;
}
.input-wrap input[type="text"] {
  width: 100%;
  padding-right: 56px; /* space for the icon button */
  min-height: 44px;
}
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: transform 0.06s ease, filter 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}
.icon-btn:hover { filter: brightness(1.05); }
.icon-btn:active { transform: translateY(1px) scale(0.98); }
.icon-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Positioned inside the input on the right */
.icon-in {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border-radius: 50%;
}

/* Bars */
.bar-stack {
  width: 100%;
  height: 26px;
  display: flex;
  overflow: hidden;
  border-radius: 16px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.08);
}
.bar-seg { height: 100%; transition: width 350ms ease; }
.bar-good { background: #9dffc1 !important; }
.bar-novote { background: #d8c1b0 !important; }
.bar-confused { background: #ff9e9e !important; }

.counts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  margin-top: 8px;
  text-align: center;
}
.badge { font-weight: 700; }
.good { color: #d8c1b0 !important; }
.warn { color: #d8c1b0 !important; }
.bad { color: #d8c1b0 !important; }

/* Student UI */
.student {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.student-container {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  padding: 20px 0;
}

.student-card {
  position: relative;
  background: var(--panel);
  border-radius: 20px;
  box-shadow: 0 14px 36px rgba(0,0,0,0.35);
  padding: 24px;
  border: 1px solid rgba(255,255,255,0.12);
  width: 100%;
  box-sizing: border-box;
}

.info-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.info-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
}

.info-btn .material-icons {
  font-size: 24px;
}

.feedback-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.feedback-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  background: transparent;
  color: var(--text);
  outline: none;
}

.feedback-btn:focus {
  box-shadow: 0 0 0 2px var(--accent);
}

.feedback-btn.active {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

.feedback-btn .material-icons {
  font-size: 32px;
  margin-bottom: 8px;
  transition: transform 0.2s ease;
}

.feedback-btn.good {
  background: #d8c1b0 !important;
  border-color: #d8c1b0 !important;
  color: var(--good) !important;
}

.feedback-btn.good .material-icons {
  color: var(--good) !important;
}

.feedback-btn.confused {
  background: #8c3f3b !important;
  border-color: #8c3f3b !important;
  color: #d8c1b0 !important;
}

.feedback-btn.confused .material-icons {
  color: #d8c1b0 !important;
}

.feedback-btn:active {
  transform: scale(0.98);
}

.feedback-btn.active {
  box-shadow: 0 0 0 2px var(--accent);
}

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 24px 0;
  color: #d8c1b0 !important;
  font-size: 14px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}

.divider span {
  padding: 0 10px;
}

.feedback-note {
  width: 100%;
  display: flex;
  flex-direction: column;
}

.feedback-note textarea {
  width: 100%;
  padding: 12px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 12px;
  font-family: inherit;
  color: #d8c1b0 !important;
  min-height: 100px;
  max-height: 200px;
  resize: none;
  box-sizing: border-box;
  transition: border-color 0.2s ease;
  outline: none;
}

/* Fix light mode student page text colors */
.student-container,
.feedback-note textarea,
.feedback-note textarea::placeholder,
.divider {
  color: var(--good) !important;
}

/* Fix send button text color in light mode */
#sendFeedbackBtn {
  color: #d8c1b0 !important;
}

/* Keep text colors consistent in dark mode */
[data-theme="dark"] .student-container,
[data-theme="dark"] .feedback-note textarea,
[data-theme="dark"] .feedback-note textarea::placeholder,
[data-theme="dark"] .divider {
  color: #d8c1b0 !important;
}

[data-theme="dark"] #sendFeedbackBtn {
  color: #d8c1b0 !important;
}

.feedback-note textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.feedback-note textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.feedback-note .btn {
  width: 100%;
  padding: 12px;
  background: var(--good) !important;
  color: white !important;
  border: 1px solid var(--good) !important;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.feedback-note .btn:disabled {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.08);
  color: var(--muted);
  cursor: not-allowed;
}

/* Info Panel - original overlay style */
.info-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

.info-panel[hidden] {
  display: none;
}

.info-content {
  background: var(--panel);
  border-radius: 16px;
  padding: 24px;
  max-width: 400px;
  width: 100%;
  position: relative;
  animation: slideUp 0.3s ease;
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 14px 36px rgba(0,0,0,0.35);
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.info-content h3 {
  margin-top: 0;
  color: var(--text);
  margin-bottom: 16px;
}

.info-content ul {
  padding-left: 20px;
  margin: 0 0 24px;
  color: var(--muted);
}

.info-content li {
  margin-bottom: 10px;
  line-height: 1.5;
}

.btn-text {
  background: var(--good) !important;
  border: 1px solid var(--good) !important;
  color: white !important;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  display: block;
  width: 100%;
  text-align: center;
  transition: all 0.2s ease;
}

.btn-text:active {
  background: rgba(255,255,255,0.12);
  transform: translateY(1px);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(0,0,0,0.8);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1000;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.1);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Feedback Section */
.feedback-section {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 16px;
  margin-top: 16px;
  max-height: 300px;
  display: flex;
  flex-direction: column;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.section-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.feedback-list {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.feedback-list::-webkit-scrollbar {
  width: 6px;
}

.feedback-list::-webkit-scrollbar-track {
  background: transparent;
}

.feedback-list::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.feedback-item {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  border-left: 3px solid var(--muted);
}

.feedback-item.good {
  border-left-color: var(--good);
}

.feedback-item.confused {
  border-left-color: var(--confused);
}

.feedback-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted);
}

.feedback-time {
  opacity: 0.8;
}

.feedback-status {
  font-weight: 600;
  text-transform: capitalize;
}

.feedback-status.good {
  color: #d8c1b0 !important;
}

.feedback-status.bad {
  color: #d8c1b0 !important;
}

.feedback-text {
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.no-feedback {
  text-align: center;
  color: var(--muted);
  font-style: italic;
  padding: 16px 0;
  font-size: 14px;
}

/* Default theme adjustments */
.feedback-section {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}

.feedback-item {
  background: rgba(0, 0, 0, 0.02);
  border-left-color: var(--muted);
}

.feedback-text {
  color: var(--text);
}

/* Hide streaks on mobile */
@media (max-width: 768px) {
  .streak-left,
  .streak-right {
    display: none;
  }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .feedback-section {
    max-height: 250px;
  }
}

@media (max-width: 480px) {
  .student {
    padding: 12px;
  }
  
  .student-card {
    padding: 16px;
  }
  
  .feedback-buttons {
    grid-template-columns: 1fr;
  }
  
  .student-header h1 {
    font-size: 20px;
  }
  
  .feedback-btn {
    padding: 16px 10px;
  }
}

/* Disabled state */
.big[disabled] {
  opacity: 0.6;
  filter: grayscale(0.2);
  cursor: not-allowed;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  color: white;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

/* Only student page should fully lock scrolling */
body.no-scroll { height: 100svh; overflow: hidden; }

/* Remove title glow entirely */
#roomName { position: relative; }
.toggle input[type="checkbox"]:checked {
  background: linear-gradient(180deg, var(--good), var(--confused));
  border-color: var(--good);
}

/* Hide any footer if present */
footer { display: none; }

/* Colored toggle switch */
.toggle { color: var(--muted); font-size: 14px; }
.toggle input[type="checkbox"] {
  appearance: none;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.18);
  position: relative;
  outline: none;
  cursor: pointer;
  transition: background 200ms ease, border-color 200ms ease, box-shadow 200ms ease;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.25);
}
.toggle input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  transform: translateY(-50%);
  transition: left 200ms ease;
}
.toggle input[type="checkbox"]:checked {
  background: linear-gradient(180deg, rgba(140, 63, 59, 0.85), rgba(94, 44, 49, 0.85));
  border-color: rgba(140, 63, 59, 0.9);
}
.toggle input[type="checkbox"]:checked::after {
  left: 23px;
}

/* Toggle */
.toggle { display: inline-flex; align-items: center; gap: 8px; user-select: none; }

@media (max-width: 780px) {
  .teacher-wrap { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .counts { grid-template-columns: 1fr; }
  .qr { width: 180px; height: 180px; }
  .student-container { grid-template-columns: 1fr; }
}
