:root {
  --bg: #e9f0f3;
  --panel: #f1f5f7;
  --muted: #6b7d88;
  --accent: #294c62;
  --accent-2: #3f6978;
  --danger: #ff6b6b;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(20, 30, 40, 0.08);
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
}

/* ----- Alapok / háttér ----- */
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  background:
    repeating-linear-gradient(
      -60deg,
      rgba(0, 0, 0, 0.02) 0px,
      rgba(0, 0, 0, 0.02) 1px,
      transparent 1px,
      transparent 28px
    ),
    repeating-linear-gradient(
      30deg,
      rgba(0, 0, 0, 0.01) 0px,
      rgba(0, 0, 0, 0.01) 1px,
      transparent 1px,
      transparent 48px
    ),
    var(--bg);
  color: #253247;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

/* ----- Topbar ----- */
.topbar {
  text-align: center;
  padding: 36px 20px 10px;
}
.topbar h1 {
  margin: 0;
  font-size: 30px;
  color: var(--accent);
  transform-origin: center;
  animation: fadeInDown 0.5s ease;
}
/* ----- Layout ----- */
.wrap {
  display: flex;
  gap: 24px;
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
  align-items: flex-start;
}

/* ----- Sidebar / Panels ----- */
.sidebar {
  width: 300px;
}
.panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.8), var(--panel));
  padding: 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  border: 1px solid rgba(41, 76, 98, 0.04);
  animation: fadeIn 0.4s ease;
}
.panel h2 {
  margin: 0 0 12px;
  font-size: 16px;
  color: var(--accent);
}
.tool-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ----- Tool buttons (oldalsáv) ----- */
.tool {
  border: 1px solid rgba(41, 76, 98, 0.08);
  background: #fff;
  padding: 10px;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
  color: var(--accent);
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    background 0.12s;
  font-size: 14px;
}
.tool:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(20, 30, 40, 0.06);
}
.tool.active {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: white;
  border-color: transparent;
}

/* ----- Custom input ----- */
.custom-input {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(41, 76, 98, 0.08);
  background: linear-gradient(180deg, #fff, rgba(255, 255, 255, 0.95));
  outline: none;
  box-shadow: 0 2px 6px rgba(41, 76, 98, 0.03) inset;
  transition:
    box-shadow 0.18s,
    border-color 0.18s,
    transform 0.08s;
  font-size: 14px;
}
.custom-input:focus {
  border-color: var(--accent);
  box-shadow: 0 10px 30px rgba(41, 76, 98, 0.06);
  transform: translateY(-1px);
}

/* ----- Buttons ----- */
.accent-btn {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(41, 76, 98, 0.07);
  transition: transform 0.12s ease;
  font-weight: 600;
}
.accent-btn:hover {
  transform: translateY(-3px);
}

.secondary-btn {
  padding: 10px 12px;
  border-radius: 10px;
  background: #f2f5f6;
  border: 1px solid rgba(41, 76, 98, 0.04);
  cursor: pointer;
  color: var(--accent);
}
.primary {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: white;
  border: none;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(41, 76, 98, 0.08);
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease;
}

#generateBtn:disabled {
  opacity: 0.8;
  cursor: not-allowed;
  transform: none;
  filter: grayscale(0.07);
}

/* ----- Students panel ----- */
.students-panel .add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.students-panel input {
  flex: 1;
}
.students-panel button {
  padding: 10px 12px;
  border-radius: 8px;
  border: none;
  background: #eef6fb;
  cursor: pointer;
  color: var(--accent);
}
.students-panel .wide {
  margin-top: 10px;
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: none;
  background: #f2fbff;
  cursor: pointer;
  color: var(--accent);
}
.student-list {
  margin-top: 12px;
  max-height: 260px;
  overflow: auto;
  padding: 8px;
  border-radius: 8px;
  border: 1px dashed rgba(41, 76, 98, 0.04);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.6),
    rgba(255, 255, 255, 0.4)
  );
}
.student-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 6px;
  background: #fff;
  margin-bottom: 8px;
  border: 1px solid rgba(41, 76, 98, 0.03);
  transition: transform 0.12s ease;
}
.student-item:hover {
  transform: translateX(6px);
}
.student-item.assigned {
  opacity: 0.8;
}
.student-item .left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.student-item .badge {
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 12px;
  background: rgba(41, 76, 98, 0.08);
  color: var(--accent);
}
.student-item button {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--danger);
  font-weight: 700;
}

/* ----- Top controls / canvas wrap ----- */
.canvas-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.top-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  align-items: center;
}
.top-controls button {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #e9eefc;
  background: white;
  cursor: pointer;
}

.top-controls__end {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* toggle-grid button specific (should not inherit .tool active styles) */
.toggle-grid-btn {
  border: 1px solid rgba(41, 76, 98, 0.08);
  background: #fff;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--accent);
  cursor: pointer;
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    background-color 0.18s;
}
.toggle-grid-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(20, 30, 40, 0.06);
}

/* ----- Canvas area ----- */
#canvasContainer,
.canvas {
  background: linear-gradient(180deg, #f8fbff, #f3f6f7);
  border-radius: 12px;
  padding: 18px;
  position: relative;
  box-shadow: var(--shadow);
  outline: none;
  overflow: auto;
  min-height: 200px;
}

#canvasContainer {
  width: 900px;
  height: 520px;
}

/* dotted grid background (visible when snap / grid enabled) */
/* animation for grid pulse on toggle */
#canvasContainer::before,
.canvas::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background-image: radial-gradient(
    rgba(41, 76, 98, 0.03) 1px,
    transparent 1px
  );
  background-size: 18px 18px;
  opacity: 0.45;
  pointer-events: none;
  border-radius: 10px;
  transition:
    opacity 0.24s ease,
    transform 0.22s ease;
}
#canvasContainer.snap::before,
.canvas.snap::before {
  opacity: 0.9;
}
#canvasContainer.grid-anim::before {
  animation: gridPulse 0.55s ease;
}

/* ----- Desk styles ----- */
.desk {
  position: absolute;
  min-width: 150px;
  max-width: 260px;
  background: var(--panel);
  border-radius: 8px;
  border: 1px solid rgba(41, 76, 98, 0.06);
  box-shadow: 0 10px 30px rgba(20, 30, 40, 0.06);
  cursor: grab;
  user-select: none;
  padding: 6px;
  transform-origin: left top;
  transition:
    left 0.12s ease,
    top 0.12s ease,
    transform 0.12s ease,
    box-shadow 0.12s ease;
}
.desk.pop {
  animation: popIn 0.28s cubic-bezier(0.2, 0.9, 0.2, 1);
}
.desk .desk-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-bottom: 1px solid rgba(41, 76, 98, 0.03);
}
.desk .desk-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
}
.desk .small-btn {
  border: none;
  background: #f3f6ff;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--accent);
}
.desk .seat-row {
  display: flex;
  gap: 6px;
  padding: 6px;
  flex-wrap: wrap;
}

/* selected desk */
.desk.selected {
  box-shadow: 0 18px 46px rgba(20, 30, 50, 0.14);
  transform: translateY(-6px);
  z-index: 50;
  border-color: rgba(41, 76, 98, 0.12);
}

/* ----- Seat and student chip ----- */
.seat {
  min-width: 80px;
  max-width: 180px;
  min-height: 40px;
  border-radius: 6px;
  border: 1px dashed transparent;
  background: #fbfdff;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 6px;
  box-sizing: border-box;
  overflow: hidden;
  text-align: center;
  transition:
    background 0.12s ease,
    transform 0.12s ease,
    box-shadow 0.12s ease;
}
.seat.empty {
  color: var(--muted);
  font-size: 13px;
}
.seat.flash {
  animation: seatFlash 0.36s ease;
}
.student-chip {
  display: block;
  max-width: 100%;
  word-break: break-word;
  white-space: normal;
  padding: 6px 8px;
  border-radius: 12px;
  background: #eef6fb;
  border: 1px solid rgba(41, 76, 98, 0.08);
  cursor: grab;
  color: var(--accent);
  font-size: 13px;
  line-height: 1.1;
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease;
}
.student-chip.dragging {
  transform: scale(0.98) rotate(-2deg);
  box-shadow: 0 18px 40px rgba(20, 30, 50, 0.12);
}

/* tanári hely */
.seat[data-type="teacher"] {
  min-width: 140px;
  min-height: 48px;
  background: #fff7e6;
  border: 1px solid #fde3a7;
}

.statusbar {
  margin-top: 12px;
  padding: 10px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

/* canvas hint */
.canvas-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: var(--muted);
  text-align: center;
  pointer-events: none;
  animation: fadeIn 0.5s ease;
  font-size: 14px;
}

/* ----- Modal ----- */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  align-items: center;
  justify-content: center;
  z-index: 1200;
}
.modal[aria-hidden="false"] {
  display: flex;
}
.modal-content {
  width: 420px;
  max-width: 95%;
  background: linear-gradient(180deg, #fff, #fbfdff);
  padding: 18px;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(20, 40, 60, 0.25);
  border: 1px solid rgba(41, 76, 98, 0.06);
  transform-origin: center;
}
.modal-animate {
  animation: modalPop 0.28s cubic-bezier(0.2, 0.9, 0.2, 1);
}

/* modal vertical layout for configurator fields */
.modal-row-vertical {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}
.modal-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

/* ----- Live preview inside modal ----- */
.live-preview {
  margin-top: 12px;
}
.preview-info {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}
.preview-frame {
  width: 100%;
  height: 160px;
  border-radius: 8px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.6),
    rgba(255, 255, 255, 0.4)
  );
  border: 1px dashed rgba(41, 76, 98, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  box-sizing: border-box;
}
.canvas-preview {
  width: 100px;
  height: 60px;
  background: linear-gradient(180deg, #ffffff, #f1f6fa);
  border-radius: 4px;
  border: 1px solid rgba(41, 76, 98, 0.06);
  box-shadow: 0 8px 20px rgba(20, 30, 40, 0.06) inset;
  transition:
    width 0.18s ease,
    height 0.18s ease,
    transform 0.18s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--muted);
  user-select: none;
}

/* ----- Toast / Notifications ----- */
.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1500;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  min-width: 200px;
  max-width: 360px;
  padding: 10px 14px;
  border-radius: 10px;
  color: white;
  box-shadow: 0 8px 20px rgba(20, 40, 60, 0.18);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 0.22s,
    transform 0.22s;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast.info {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.toast.success {
  background: linear-gradient(90deg, #2a9d8f, #57c6a6);
}
.toast.error {
  background: linear-gradient(90deg, #ff6b6b, #ff9b9b);
}

/* ----- Keyframes / Animations ----- */
@keyframes popIn {
  0% {
    transform: translateY(8px) scale(0.96);
    opacity: 0;
  }
  60% {
    transform: translateY(-6px) scale(1.02);
    opacity: 1;
  }
  100% {
    transform: translateY(0) scale(1);
  }
}
@keyframes seatFlash {
  0% {
    box-shadow: 0 0 0 rgba(41, 76, 98, 0);
    background: #fff;
  }
  40% {
    box-shadow: 0 0 24px rgba(41, 76, 98, 0.08);
    background: #eaf6ff;
  }
  100% {
    box-shadow: 0 0 0 rgba(41, 76, 98, 0);
    background: #fbfdff;
  }
}
@keyframes modalPop {
  0% {
    transform: translateY(10px) scale(0.98);
    opacity: 0;
  }
  60% {
    transform: translateY(-6px) scale(1.02);
    opacity: 1;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes gridPulse {
  0% {
    opacity: 0.9;
    transform: scale(0.995);
  }
  50% {
    opacity: 1;
    transform: scale(1.002);
  }
  100% {
    opacity: 0.9;
    transform: scale(1);
  }
}

/* ----- Small helpers ----- */
.muted {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
