*,*::before,*::after{margin:0;padding:0;box-sizing:border-box}

:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface2: #f7f8fa;
  --surface3: #eef0f4;
  --border: #e2e4e9;
  --border2: #d0d3da;
  --accent: #3b82f6;
  --accent2: #8b5cf6;
  --accent3: #10b981;
  --danger: #ef4444;
  --text: #1e293b;
  --text2: #64748b;
  --text3: #94a3b8;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

body {
  font-family: 'IBM Plex Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Topbar ────────────────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 10;
}

.logo {
  font-family: 'Bebas Neue', cursive;
  font-size: 1.5rem;
  letter-spacing: 3px;
  color: var(--accent);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-display {
  color: var(--text2);
  font-size: 0.85rem;
  margin-right: 0.5rem;
}

.btn-icon {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.85rem;
  border-radius: 8px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-icon:hover { background: var(--surface3); border-color: var(--border2); }

.btn-logout { color: var(--text2); }

/* ─── Dashboard Layout ──────────────────────────────────────────────────── */

.dashboard {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.col {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface);
}

.col-classes { width: 230px; min-width: 190px; background: var(--surface2); }
.col-lfs { width: 360px; min-width: 280px; background: var(--surface); }
.col-boards { flex: 1; background: var(--bg); }

.col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: inherit;
}

.col-header h2 {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}

.col-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

/* ─── Class List ────────────────────────────────────────────────────────── */

.class-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
  margin-bottom: 2px;
}

.class-item:hover { background: var(--surface3); }
.class-item.active { background: var(--surface); box-shadow: var(--shadow-sm); }

.class-dot {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  flex-shrink: 0;
}

.class-name {
  font-size: 0.9rem;
  font-weight: 600;
}

.class-item .btn-delete {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.25rem;
  line-height: 1;
}

.class-item:hover .btn-delete { opacity: 0.6; }
.class-item .btn-delete:hover { opacity: 1; color: var(--danger); }

/* ─── LF Cards ──────────────────────────────────────────────────────────── */

.lf-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 0.5rem;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
}

.lf-card:hover { box-shadow: var(--shadow-md); }

.lf-card-header {
  display: flex;
  align-items: flex-start;
  padding: 0.875rem 1rem;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}

.lf-card-header:hover { background: var(--surface2); }

.lf-color-bar {
  width: 5px;
  min-height: 100%;
  border-radius: 3px;
  margin-right: 0.75rem;
  flex-shrink: 0;
  align-self: stretch;
}

.lf-info { flex: 1; }

.lf-number {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  color: var(--text3);
  margin-bottom: 0.2rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.lf-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.lf-meta {
  font-size: 0.75rem;
  color: var(--text3);
  margin-top: 0.375rem;
}

.lf-actions {
  display: flex;
  gap: 0.25rem;
  margin-left: 0.5rem;
}

.lf-actions button {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 0.25rem;
  font-size: 0.85rem;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.lf-actions button:hover { color: var(--text); background: var(--surface3); }
.lf-actions .btn-delete-lf:hover { color: var(--danger); }

/* LF Card selected state */
.lf-card.selected {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.topic-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s;
  margin-bottom: 2px;
}

.topic-item:hover { background: var(--surface3); }
.topic-item.active { background: #eff6ff; color: var(--accent); font-weight: 500; }

.topic-item .btn-delete-topic {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.125rem 0.25rem;
}

.topic-item:hover .btn-delete-topic { opacity: 0.6; }
.topic-item .btn-delete-topic:hover { opacity: 1; color: var(--danger); }


/* ─── Board Cards ───────────────────────────────────────────────────────── */

.boards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  padding: 0.75rem;
}

.board-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-sm);
}

.board-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-md); }

.board-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}

.board-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.board-thumb-empty {
  color: var(--text3);
  font-size: 0.8rem;
}

.board-card-footer {
  padding: 0.625rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.board-card-name {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.board-card .btn-delete-board {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.125rem 0.25rem;
  flex-shrink: 0;
}

.board-card:hover .btn-delete-board { opacity: 0.6; }
.board-card .btn-delete-board:hover { opacity: 1; color: var(--danger); }

.topic-tag {
  font-size: 0.7rem;
  color: var(--text3);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topic-group-header {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.75rem 0.75rem 0.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topic-group-header:first-child { padding-top: 0.25rem; }

.btn-delete-topic-group {
  opacity: 0.4;
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  transition: opacity 0.15s, color 0.15s;
}

.btn-delete-topic-group:hover { opacity: 1; color: var(--danger); }

/* ─── Buttons ───────────────────────────────────────────────────────────── */

.btn-small {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 0.3rem 0.7rem;
  border-radius: 8px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.75rem;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.btn-small:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.5rem 1.25rem;
  border-radius: 8px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover { background: #2563eb; }

.btn-secondary {
  background: var(--surface);
  color: var(--text2);
  border: 1px solid var(--border);
  padding: 0.5rem 1.25rem;
  border-radius: 8px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-secondary:hover { background: var(--surface3); }

/* ─── Modal ─────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay[hidden] {
  display: none !important;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.modal h3 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.modal input[type="text"],
.modal input[type="number"] {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.9rem;
  outline: none;
  margin-bottom: 0.75rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.modal input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,0.12); }

.modal label {
  display: block;
  font-size: 0.8rem;
  color: var(--text2);
  margin-bottom: 0.25rem;
  font-weight: 500;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* ─── Color Picker Row ──────────────────────────────────────────────────── */

.color-options {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.color-option {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}

.color-option.active,
.color-option:hover {
  border-color: var(--text);
  transform: scale(1.1);
}

/* ─── LF Type Toggle ───────────────────────────────────────────────────── */

.lf-type-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 0.75rem;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.lf-type-btn {
  flex: 1;
  padding: 0.5rem 1rem;
  border: none;
  background: var(--surface2);
  color: var(--text2);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.lf-type-btn.active {
  background: var(--accent);
  color: #fff;
}

.lf-type-btn:not(.active):hover {
  background: var(--surface3);
}

/* ─── Share Modal ───────────────────────────────────────────────────────── */

.modal-share {
  max-width: 480px;
  text-align: center;
}

.share-label {
  color: var(--text2);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.share-url-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.share-url-input {
  flex: 1;
  padding: 0.6rem 0.85rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  outline: none;
}

.share-qr {
  margin: 1rem auto;
}

.share-qr canvas {
  border-radius: 8px;
}

/* ─── Empty State ───────────────────────────────────────────────────────── */

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text3);
  font-size: 0.85rem;
  text-align: center;
  padding: 2rem;
}

/* ─── Scrollbar ─────────────────────────────────────────────────────────── */

.col-body::-webkit-scrollbar { width: 6px; }
.col-body::-webkit-scrollbar-track { background: transparent; }
.col-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ─── Animations ───────────────────────────────────────────────────────── */

@keyframes popUp {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.animate-in {
  animation: popUp 0.3s ease-out both;
}

.animate-in:nth-child(1) { animation-delay: 0.03s; }
.animate-in:nth-child(2) { animation-delay: 0.06s; }
.animate-in:nth-child(3) { animation-delay: 0.09s; }
.animate-in:nth-child(4) { animation-delay: 0.12s; }
.animate-in:nth-child(5) { animation-delay: 0.15s; }
.animate-in:nth-child(6) { animation-delay: 0.18s; }
.animate-in:nth-child(7) { animation-delay: 0.21s; }
.animate-in:nth-child(8) { animation-delay: 0.24s; }
.animate-in:nth-child(9) { animation-delay: 0.27s; }
.animate-in:nth-child(10) { animation-delay: 0.30s; }

/* ─── Responsive ────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .dashboard { flex-direction: column; }
  .col { width: 100% !important; border-right: none; border-bottom: 1px solid var(--border); max-height: 33vh; }
  .col-boards { max-height: none; }
}
