/* Root variables define a modern blue theme reminiscent of Korean financial apps */
:root {
  --primary-color: #2563eb;
  --primary-light: #3b82f6;
  --secondary-color: #f9fafb;
  --text-color: #111827;
  --border-radius: 8px;
  --card-background: #ffffff;
  --card-border: #e5e7eb;
  --danger-color: #dc2626;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
    Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  background-color: var(--secondary-color);
  color: var(--text-color);
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--primary-color);
  color: white;
  padding: 1rem;
}

header h1 {
  margin: 0;
  font-size: 1.5rem;
}

/* Auth buttons container in header */
#auth-buttons {
  display: flex;
  gap: 0.5rem;
}
#auth-buttons .button {
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
}

.panel {
  margin: 1rem;
  padding: 1rem;
  background-color: var(--card-background);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Section header with toggle button for collapsible panels */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.toggle-button {
  appearance: none;
  border: none;
  background-color: transparent;
  color: var(--primary-color);
  cursor: pointer;
  font-size: 0.85rem;
}

/* Collapsed content hidden */
.section-content.collapsed {
  display: none;
}

.settings-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

/* Centre the grade count inputs vertically and horizontally */
#grade-counts {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.settings-block {
  flex: 1;
  min-width: 250px;
  background-color: var(--secondary-color);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius);
  padding: 1rem;
}

.settings-block h3 {
  margin-top: 0;
}

.note {
  font-size: 0.85rem;
  color: #6b7280;
  margin-top: 0.5rem;
}

.file-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.file-actions input[type="file"] {
  flex: 1;
}

.day-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.button {
  appearance: none;
  border: none;
  border-radius: var(--border-radius);
  padding: 0.5rem 1rem;
  cursor: pointer;
  background-color: var(--card-border);
  color: var(--text-color);
  font-size: 0.9rem;
}

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

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

.button.active {
  background-color: var(--primary-light);
  color: white;
}

.teachers {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

/* Teacher cards get a modern look with a soft background and subtle shadow */
.teacher-card {
  flex: 1 1 250px;
  background-color: #f1f5fd;
  border: 1px solid #d1e3ff;
  border-radius: var(--border-radius);
  padding: 0.75rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  position: relative;
}

.teacher-card h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1.1rem;
  color: var(--primary-color);
}

.teacher-info {
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
  color: #374151;
  background-color: #ffffff;
  border: 1px solid #e5efff;
  border-radius: var(--border-radius);
  padding: 0.35rem 0.45rem;
}

/* Inputs inside teacher cards */
.teacher-card input[type="text"] {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid #d1e3ff;
  border-radius: var(--border-radius);
  background-color: #ffffff;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  box-sizing: border-box;
}

.teacher-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  justify-content: center;
}

.auto-assign-container {
  margin-top: 1rem;
  text-align: center;
}

/* Increase size of the auto assign button */
#auto-assign {
  font-size: 1rem;
  padding: 0.75rem 1.5rem;
}

/* Teacher info rows in cards */
.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.info-label {
  font-weight: 600;
  color: #374151;
  margin-right: 0.5rem;
  white-space: nowrap;
}

.info-input {
  flex: 1;
  padding: 0.35rem 0.5rem;
  border: 1px solid #d1e3ff;
  border-radius: var(--border-radius);
  background-color: #ffffff;
  font-size: 0.9rem;
}

/* Adjust text sizes in schedule for better readability */
.subject-input {
  font-size: 1rem;
  padding: 0.5rem;
}

.slot-label {
  font-size: 0.8rem;
}

.slot-teacher {
  font-size: 1rem;
  font-weight: 600;
}

/* Schedule styles */
#schedule-container {
  margin-top: 1rem;
  overflow-x: auto;
}

.day-container {
  margin-bottom: 2rem;
}

.day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.grade-row {
  display: flex;
  gap: 0.5rem;
}

.grade-column {
  flex: 1;
  min-width: 280px;
  border: 1px solid #d1e3ff;
  border-radius: var(--border-radius);
  background-color: #f1f5fd;
  padding: 0.5rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

/* Grade count items styled as small cards */
.grade-count-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background-color: #f1f5fd;
  border: 1px solid #d1e3ff;
  border-radius: var(--border-radius);
  margin-bottom: 0.5rem;
}

.grade-count-item label {
  font-weight: 600;
  color: var(--text-color);
  min-width: 50px;
}

.grade-count-item input {
  width: 60px;
  padding: 0.3rem;
  border: 1px solid #d1e3ff;
  border-radius: var(--border-radius);
  background-color: #ffffff;
  text-align: center;
  font-size: 1rem;
}

.grade-header {
  font-weight: bold;
  margin-bottom: 0.5rem;
}

.period-block {
  margin-bottom: 0.5rem;
  background-color: #ffffff;
  border-radius: var(--border-radius);
  padding: 0.25rem;
  border: 1px solid #e5efff;
}

.subject-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.4rem;
  margin-bottom: 0.4rem;
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius);
  font-size: 0.9rem;
}

.class-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.slot {
  flex: 1 1 calc(25% - 0.25rem);
  /* four per row */
  min-width: 60px;
  height: 56px;
  background-color: var(--card-background);
  border: 1px solid #d1e3ff;
  border-radius: var(--border-radius);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  overflow: hidden;
  cursor: pointer;
}

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

/* Class label inside slots */
.slot-label {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 0.7rem;
  color: #6b7280;
}

/* When slot is assigned, show label in a lighter colour for contrast */
.slot.assigned .slot-label {
  color: rgba(255, 255, 255, 0.8);
}

/* Teacher name inside slots */
.slot-teacher {
  font-weight: bold;
  font-size: 0.9rem;
  z-index: 1;
  color: inherit;
  margin-top: 10px;
  text-align: center;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background-color: var(--card-background);
  border-radius: var(--border-radius);
  padding: 1rem;
  max-width: 400px;
  width: 100%;
}

.unavailable-days {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.unavailable-day {
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius);
  padding: 0.5rem;
}

.unavailable-day h4 {
  margin: 0 0 0.25rem 0;
}

.unavailable-periods {
  display: flex;
  gap: 0.25rem;
}

.unavailable-cell {
  flex: 1;
  text-align: center;
  padding: 0.25rem;
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius);
  cursor: pointer;
  user-select: none;
  font-size: 0.8rem;
}

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

#toast-container {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 2000;
}

.toast {
  background-color: var(--primary-light);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  font-size: 0.85rem;
  opacity: 0;
  animation: fadeIn 0.3s forwards;
}

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

/* Chart styles for assignment bar graph */
#chart-section {
  margin-top: 1rem;
}

#chart-container {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.chart-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chart-label {
  width: 80px;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-bar {
  position: relative;
  flex: 1;
  height: 20px;
  background-color: #e5e7eb;
  border-radius: var(--border-radius);
}

.chart-fill {
  height: 100%;
  background-color: var(--primary-color);
  border-radius: var(--border-radius);
}

.chart-count {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  color: white;
  pointer-events: none;
}

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

/* Chart table styles */
#chart-container table {
  width: 100%;
  border-collapse: collapse;
}
#chart-container th,
#chart-container td {
  border: 1px solid #d1e3ff;
  padding: 0.4rem 0.5rem;
  text-align: left;
  font-size: 0.9rem;
}
#chart-container th {
  background-color: #f1f5fd;
  font-weight: 600;
  color: var(--primary-color);
}