/* Custom Properties & Design System */
:root {
  --font-primary: 'Outfit', 'Noto Sans KR', sans-serif;
  
  /* Color Palette (Deep dark theme with vibrant accents) */
  --bg-main: #0B0F19;
  --bg-sidebar: rgba(17, 24, 39, 0.7);
  --bg-card: rgba(30, 41, 59, 0.45);
  --bg-card-active: rgba(59, 130, 246, 0.15);
  --bg-aisle: rgba(255, 255, 255, 0.02);
  --bg-modal: rgba(15, 23, 42, 0.95);
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-glow: rgba(59, 130, 246, 0.4);
  
  --text-main: #F1F5F9;
  --text-muted: #94A3B8;
  --text-accent: #60A5FA;
  
  /* Primary & Accent Buttons */
  --color-primary: #3B82F6;
  --color-primary-hover: #2563EB;
  --color-secondary: rgba(51, 65, 85, 0.5);
  --color-secondary-hover: rgba(51, 65, 85, 0.8);
  --color-danger: #EF4444;
  --color-danger-hover: #DC2626;
  
  /* Shadows and Blurs */
  --blur-sidebar: 16px;
  --blur-card: 12px;
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.5);
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base resets & styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-primary);
  background-color: var(--bg-main);
  color: var(--text-main);
  overflow: hidden;
  height: 100vh;
  display: flex;
}

/* App container */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  position: relative;
}

/* Sidebar Styling */
.sidebar {
  width: 320px;
  height: 100%;
  background: var(--bg-sidebar);
  backdrop-filter: blur(var(--blur-sidebar));
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 10;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.icon-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--text-accent);
  color: var(--text-accent);
  transform: rotate(45deg);
}

/* History List Container */
.history-list-wrapper {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* Customize scrollbar */
.history-list-wrapper::-webkit-scrollbar {
  width: 6px;
}
.history-list-wrapper::-webkit-scrollbar-track {
  background: transparent;
}
.history-list-wrapper::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}
.history-list-wrapper::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.no-history {
  color: var(--text-muted);
  text-align: center;
  padding: 40px 0;
  font-size: 0.9rem;
}

.history-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-color-glow);
  transform: translateY(-2px);
}

.history-item.active {
  background: var(--bg-card-active);
  border-color: var(--color-primary);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.2);
}

.history-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-date {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-main);
}

.history-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.history-item-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.history-item-delete:hover {
  color: var(--color-danger);
  background: rgba(239, 68, 68, 0.1);
}

.sidebar-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border-color);
}

.stats-text {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.stats-text span {
  font-weight: 600;
  color: var(--text-accent);
}

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  background: radial-gradient(circle at top right, rgba(59, 130, 246, 0.05), transparent 60%);
}

.main-header {
  height: 80px;
  padding: 0 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.main-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #FFF, #94A3B8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Classroom Styling */
.classroom-area {
  flex: 1;
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 40px;
  overflow: auto;
}

.teacher-desk-wrapper {
  width: 100%;
  max-width: 900px;
  display: flex;
  justify-content: center;
}

.teacher-desk {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01));
  border: 1px solid var(--border-color);
  width: 280px;
  padding: 12px 0;
  text-align: center;
  border-radius: 12px;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 600;
  position: relative;
  box-shadow: var(--shadow-lg);
}

.teacher-desk::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 10%;
  width: 80%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-primary), transparent);
}

.grid-container-wrapper {
  width: 100%;
  max-width: 960px;
}

/* 5 Rows x 8 Columns grid */
.seating-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 20px;
  perspective: 1000px;
}

/* Seat item */
.seat-cell {
  aspect-ratio: 1.4 / 1;
  border-radius: 12px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(var(--blur-card));
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), 
              border-color 0.3s, background-color 0.3s, box-shadow 0.3s;
  user-select: none;
}

/* Desk card details */
.seat-cell .seat-label {
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}

.seat-cell .student-number {
  transform: scale(1);
  transition: transform 0.3s ease;
}

.seat-cell.has-student {
  border-color: var(--border-color-glow);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(30, 41, 59, 0.6));
}

.seat-cell.has-student:hover {
  transform: translateY(-5px) scale(1.03);
  border-color: var(--text-accent);
  box-shadow: 0 10px 20px rgba(59, 130, 246, 0.15);
}

/* Aisle styling (Column 3 and Column 6 empty path) */
.aisle-cell {
  aspect-ratio: 1.4 / 1;
  border: none;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.aisle-cell::before {
  content: '';
  width: 2px;
  height: 60%;
  background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.03), transparent);
}

/* Shuffle/Drawing Animation Classes */
.seat-cell.shuffling {
  animation: shuffleAnimation 0.15s infinite alternate;
  border-color: var(--color-primary);
  background: rgba(59, 130, 246, 0.08);
}

.seat-cell.drawn {
  animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes shuffleAnimation {
  0% { transform: translateY(-1px) rotate(-0.5deg); }
  100% { transform: translateY(1px) rotate(0.5deg); }
}

@keyframes popIn {
  0% {
    transform: scale(0.85);
    opacity: 0.5;
  }
  70% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Controls bottom area */
.controls-area {
  height: 100px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-top: 1px solid var(--border-color);
  background: linear-gradient(to top, rgba(11, 15, 25, 0.9), rgba(11, 15, 25, 0));
  z-index: 5;
}

/* Custom Buttons */
.btn {
  font-family: var(--font-primary);
  font-weight: 600;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  transform: translateY(-2px);
}

.btn-secondary {
  background: var(--color-secondary);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 10px 20px;
  font-size: 0.9rem;
}

.btn-secondary:hover {
  background: var(--color-secondary-hover);
  border-color: var(--text-muted);
}

.btn-danger {
  background: var(--color-danger);
  color: white;
}

.btn-danger:hover {
  background: var(--color-danger-hover);
}

/* Specially designed Draw Button */
.btn-draw {
  position: relative;
  padding: 16px 48px;
  font-size: 1.2rem;
  border-radius: 16px;
  box-shadow: 0 8px 30px rgba(59, 130, 246, 0.3);
  overflow: hidden;
}

.btn-draw:hover {
  box-shadow: var(--shadow-glow);
}

.btn-draw:active {
  transform: translateY(1px);
}

.btn-draw .btn-text {
  position: relative;
  z-index: 2;
  letter-spacing: 0.05em;
}

.btn-draw .btn-glow {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), transparent);
  z-index: 1;
}

/* Modal Window Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  background: var(--bg-modal);
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 500px;
  border-radius: 24px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(1);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.hidden .modal-content {
  transform: scale(0.9);
}

.modal-header {
  padding: 24px 30px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.8rem;
  cursor: pointer;
  transition: var(--transition-smooth);
  line-height: 1;
}

.close-btn:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Settings fields & presets */
.setting-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.setting-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

.setting-description {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.range-presets {
  display: flex;
  gap: 8px;
}

.preset-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 10px 0;
  border-radius: 8px;
  color: var(--text-muted);
  font-family: var(--font-primary);
  font-weight: 500;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.preset-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
}

.preset-btn.active {
  background: var(--bg-card-active);
  border-color: var(--color-primary);
  color: var(--text-accent);
}

/* Custom inputs for custom range */
.custom-range-inputs {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

.input-field {
  flex: 1;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0 12px;
}

.input-field span {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-right: 8px;
}

.input-field input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-main);
  padding: 10px 0;
  font-family: var(--font-primary);
  font-size: 0.9rem;
  font-weight: 600;
  outline: none;
}

/* Toggle switch */
.toggle-group {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}

.setting-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 75%;
}

.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: .4s;
  border: 1px solid var(--border-color);
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
}

input:checked + .slider {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

input:focus + .slider {
  box-shadow: 0 0 1px var(--color-primary);
}

input:checked + .slider:before {
  transform: translateX(24px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

/* Danger zone section */
.danger-zone {
  border-top: 1px solid var(--border-color);
  padding-top: 24px;
}

.text-danger {
  color: var(--color-danger);
}

.danger-zone .btn-danger {
  margin-top: 8px;
  padding: 12px;
  font-size: 0.85rem;
}

.modal-footer {
  padding: 20px 30px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
}

.modal-footer .btn {
  padding: 12px 30px;
  font-size: 0.95rem;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .sidebar {
    width: 260px;
  }
  .seating-grid {
    gap: 12px;
  }
}
