/* ──────────────────────────────────────────────── */
/* Color palette - cream/tan primary                 */
/* ──────────────────────────────────────────────── */
:root {
  --bg-color: #f8f5f0;
  --text-color: #3c2f2f;
  --card-bg: #fffaf0;
  --input-bg: #fffaf0;
  --input-text: #3c2f2f;
  --button-bg: #f5e8c7;
  --button-text: #4a3728;
  --button-hover-bg: #e0d0a8;
  --accent: #d4a373;
  --poll-bg: #fff8e8;
  --border-color: #e0d4c0;
  --upvote-active: #800000;
  --upvoted-bg: #fff0f0;
}

[data-theme="dark"] {
  --bg-color: #1a1410;
  --text-color: #e8d9c5;
  --card-bg: #2a1f18;
  --input-bg: #33251f;
  --input-text: #e8d9c5;
  --button-bg: #d4a373;
  --button-text: #1a1410;
  --button-hover-bg: #b58955;
  --accent: #f5e8c7;
  --poll-bg: #2f241c;
  --border-color: #4a3728;
  --upvote-active: #c75151;
  --upvoted-bg: #3a1f1f;
}

/* Base layout & resets */
body {
  font-family: system-ui, sans-serif;
  margin: 0;
  padding: 10px;
  background: var(--bg-color);
  color: var(--text-color);
}

.hidden { display: none; }

#login, #app { max-width: 700px; margin: auto; }

/* Header & Logo */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  flex-wrap: wrap;
  gap: 16px;
}

#logo-img {
  height: 48px;
  width: auto;
  max-width: 220px;
  display: block;
  object-fit: contain;
}

[data-theme="dark"] #logo-img {
  filter: brightness(1.1);
}

/* Form elements */
textarea, input {
  width: 100%;
  padding: 8px;
  margin-bottom: 8px;
  background: var(--input-bg);
  color: var(--input-text);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  box-sizing: border-box;
  font-size: 1rem;
}

button {
  padding: 8px 12px;
  cursor: pointer;
  background: var(--button-bg);
  color: var(--button-text);
  border: none;
  border-radius: 4px;
  transition: background-color 0.2s;
}

button:hover {
  background: var(--button-hover-bg);
}

/* Posts & upvotes */
.post {
  background: var(--card-bg);
  padding: 10px;
  margin-bottom: 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.post.upvoted-by-me {
  background: var(--upvoted-bg);
  border-color: #80000088;
}

.upvote {
  cursor: pointer;
  color: var(--accent);
  user-select: none;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s;
}

.upvote:hover {
  background: rgba(212,163,115,0.12);
}

/* Poll */
.poll {
  background: var(--poll-bg);
  padding: 10px;
  margin-bottom: 15px;
  border-radius: 6px;
}

.poll button {
  margin: 5px 8px 5px 0;
  min-width: 140px;
  position: relative;
  transition: all 0.2s;
}

.poll button.voted-by-me {
  background: var(--upvote-active) !important;
  color: white !important;
  box-shadow: 0 2px 8px rgba(128,0,0,0.3);
}

.poll button.voted-by-me::after {
  content: "✓";
  margin-left: 6px;
  font-weight: bold;
}

/* Upvoted post styling – dark maroon theme */
.post.upvoted-by-me {
  background: #4a000022;
  border-left: 4px solid #800000;
  border-color: #80000066;
  transition: background 0.4s ease, border-left 0.4s ease;
}

/* Confetti burst */
.confetti-piece {
  position: absolute;
  pointer-events: none;
  z-index: 10;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  transform-origin: center;
  animation: confetti-burst 0.6s ease-out forwards;
}

@keyframes confetti-burst {
  0% { transform: scale(0); opacity: 0; }
  30% { transform: scale(1.4) translate(var(--tx), var(--ty)); opacity: 1; }
  100% { transform: scale(0.1); opacity: 0; }
}

/* === PopBoard 1.3 additions === */

.reply {
  margin-left: 18px;
  margin-top: 6px;
  padding: 6px 8px;
  font-size: 0.85rem;
  background: rgba(0,0,0,0.03);
  border-left: 3px solid var(--border-color);
  border-radius: 4px;
}

.reply-input { margin-top: 6px; }

.upvote.pop {
  animation: pop 0.25s ease;
}

@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

.poll textarea { margin-top: 8px; }

label {
  font-size: 0.85rem;
  margin-left: 4px;
  cursor: pointer;
}

.post button.delete,
.reply button:not(.hide-toggle) {
  margin-left: 6px;
  background: #c75151;
  color: white;
}

.post button.delete:hover,
.reply button:not(.hide-toggle):hover {
  background: #a43f3f;
}

.anonymous {
  font-style: italic;
  color: #555;
}

/* ──────────────────────────────────────────────── */
/* Anonymous Toggle - Improved Spacing & Styling    */
/* ──────────────────────────────────────────────── */

.post-options {
  display: flex;
  align-items: center;
  gap: 6px !important;
  margin-bottom: 8px !important;
}

.post-options input[type="checkbox"] {
  width: auto !important;
  margin: 0 !important;
  cursor: pointer;
}

.post-options label {
  margin: 0 !important;
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
}

/* ──────────────────────────────────────────────── */
/* Teacher Upvote History (NEW – safe addition)     */
/* ──────────────────────────────────────────────── */

#teacherPanel {
  margin: 16px 0;
}

.teacher-panel {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 12px;
}

.teacher-panel h3 {
  margin: 0 0 8px 0;
  font-size: 0.95rem;
  color: var(--text-color);
}

.history-log {
  max-height: 220px;
  overflow-y: auto;
  font-size: 0.8rem;
  line-height: 1.35;
  opacity: 0.9;
}

.history-log div {
  padding: 2px 0;
  border-bottom: 1px dashed var(--border-color);
}

.history-log div:last-child {
  border-bottom: none;
}

/* ──────────────────────────────────────────────── */
/* Per-comment upvote history                       */
/* ──────────────────────────────────────────────── */

.comment-upvote-history {
  margin-top: 8px;
  padding: 8px;
  background: rgba(0,0,0,0.02);
  border-left: 3px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.75rem;
  line-height: 1.4;
  opacity: 0.85;
}

.comment-upvote-history strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.8rem;
}

.comment-upvote-history div {
  padding: 1px 0;
}

/* ──────────────────────────────────────────────── */
/* Hide/Show comment buttons for posts and replies  */
/* ──────────────────────────────────────────────── */

button.hide-toggle,
.reply button.hide-toggle {
  background: var(--button-bg) !important;
  color: var(--button-text) !important;
  border: none;
  border-radius: 4px;
  padding: 4px 8px !important;        /* smaller padding */
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
  font-size: 0.78rem !important;      /* smaller font */
  line-height: 1.2 !important;        /* consistent text height */
  margin-left: 6px !important;
  min-width: auto !important;         /* remove inherited min-width from other buttons */
}

/* Hover state */
button.hide-toggle:hover,
.reply button.hide-toggle:hover {
  background: var(--button-hover-bg) !important;
  color: var(--button-text) !important;
}
