/* IQ.Blazor.Academics Class Manager styles */

:root {
  --color-border-subtle: #e5e7eb;
  --color-bg-page: #ffffff;
  --color-bg-panel: #ffffff;
  --color-bg-muted: #f9fafb;
  --color-bg-header: #f3f4f6;
  --color-text: #111827;
  --color-text-muted: #6b7280;
  --color-accent: #2563eb;
  --color-warning-bg: #fef3c7;
  --color-warning-fg: #b45309;
  --color-danger: #b91c1c;
  --color-level-badge-bg: #eff6ff;
  --color-level-badge-fg: #1d4ed8;
  --color-bulk-bar-bg: #eff6ff;
  --color-bulk-bar-border: #bfdbfe;
  --color-hover: rgba(0,0,0,0.05);
  --color-shadow: rgba(15,23,42,0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-border-subtle: #374151;
    --color-bg-page: #111827;
    --color-bg-panel: #1f2937;
    --color-bg-muted: #374151;
    --color-bg-header: #374151;
    --color-text: #f9fafb;
    --color-text-muted: #9ca3af;
    --color-accent: #3b82f6;
    --color-warning-bg: #78350f;
    --color-warning-fg: #fcd34d;
    --color-danger: #f87171;
    --color-level-badge-bg: #1e3a5f;
    --color-level-badge-fg: #93c5fd;
    --color-bulk-bar-bg: #1e3a5f;
    --color-bulk-bar-border: #3b82f6;
    --color-hover: rgba(255,255,255,0.05);
    --color-shadow: rgba(0,0,0,0.4);
  }
}

.class-manager-view {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--color-bg-page);
  color: var(--color-text);
}

.class-manager-view .top-bar {
  flex-shrink: 0;
  padding: 8px;
}

.class-manager-view .main-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
  --right-panel-width: 420px;
}

.class-manager-view .panel {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.class-manager-view .panel-center {
  flex: 1;
  min-width: 0;
}

.vertical-resizer {
  flex: 0 0 4px;
  cursor: col-resize;
  position: relative;
}
.vertical-resizer::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: var(--color-border-subtle);
}
.vertical-resizer:hover::before,
.main-layout.resizing .vertical-resizer::before {
  background: var(--color-accent);
}

.class-manager-view .panel-right {
  flex: 0 0 var(--right-panel-width);
  min-width: 280px;
  max-width: 70vw;
  border-left: 1px solid var(--color-border-subtle);
}

.class-manager-view .panel-body {
  flex: 1;
  overflow: auto;
}

.filter-bar.card {
  margin: 0;
}

.class-manager-toolbar-checks {
  min-height: 31px;
}

.class-manager-toolbar-checks .form-check-label {
  white-space: nowrap;
}

.timetable-grid {
  display: grid;
  grid-auto-rows: max-content;
  border: 1px solid var(--color-border-subtle);
  background: var(--color-bg-muted);
  font-size: 12px;
  color: var(--color-text);
}

.timetable-header-cell {
  padding: 6px 8px;
  border-bottom: 1px solid var(--color-border-subtle);
  border-right: 1px solid var(--color-border-subtle);
  background: var(--color-bg-header);
  font-weight: 500;
  text-align: center;
}

.timetable-header-holiday {
  color: #dc3545;
  font-size: 11px;
  font-weight: 600;
}

.timetable-header-cell--corner {
  display: flex;
  align-items: center;
  justify-content: center;
}

.timetable-time-cell {
  padding: 6px 8px;
  border-bottom: 1px solid var(--color-border-subtle);
  border-right: 1px solid var(--color-border-subtle);
  font-size: 11px;
  color: var(--color-text-muted);
}

.timetable-slot-cell {
  padding: 4px;
  border-bottom: 1px solid var(--color-border-subtle);
  border-right: 1px solid var(--color-border-subtle);
  min-height: 40px;
  background: var(--color-bg-panel);
}

.student-current-classes {
  margin-top: 2px;
}

.student-class-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--color-border-subtle);
  background: var(--color-bg-muted);
  font-size: 11px;
}

.student-class-pill-name {
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.student-class-pill-remove {
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  padding: 0;
  margin-left: 2px;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.student-class-pill-remove:hover {
  color: var(--color-danger);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.class-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.2);
  flex-shrink: 0;
}

.level-badge {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--color-level-badge-bg);
  color: var(--color-level-badge-fg);
}

.capacity-indicator.over {
  color: var(--color-danger);
  font-weight: 500;
}

.timetable-class-block {
  padding: 6px 8px;
  border-radius: 4px;
  margin: 2px;
}

.class-box-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  padding: 4px;
}

.class-box-block {
  padding: 12px 14px;
  border-radius: 8px;
  margin: 0;
  min-height: 120px;
  border: 1px solid rgba(15, 23, 42, 0.12);
}

.class-box-block .title {
  font-size: 14px;
}

.class-box-block .meta {
  margin-top: 8px;
}

.class-box-schedule {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  font-size: 11px;
  color: var(--color-text-muted);
  line-height: 1.45;
}

.class-box-schedule li + li {
  margin-top: 4px;
}

.timetable-class-block .title {
  font-weight: 600;
  cursor: pointer;
}

.timetable-class-block .inactive-badge {
  margin-left: 4px;
  font-size: 10px;
  font-weight: 500;
  opacity: 0.9;
}

.timetable-class-block .meta {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.students-table {
  font-size: 12px;
}

.checkbox-cell {
  width: 26px;
  text-align: center;
}

/* Multi-dropdown (Groups filter) */
.multi-dropdown {
  position: relative;
}
.multi-dropdown-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--color-border-subtle);
  background: var(--color-bg-panel);
  font-size: 12px;
}
.multi-dropdown-caret { margin-left: 6px; font-size: 10px; }
.multi-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  min-width: 180px;
  max-height: 220px;
  overflow: auto;
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--color-border-subtle);
  background: var(--color-bg-panel);
  box-shadow: 0 4px 12px var(--color-shadow);
  display: none;
}
.multi-dropdown-menu.open { display: block; }
.multi-dropdown-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px;
  font-size: 12px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-border-subtle);
}
.tab {
  padding: 8px 16px;
  border: none;
  background: transparent;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab.active {
  font-weight: 600;
  border-bottom-color: var(--color-accent);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Warnings */
.warnings-list-group { margin-bottom: 12px; }
.warnings-list-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 12px;
}
.badge-warning {
  font-size: 10px;
  padding: 2px 6px;
  background: var(--color-warning-bg);
  color: var(--color-warning-fg);
  border-radius: 4px;
}
.warnings-list-item {
  padding: 6px 8px;
  font-size: 12px;
  cursor: pointer;
  border-radius: 4px;
}
.warnings-list-item:hover { background: var(--color-hover); }

/* Bulk bar */
.students-bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  background: var(--color-bulk-bar-bg);
  border: 1px solid var(--color-bulk-bar-border);
  font-size: 12px;
  margin-bottom: 8px;
}
.students-bulk-bar select {
  border-radius: 4px;
  border: 1px solid var(--color-border-subtle);
  padding: 2px 6px;
  max-width: 180px;
}

/* Drag handle */
.student-drag-handle {
  display: inline-block;
  margin-left: 4px;
  cursor: grab;
  font-size: 11px;
  user-select: none;
}
.timetable-class-block.drag-hover {
  outline: 2px dashed var(--color-accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.25);
}

/* Slot selects, btn-ghost */
.slot-select {
  max-width: 90px;
  font-size: 11px;
  border-radius: 4px;
  border: 1px solid var(--color-border-subtle);
  padding: 1px 4px;
  background: var(--color-bg-panel);
}
.slot-select-wrapper { display: inline-flex; align-items: center; gap: 4px; }
.slot-warning-icon {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--color-warning-bg);
  color: var(--color-warning-fg);
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-ghost {
  background: transparent;
  border: none;
  padding: 2px 6px;
  font-size: 11px;
  cursor: pointer;
}
.btn-ghost:hover { background: var(--color-hover); }

.chip { font-size: 10px; padding: 2px 6px; background: var(--color-bg-header); border-radius: 4px; }

/* Students panel layout - flex column so panel-body can scroll */
.students-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.students-panel .tabs {
  flex-shrink: 0;
}
.students-panel .panel-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

/* Base colors for layout containers */
.class-manager-view .top-bar { background: var(--color-bg-muted); }
.class-manager-view .panel-body { background: var(--color-bg-panel); }
.filter-bar.card { background: var(--color-bg-panel); }
.filter-bar .card-body { background: var(--color-bg-panel); color: var(--color-text); }
.students-panel { background: var(--color-bg-panel); color: var(--color-text); }
.students-table { color: var(--color-text); background: var(--color-bg-panel); }
.students-table td,
.students-table th { color: var(--color-text); background: var(--color-bg-panel); }
.student-name { color: var(--color-text) !important; }
.student-hours-summary.text-muted { color: var(--color-text-muted) !important; }

/* Generic help tour / wizard */
.help-tour-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 9990;
}
.help-tour-highlight {
  position: absolute;
  border-radius: 12px;
  box-shadow: 0 0 0 3px var(--color-bg-panel), 0 0 0 6px var(--color-accent);
  pointer-events: none;
  z-index: 9992;
  transition: all 0.18s ease-out;
}
.help-tour-tooltip {
  position: absolute;
  z-index: 9993;
  max-width: 320px;
}
.help-tour-tooltip-inner {
  background: var(--color-bg-panel);
  color: var(--color-text);
  border-radius: 12px;
  box-shadow: 0 20px 40px var(--color-shadow);
  padding: 12px 14px;
  font-size: 13px;
}
.help-tour-tooltip-inner h3 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
}
.help-tour-tooltip-inner p {
  margin: 0 0 8px;
  line-height: 1.4;
}
.help-tour-meta {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}
.help-tour-controls {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

/* Class editor dialog */
.class-editor-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1040;
}

.class-editor-modal {
  position: fixed;
  inset: 24px;
  z-index: 1050;
  display: flex;
  flex-direction: column;
  max-width: 1120px;
  margin: 0 auto;
  background: var(--color-bg-muted);
  border-radius: 16px;
  box-shadow: 0 24px 48px var(--color-shadow);
  overflow: hidden;
}

.class-editor-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 24px 28px 16px;
  background: var(--color-bg-page);
  border-bottom: 1px solid var(--color-border-subtle);
}

.class-editor-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-border-subtle);
  border-radius: 10px;
  background: var(--color-bg-page);
  color: var(--color-text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.class-editor-back:hover {
  background: var(--color-hover);
}

.class-editor-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}

.class-editor-subtitle {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--color-text-muted);
}

.class-editor-body {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr);
  gap: 20px;
  padding: 20px 28px;
  overflow: auto;
}

.class-editor-main,
.class-editor-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.class-editor-card {
  background: var(--color-bg-page);
  border: 1px solid var(--color-border-subtle);
  border-radius: 14px;
  padding: 20px;
}

.class-editor-card-title {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text);
}

.class-editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.class-editor-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.class-editor-field--full {
  margin-bottom: 14px;
}

.class-editor-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.class-editor-input,
.class-editor-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border-subtle);
  border-radius: 10px;
  background: var(--color-bg-page);
  color: var(--color-text);
  font-size: 14px;
}

.class-editor-input:focus,
.class-editor-select:focus {
  outline: 2px solid rgba(37, 99, 235, 0.25);
  border-color: var(--color-accent);
}

.class-editor-input-suffix {
  position: relative;
}

.class-editor-input-suffix .class-editor-input {
  padding-right: 72px;
}

.class-editor-suffix {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--color-text-muted);
  pointer-events: none;
}

.class-editor-day-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.class-editor-day-pill {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--color-border-subtle);
  background: var(--color-bg-page);
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.class-editor-day-pill.scheduled:not(.active) {
  color: var(--color-accent);
  border-color: rgba(37, 99, 235, 0.35);
}

.class-editor-day-pill.active {
  color: var(--color-accent);
  border-color: var(--color-accent);
  background: rgba(37, 99, 235, 0.08);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.15);
}

.class-editor-slots-heading {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.class-editor-slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.class-editor-slot-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--color-border-subtle);
  border-radius: 12px;
  background: var(--color-bg-page);
  color: var(--color-text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.class-editor-slot-card:hover:not(:disabled) {
  border-color: rgba(37, 99, 235, 0.4);
}

.class-editor-slot-card.selected {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #ffffff;
}

.class-editor-slot-card:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.class-editor-slot-name {
  font-size: 14px;
  font-weight: 700;
}

.class-editor-slot-time {
  font-size: 12px;
  opacity: 0.85;
}

.class-editor-empty-slots {
  margin: 0;
  font-size: 13px;
  color: var(--color-text-muted);
}

.class-editor-appearance {
  margin-bottom: 16px;
}

.class-editor-color-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 6px;
}

.class-editor-color-input {
  width: 44px;
  height: 44px;
  padding: 2px;
  border: 1px solid var(--color-border-subtle);
  border-radius: 10px;
  background: var(--color-bg-page);
  flex-shrink: 0;
  cursor: pointer;
}

.class-editor-color-hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--color-text-muted);
}

.class-editor-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: var(--color-bg-muted);
  margin-bottom: 14px;
}

.class-editor-preview-swatch {
  width: 36px;
  height: 48px;
  border-radius: 8px;
  background: var(--preview-color, #bfdbfe);
  border: 1px solid rgba(15, 23, 42, 0.12);
  flex-shrink: 0;
}

.class-editor-preview-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.class-editor-preview-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.class-editor-preview-meta {
  font-size: 12px;
  color: var(--color-text-muted);
}

.class-editor-inactive {
  padding-top: 4px;
}

.class-editor-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--color-text);
  cursor: pointer;
}

.class-editor-tip {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-radius: 14px;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.18);
}

.class-editor-tip-icon {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--color-accent);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.class-editor-tip-title {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
}

.class-editor-tip-text {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--color-text-muted);
}

.class-editor-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 28px 20px;
  background: var(--color-bg-page);
  border-top: 1px solid var(--color-border-subtle);
}

.class-editor-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}

.class-editor-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.class-editor-btn--secondary {
  background: var(--color-bg-page);
  border-color: var(--color-border-subtle);
  color: var(--color-text);
}

.class-editor-btn--secondary:hover:not(:disabled) {
  background: var(--color-hover);
}

.class-editor-btn--primary {
  background: var(--color-accent);
  color: #ffffff;
}

.class-editor-btn--primary:hover:not(:disabled) {
  filter: brightness(0.95);
}

.class-editor-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 999px;
  animation: class-editor-spin 0.7s linear infinite;
}

@keyframes class-editor-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 900px) {
  .class-editor-modal {
    inset: 12px;
    border-radius: 12px;
  }

  .class-editor-body {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .class-editor-header,
  .class-editor-footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .class-editor-grid {
    grid-template-columns: 1fr;
  }
}
