/* MSTRC Tutor Scheduler — Styles */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #dde1e6;
  --text: #21272a;
  --text-secondary: #697077;
  --primary: #0f62fe;
  --primary-hover: #0353e9;
  --success: #24a148;
  --success-light: #defbe6;
  --warning: #f1c21b;
  --warning-light: #fff8e1;
  --danger: #da1e28;
  --danger-light: #fff1f1;
  --info: #4589ff;
  --info-light: #edf5ff;
  --available: #a7f0ba;
  --preferred: #78a9ff;
  --blocked: #e0e0e0;
  --gap: #ffb3b8;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
}

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

body {
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}

/* ─── Layout ─── */

.app-shell {
  min-height: 100vh;
}

.app-header {
  background: var(--text);
  color: white;
  padding: 0 24px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.app-header nav {
  display: flex;
  gap: 4px;
}

.app-header nav a {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  padding: 4px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}

.app-header nav a:hover,
.app-header nav a.router-link-active {
  color: white;
  background: rgba(255,255,255,0.12);
}

.app-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

/* ─── Cards ─── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h2 {
  font-size: 15px;
  font-weight: 600;
}

.card-body {
  padding: 20px;
}

/* ─── Buttons ─── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

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

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover { background: #198038; }

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

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline:hover { background: var(--info-light); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg); }

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ─── Forms ─── */

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(15, 98, 254, 0.15);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23697077' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

/* ─── Tables ─── */

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg);
}

tbody tr:hover {
  background: #f9fafb;
}

/* ─── Badges & Tags ─── */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

.badge-success { background: var(--success-light); color: #0e6027; }
.badge-warning { background: var(--warning-light); color: #8a6d00; }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: #0043ce; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  background: var(--bg);
  border-radius: var(--radius);
  font-size: 12px;
  margin: 2px;
}

/* ─── Stats Row ─── */

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

/* ─── Availability Grid ─── */

.avail-grid-wrap {
  overflow-x: auto;
}

.avail-grid {
  display: grid;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  user-select: none;
}

.avail-grid .grid-header {
  background: var(--bg);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  padding: 8px 4px;
  color: var(--text-secondary);
}

.avail-grid .grid-time {
  background: var(--bg);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 8px;
  text-align: right;
  color: var(--text-secondary);
  white-space: nowrap;
}

.avail-grid .grid-cell {
  background: var(--surface);
  min-height: 24px;
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
}

.avail-grid .grid-cell:hover {
  filter: brightness(0.92);
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.avail-grid.dragging { cursor: crosshair; }
.avail-grid.dragging .grid-cell { cursor: crosshair; }
.avail-grid .grid-cell.drag-preview {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.avail-grid .grid-cell.available {
  background: var(--available);
}

.avail-grid .grid-cell.preferred {
  background: var(--preferred);
}

.avail-grid .grid-cell.blocked {
  background: var(--blocked);
  cursor: not-allowed;
}

.avail-grid .grid-cell.blocked::after {
  content: '✕';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  color: #888;
}

/* ─── Schedule Grid ─── */

.schedule-grid {
  display: grid;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.schedule-grid .grid-header {
  background: var(--bg);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  padding: 10px 4px;
  color: var(--text-secondary);
}

.schedule-grid .grid-time {
  background: var(--bg);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 8px;
  text-align: right;
  color: var(--text-secondary);
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.schedule-grid .grid-cell {
  background: var(--surface);
  min-height: 28px;
  padding: 2px 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  align-items: center;
}

.tutor-chip {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
}

.tutor-chip.in_person {
  background: #d4edda;
  color: #155724;
}

.tutor-chip.zoom {
  background: #cce5ff;
  color: #004085;
}

/* ─── Coverage Heatmap ─── */

.heatmap-cell {
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
}

.heatmap-cell.coverage-full { background: var(--available); color: #0e6027; }
.heatmap-cell.coverage-adequate { background: #fff3cd; color: #8a6d00; }
.heatmap-cell.coverage-gap { background: var(--gap); color: var(--danger); }
.heatmap-cell.coverage-none { background: var(--surface); }

/* ─── Tab Switcher ─── */

.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
}

.tab {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}

.tab:hover { color: var(--text); }

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ─── Alert ─── */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
}

.alert-info { background: var(--info-light); color: #0043ce; border: 1px solid #a6c8ff; }
.alert-success { background: var(--success-light); color: #0e6027; border: 1px solid #6fdc8c; }
.alert-warning { background: var(--warning-light); color: #8a6d00; border: 1px solid #fddc69; }
.alert-danger { background: var(--danger-light); color: var(--danger); border: 1px solid #ffb3b8; }

/* ─── Tutor Login ─── */

.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
}

.login-card {
  width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 40px;
  text-align: center;
}

.login-card h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

.login-card p {
  color: var(--text-secondary);
  margin-bottom: 24px;
  font-size: 13px;
}

.pin-input {
  font-size: 32px;
  text-align: center;
  letter-spacing: 12px;
  padding: 12px;
  font-weight: 600;
  width: 200px;
}

/* ─── Misc ─── */

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--text-secondary); }
.text-center { text-align: center; }
.w-full { width: 100%; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ─── Grid Legend ─── */

.grid-legend {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

.grid-legend span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid var(--border);
}

/* ─── Modal ─── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-md);
  width: 90%;
}

/* ─── Coverage Editor ─── */

.cov-editor {
  user-select: none;
}

.cov-layout {
  display: flex;
  gap: 16px;
}

.cov-grid-wrap {
  flex: 1;
  overflow-x: auto;
}

.cov-grid {
  display: grid;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 500px;
}

.cov-header {
  background: var(--bg);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  padding: 8px 4px;
  color: var(--text-secondary);
}

.cov-time {
  background: var(--bg);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 6px;
  text-align: right;
  color: var(--text-secondary);
  white-space: nowrap;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
}

.cov-cell {
  background: var(--surface);
  min-height: 32px;
  padding: 2px 4px;
  cursor: pointer;
  transition: background 0.1s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  position: relative;
}

.cov-cell:hover { background: #f0f4ff; }

.cov-cell.cov-minimal { background: #eff6ff; }
.cov-cell.cov-low { background: #dbeafe; }
.cov-cell.cov-medium { background: #93c5fd; }
.cov-cell.cov-high { background: #60a5fa; }

.cov-cell.cov-drag {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  z-index: 1;
}

.cov-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.cov-subjects {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  justify-content: center;
}

.cov-subj-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  color: white;
  line-height: 1;
  flex-shrink: 0;
}

/* Edit panel */
.cov-panel {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  align-self: flex-start;
  position: sticky;
  top: 60px;
}

.cov-panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}

.cov-panel-section {
  padding: 12px 16px;
}

.cov-panel-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.cov-panel-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 0;
}

/* ─── Toast Notification ─── */

.toast {
  position: fixed;
  top: 60px;
  right: 20px;
  padding: 12px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  font-weight: 500;
  z-index: 200;
  animation: slideIn 0.25s ease-out;
  max-width: 360px;
}

.toast-success { background: var(--success); color: white; }
.toast-error { background: var(--danger); color: white; }
.toast-warning { background: #e67e22; color: white; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ─── Responsive ─── */

@media (max-width: 768px) {
  .app-content { padding: 12px; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .form-row { flex-direction: column; }

  /* Header: stack title and nav */
  .app-header {
    flex-direction: column;
    height: auto;
    padding: 10px 16px;
    gap: 6px;
  }
  .app-header h1 { font-size: 14px; }
  .app-header nav {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }
  .app-header nav a { padding: 4px 8px; font-size: 12px; }

  /* Schedule grid: horizontal scroll with minimum column width */
  .schedule-grid {
    min-width: 600px;
  }
  .schedule-grid .grid-cell {
    min-height: 24px;
    padding: 1px 2px;
  }
  .tutor-chip { font-size: 9px; padding: 0 4px; }

  /* Coverage heatmap: also scroll */
  .heatmap-cell { font-size: 9px; min-height: 24px; }

  /* Tables: horizontal scroll wrapper */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  th, td { padding: 8px 10px; font-size: 12px; white-space: nowrap; }

  /* Availability grid */
  .avail-grid .grid-time { font-size: 10px; padding: 2px 4px; }
  .avail-grid .grid-cell { min-height: 20px; }

  /* Login card */
  .login-card { width: 90vw; padding: 24px; }

  /* Coverage gaps table - ensure scroll */
  .card-body.table-wrap { overflow-x: auto; }
}

/* ─── Checkbox ─── */

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s;
}

.checkbox-item:hover { background: #edf0f3; }

.checkbox-item input[type="checkbox"] {
  accent-color: var(--primary);
}

/* ─── Solver Status ─── */

.solve-status {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.solve-status .status-icon { font-size: 24px; }

/* ─── Schedule class entry ─── */

.class-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.class-entry:last-child { border-bottom: none; }

.class-entry .class-info { flex: 1; font-size: 13px; }

/* ─── Mode toggle ─── */

.mode-toggle {
  display: inline-flex;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 2px;
  border: 1px solid var(--border);
}

.mode-toggle button {
  padding: 4px 12px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
  color: var(--text-secondary);
}

.mode-toggle button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
