/* layout.css - App shell, header, views, slot panel */

/* ── App screen layout ───────────────────────────────────────────────────── */

#screen-app {
  display: grid;
  grid-template-rows: auto auto 1fr;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "header  header"
    "filter  filter"
    "main    panel";
  height: 100%;
  overflow: hidden;
}

/* ── Header ──────────────────────────────────────────────────────────────── */

#app-header {
  grid-area: header;
  background: var(--color-primary-dark);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 52px;
  flex-shrink: 0;
}

.header-logo { height: 30px; width: auto; }

.app-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* Breadcrumb */
#breadcrumb {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  overflow: hidden;
}
.bc-item { color: rgba(255,255,255,0.7); white-space: nowrap; }
.bc-current { color: #fff; font-weight: 600; }
.bc-link { cursor: pointer; }
.bc-link:hover { color: #fff; text-decoration: underline; }
.bc-sep { color: rgba(255,255,255,0.4); font-size: 16px; line-height: 1; }

/* Right side of header */
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

#user-name {
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
}

#term-select {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 13px;
  cursor: pointer;
}
#term-select:disabled { opacity: 0.5; cursor: default; }
#term-select option { background: var(--color-primary-dark); }

#app-header .btn-text { color: rgba(255,255,255,0.75); font-size: 13px; }
#app-header .btn-text:hover { color: #fff; }

.zoom-control {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
.zoom-icon {
  font-size: 13px;
  opacity: 0.7;
  user-select: none;
}
#week-zoom {
  width: 80px;
  accent-color: rgba(255,255,255,0.8);
  cursor: pointer;
  opacity: 0.85;
}
#week-zoom:hover { opacity: 1; }

/* ── Teacher filter bar ──────────────────────────────────────────────────── */

#filter-bar {
  grid-area: filter;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  /* overflow must stay visible so the teachers dropdown can escape this bar */
  overflow: visible;
}

.filter-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#teacher-filter-list {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
  overflow-x: auto;
  flex: 1;
  min-width: 0;
}
#teacher-filter-list::-webkit-scrollbar { height: 4px; }
#teacher-filter-list::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 2px; }

/* ── Main content ────────────────────────────────────────────────────────── */

#app-main {
  grid-area: main;
  overflow: auto;
  position: relative;
}

.view-container {
  min-height: 100%;
}

/* ── Phase 1 status placeholder ─────────────────────────────────────────── */

.status-card {
  max-width: 480px;
  margin: 60px auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  box-shadow: 0 2px 16px var(--color-shadow);
}

.status-icon {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: #DCFCE7;
  color: #16A34A;
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.status-error .status-icon {
  background: #FEE2E2;
  color: #DC2626;
}

.status-card h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--color-text);
}

.status-card p {
  color: var(--color-text-muted);
  font-size: 14px;
  margin-bottom: 6px;
}

.status-hint {
  font-size: 12px !important;
  margin-top: 12px;
  color: var(--color-text-muted);
  font-style: italic;
}

.teacher-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 20px;
}

.teacher-chip {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 500;
}

/* ── Slot panel ──────────────────────────────────────────────────────────── */

#slot-panel {
  grid-area: panel;
  width: 360px;
  border-left: 1px solid var(--color-border);
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

#slot-panel.open  { transform: translateX(0); }
#slot-panel.hidden { display: none; }

.slot-panel-header {
  background: var(--color-primary-dark);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.slot-panel-header button {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border-radius: var(--radius-sm);
  width: 28px; height: 28px;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.slot-panel-header button:hover { background: rgba(255,255,255,0.25); }

#slot-panel-title {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#slot-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* ── Setup modal ─────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 900;
}

.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.modal-dialog {
  position: relative;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 48px rgba(0,0,0,0.25);
  width: min(740px, 96vw);
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}

.modal-header {
  background: var(--color-primary-dark);
  color: #fff;
  padding: 14px 20px;
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0;
}

.modal-header h2 { font-size: 16px; font-weight: 700; flex: 1; }

.modal-header .btn-icon {
  color: rgba(255,255,255,0.8);
  font-size: 22px;
}
.modal-header .btn-icon:hover { color: #fff; background: rgba(255,255,255,0.15); }

.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  flex-shrink: 0;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  margin-bottom: -1px;
}
.tab-btn:hover  { color: var(--color-text); }
.tab-btn.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

.modal-body {
  overflow-y: auto;
  flex: 1;
  padding: 20px;
}

/* ── Setup panel content ─────────────────────────────────────────────────── */

.setup-section { }

.setup-section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}

.setup-section-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text);
}

.setup-select {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 13px;
  background: var(--color-surface);
  color: var(--color-text);
  min-width: 180px;
}

.setup-list { margin-top: 8px; }

.setup-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  margin-bottom: 6px;
}

.setup-row-active { border-color: var(--color-primary); background: var(--color-primary-light); }

.setup-row-link {
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.setup-row-link:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
}

.setup-row-chevron {
  font-size: 18px;
  color: var(--color-text-muted);
  line-height: 1;
  flex-shrink: 0;
}

.setup-back-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.setup-back-btn {
  font-size: 15px;
  padding: 0 4px;
  color: var(--color-primary);
}

.setup-row-info {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; flex: 1; min-width: 0;
}

.setup-row-info strong { font-size: 13px; }

.setup-row-meta {
  font-size: 12px;
  color: var(--color-text-muted);
}

.setup-row-actions {
  display: flex; align-items: center; gap: 4px;
  flex-shrink: 0;
}

.badge-active {
  background: var(--color-primary);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* ── Setup forms ─────────────────────────────────────────────────────────── */

.setup-form {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

.setup-form h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 12px;
}

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

.form-row label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; font-weight: 600; color: var(--color-text-muted);
  flex: 1;
}

.form-row-2 label { flex: 1; }
.form-row-3 label { flex: 1; }

.form-row input,
.form-row select,
.form-row textarea {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  width: 100%;
  transition: border-color var(--transition);
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.form-row textarea { resize: vertical; min-height: 56px; }

.form-check {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--color-text);
  margin-bottom: 12px; cursor: pointer;
}
.form-check input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; }

.form-actions {
  display: flex; align-items: center; gap: 8px;
  margin-top: 12px;
}

/* ── Availability toolbar (Add Slot + Teacher Notes side by side) ─────────── */

.avail-toolbar {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.avail-toolbar-left { flex-shrink: 0; padding-top: 4px; }

.teacher-notes-box {
  flex: 1;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.teacher-notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.teacher-notes-header span {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#teacher-notes-text {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-bg);
  resize: vertical;
  min-height: 60px;
  transition: border-color var(--transition);
}
#teacher-notes-text:focus { outline: none; border-color: var(--color-primary); }

.setup-empty   { font-size: 13px; color: var(--color-text-muted); padding: 12px 0; }
.setup-loading { font-size: 13px; color: var(--color-text-muted); padding: 12px 0; font-style: italic; }
.setup-error   { font-size: 13px; color: #DC2626; padding: 12px 0; }

/* ── Week View ───────────────────────────────────────────────────────────── */

.week-grid {
  display: grid;
  border-top: 1px solid var(--color-border);
  border-left: 1px solid var(--color-border);
  /* grid-template-columns set inline per teacher count */
}

/* Sticky corner (top-left) */
.week-corner {
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  border-bottom: 2px solid var(--color-border);
  position: sticky;
  top: 0;
  left: 0;
  z-index: 20;
}

/* Teacher name headers — sticky top, click to navigate */
.week-teacher-header {
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  border-bottom: 2px solid var(--color-border);
  padding: 7px 6px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  color: var(--color-text);
  cursor: pointer;
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background var(--transition), color var(--transition);
  user-select: none;
}
.week-teacher-header:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

/* Day labels — sticky left, click to navigate */
.week-day-label {
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  position: sticky;
  left: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
  user-select: none;
}
.week-day-label:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

/* Teacher-day cells */
.week-cell {
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  padding: 4px 3px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  cursor: pointer;
  background: var(--color-bg);
  transition: opacity var(--transition);
  min-width: 64px;
}
.week-cell:hover { opacity: 0.75; }

/* Mini blocks — one per 30-min slot (26 total, 7am–8pm) */
.mini-block {
  height: var(--week-slot-height, 7px);
  border-radius: 1px;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.mini-block-label {
  display: none;
  font-size: 9px;
  font-weight: 600;
  line-height: 1;
  color: rgba(0,0,0,0.65);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 1px 3px 0;
  pointer-events: none;
}

#view-week.week-zoomed .mini-block-label {
  display: block;
}

.mini-block-venue {
  display: none;
  font-size: 9px;
  font-weight: 400;
  line-height: 1;
  color: rgba(0,0,0,0.45);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 0 3px;
  pointer-events: none;
}

#view-week.week-zoomed-detail .mini-block-venue {
  display: block;
}
.mini-block.unavailable   { background: var(--color-unavailable); }
.mini-block.avail-ip      { background: var(--color-avail-ip); box-shadow: inset 0 0 0 1px var(--color-border); }
.mini-block.avail-online  { background: var(--color-avail-online); }
.mini-block.booked-ip     { background: var(--color-booked-ip); }
.mini-block.booked-online { background: var(--color-booked-online); }
.mini-block.meeting       { background: var(--color-meeting); }
.mini-block.admin         { background: var(--color-admin); }
.mini-block.hold          { background: var(--color-hold); }

/* Empty-state message */
.week-empty {
  padding: 60px 40px;
  color: var(--color-text-muted);
  font-size: 14px;
}

/* ── Day View ────────────────────────────────────────────────────────────── */

.day-grid {
  display: grid;
  border-top: 1px solid var(--color-border);
  border-left: 1px solid var(--color-border);
}

/* Sticky corner — day name + prev/next nav */
.day-corner {
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  border-bottom: 2px solid var(--color-border);
  position: sticky;
  top: 0;
  left: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  gap: 2px;
}

.day-corner-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text-muted);
  text-align: center;
  flex: 1;
  white-space: nowrap;
}

.day-nav-btn {
  background: none;
  border: none;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  font-size: 20px;
  line-height: 1;
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.day-nav-btn:disabled { opacity: 0.25; cursor: default; }
.day-nav-btn:not(:disabled):hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

/* Teacher headers — sticky top, clickable to filter week view */
.day-teacher-header {
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  border-bottom: 2px solid var(--color-border);
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: sticky;
  top: 0;
  z-index: 10;
  cursor: pointer;
  transition: background var(--transition);
  user-select: none;
}
.day-teacher-header:hover {
  background: var(--color-primary-light);
}
.day-teacher-header:hover .day-teacher-name {
  color: var(--color-primary);
}

.day-teacher-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}

.day-format-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  letter-spacing: 0.02em;
}
.day-format-badge.fmt-ip     { background: var(--color-primary-light); color: var(--color-primary); }
.day-format-badge.fmt-online { background: #DCFCE7; color: #15803D; }
.day-format-badge.fmt-both   { background: #FEF9C3; color: #92400E; }

/* Time labels — sticky left */
.day-time-label {
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  left: 0;
  z-index: 5;
  height: 36px;
  padding: 3px 8px 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
}
.day-time-half {
  border-bottom: 1px dashed var(--color-border);
  font-size: 9px;
  color: var(--color-text-muted);
  justify-content: flex-end;
  padding-right: 4px;
}
.day-time-quarter {
  border-bottom: 1px dotted rgba(0,0,0,0.1);
}

/* Day cells */
.day-cell {
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  height: 36px;
  padding: 2px 6px;
  font-size: 11px;
  overflow: hidden;
}
.day-cell-half      { border-bottom: 1px dashed var(--color-border); }
.day-cell-quarter   { border-bottom: 1px dotted rgba(0,0,0,0.1); }
.day-cell-clickable { cursor: pointer; }
.day-cell-clickable:hover { filter: brightness(0.93); }

.day-cell.unavailable  { background: var(--color-unavailable); }
.day-cell.avail-ip     { background: var(--color-avail-ip); }
.day-cell.avail-online { background: var(--color-avail-online); }
.day-cell.booked-ip    { background: var(--color-booked-ip); }
.day-cell.booked-online{ background: var(--color-booked-online); }
.day-cell.meeting      { background: var(--color-meeting); }
.day-cell.admin        { background: var(--color-admin); }
.day-cell.hold         { background: var(--color-hold); }

/* ── Grid skeleton (used in Phase 3+) ───────────────────────────────────── */

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, #E2E8F0 25%, #F1F5F9 50%, #E2E8F0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}

/* ── Week/Day grid (shell — populated in Phase 3/4) ─────────────────────── */

.schedule-grid {
  display: grid;
  overflow: auto;
  height: 100%;
}

.grid-header-cell {
  background: var(--color-surface);
  border-bottom: 2px solid var(--color-border);
  border-right: 1px solid var(--color-border);
  padding: 8px 10px;
  font-weight: 600;
  font-size: 13px;
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: nowrap;
}

.grid-time-cell {
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  padding: 4px 8px;
  font-size: 11px;
  color: var(--color-text-muted);
  background: var(--color-surface);
  position: sticky;
  left: 0;
  z-index: 5;
  white-space: nowrap;
}

.grid-cell {
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  padding: 3px 6px;
  cursor: pointer;
  transition: filter var(--transition);
  overflow: hidden;
  font-size: 12px;
}
.grid-cell:hover { filter: brightness(0.93); }

/* Session cell states */
.grid-cell.unavailable { background: var(--color-unavailable); cursor: default; }
.grid-cell.avail-ip    { background: var(--color-avail-ip); }
.grid-cell.avail-online{ background: var(--color-avail-online); }
.grid-cell.booked      { background: var(--color-booked); }
.grid-cell.hold        { background: var(--color-hold); }

/* ── Day cell — booked states (Phase 5) ──────────────────────────────────── */

.day-cell.booked-meeting { background: var(--color-meeting); }
.day-cell.booked-admin   { background: var(--color-admin); }

/* Spanning session cell — height is determined by the grid rows it spans */
.day-cell.day-cell-span {
  height: auto;
  align-self: stretch;
  border-bottom: 2px solid rgba(0,0,0,0.15);
  z-index: 2;
}

/* Session label inside a booked cell */
.session-block {
  display: flex;
  flex-direction: column;
  gap: 1px;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}

.session-block-name {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(0,0,0,0.75);
}

.session-block-venue {
  font-size: 10px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(0,0,0,0.50);
}

/* ── Slot panel content (Phase 5) ────────────────────────────────────────── */

.panel-loading {
  color: var(--color-text-muted);
  font-size: 13px;
  padding: 8px 0;
}

.panel-empty {
  color: var(--color-text-muted);
  font-size: 13px;
  padding: 4px 0 12px;
}

.panel-session-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.panel-session-item {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-session-info {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 8px;
  row-gap: 2px;
  align-items: start;
  flex: 1;
  min-width: 0;
}

.panel-session-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}
.panel-session-item:hover .panel-session-actions { opacity: 1; }

.panel-session-tag {
  grid-column: 1;
  grid-row: 1 / 3;
  align-self: center;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.tag-student { background: var(--color-avail-ip);     color: var(--color-text); border: 1px solid var(--color-border); }
.tag-meeting { background: var(--color-meeting);      color: #1e40af; }
.tag-admin   { background: var(--color-admin);        color: #5b21b6; }

.panel-session-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-session-meta {
  font-size: 11px;
  color: var(--color-text-muted);
}

.panel-session-venue {
  grid-column: 2;
  font-size: 11px;
  color: var(--color-text-muted);
  font-style: italic;
}

.panel-add-btn {
  width: 100%;
  margin-top: 4px;
}

.panel-add-form {
  margin-top: 12px;
  border-top: 1px solid var(--color-border);
  padding-top: 12px;
}

.panel-edit-notice {
  font-size: 11px;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  margin: 0 0 8px;
}

.panel-delete-confirm {
  padding: 4px 0;
}
.panel-delete-confirm p {
  font-size: 13px;
  margin: 0 0 6px;
}
.panel-delete-warning {
  color: #b45309;
  font-size: 12px;
}

/* ── Slot add form ────────────────────────────────────────────────────────── */

.slot-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.slot-form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.slot-form-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.slot-form-group input,
.slot-form-group select,
.slot-form-group textarea {
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  width: 100%;
  box-sizing: border-box;
}

.slot-form-group textarea { resize: vertical; min-height: 52px; }

/* Two date inputs side by side */
.slot-form-dates {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.slot-form-dates label { flex-shrink: 0; }
.slot-form-dates input { flex: 1; min-width: 120px; }

.slot-form-actions {
  display: flex;
  gap: 8px;
  padding-top: 4px;
}

/* ── Specific dates chips ─────────────────────────────────────────────────── */

.specific-dates-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  min-height: 8px;
}

.specific-date-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: 10px;
  padding: 2px 8px 2px 10px;
  font-size: 12px;
  font-weight: 500;
}

.btn-remove-date {
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: 14px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  opacity: 0.7;
}
.btn-remove-date:hover { opacity: 1; }
.grid-cell.booked-partial { background: var(--color-booked-partial); border: 1px dashed #60A5FA; }

/* ── Conflict modal ──────────────────────────────────────────────────────── */

.conflict-modal-overlay { z-index: 3000; }

.conflict-modal-dialog {
  width: 420px;
  max-width: calc(100vw - 32px);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.conflict-modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.conflict-section { margin-bottom: 16px; }
.conflict-section:last-of-type { margin-bottom: 0; }

.conflict-section h4 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin: 0 0 8px;
}

.conflict-section ul {
  margin: 0;
  padding: 0 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.conflict-section li {
  font-size: 13px;
  line-height: 1.5;
}

.conflict-scope {
  font-size: 11px;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border-radius: 4px;
  padding: 1px 5px;
}

.conflict-date-list {
  font-size: 11px;
  color: var(--color-text-muted);
  display: block;
  margin-top: 2px;
}

.conflict-hint {
  font-size: 12px;
  color: var(--color-text-muted);
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
}

.conflict-modal-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

/* ── Teachers dropdown (filter bar) ─────────────────────────────────────── */

.teachers-dropdown {
  position: relative;
  flex-shrink: 0;
}

.teachers-dropdown-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  line-height: 1;
}
.teachers-dropdown-btn:hover {
  color: var(--color-primary);
  background: var(--color-primary-light);
}

.teachers-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 200;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px var(--color-shadow);
  min-width: 200px;
  max-height: 340px;
  overflow-y: auto;
  padding: 4px 0;
}

.teachers-menu-item {
  display: block;
  width: 100%;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition);
}
.teachers-menu-item:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.teachers-menu-empty {
  padding: 8px 14px;
  font-size: 12px;
  color: var(--color-text-muted);
  font-style: italic;
}

.teacher-menu-avail {
  color: var(--color-primary);
  font-size: 12px;
  font-weight: 700;
}

/* ── Teacher Profile page ────────────────────────────────────────────────── */

.profile-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}

.profile-header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--color-border);
  flex-wrap: wrap;
}

.profile-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}

.profile-email {
  font-size: 13px;
  color: var(--color-primary);
  text-decoration: none;
}
.profile-email:hover { text-decoration: underline; }

.profile-loading {
  padding: 40px 24px;
  font-size: 14px;
  color: var(--color-text-muted);
  font-style: italic;
}

/* ── Collapsible profile sections ────────────────────────────────────────── */

.profile-section {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  background: var(--color-surface);
  overflow: hidden;
}

.profile-section-summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
  background: var(--color-bg);
  border-bottom: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  transition: background var(--transition);
}
.profile-section-summary::-webkit-details-marker { display: none; }
.profile-section-summary::before {
  content: '▶';
  font-size: 9px;
  color: var(--color-text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}
details[open] > .profile-section-summary::before {
  transform: rotate(90deg);
}
details[open] > .profile-section-summary {
  border-bottom-color: var(--color-border);
}
.profile-section-summary:hover {
  background: var(--color-primary-light);
}

.profile-section-body {
  padding: 16px;
}

.profile-section-toolbar {
  margin-bottom: 12px;
}

/* ── Subject fields grid ─────────────────────────────────────────────────── */

.subject-fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.subject-field-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.subject-field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subject-field-input {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 13px;
  font-family: inherit;
  background: var(--color-bg);
  color: var(--color-text);
  width: 100%;
  box-sizing: border-box;
  transition: border-color var(--transition);
}
.subject-field-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* ── Booking mode banner ─────────────────────────────────────────────────── */

.booking-mode-banner {
  background: #FEF9C3;
  border-bottom: 2px solid #FDE68A;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  font-weight: 500;
  color: #78350F;
  flex-shrink: 0;
}
.booking-mode-banner.hidden { display: none; }
#booking-mode-text { flex: 1; }

/* ── Waitlist page ───────────────────────────────────────────────────────── */

.waitlist-page {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}

.waitlist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--color-border);
}

.waitlist-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}

/* ── Filter tabs ─────────────────────────────────────────────────────────── */

.wl-filter-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 16px;
}

.wl-filter-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  margin-bottom: -1px;
}
.wl-filter-btn:hover { color: var(--color-text); }
.wl-filter-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

.wl-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wl-empty {
  font-size: 14px;
  color: var(--color-text-muted);
  padding: 32px 0;
  text-align: center;
}

/* ── Request card ────────────────────────────────────────────────────────── */

.wl-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  overflow: hidden;
}

.wl-card-summary {
  cursor: pointer;
  list-style: none;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--color-bg);
  border-bottom: 1px solid transparent;
  user-select: none;
  transition: background var(--transition);
}
.wl-card-summary::-webkit-details-marker { display: none; }
.wl-card-summary::before {
  content: '▶';
  font-size: 9px;
  color: var(--color-text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}
details[open] > .wl-card-summary::before { transform: rotate(90deg); }
details[open] > .wl-card-summary { border-bottom-color: var(--color-border); }
.wl-card-summary:hover { background: var(--color-primary-light); }

.wl-card-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.wl-card-teacher {
  font-size: 12px;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.wl-card-date {
  font-size: 11px;
  color: var(--color-text-muted);
  flex-shrink: 0;
  margin-left: auto;
}

/* ── Badges ──────────────────────────────────────────────────────────────── */

.wl-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
}
.wl-badge-add       { background: #DCFCE7; color: #15803D; }
.wl-badge-change    { background: #FEF9C3; color: #92400E; }
.wl-badge-remove    { background: #FEE2E2; color: #DC2626; }
.wl-badge-new       { background: var(--color-primary-light); color: var(--color-primary); }
.wl-badge-ip        { background: #FEF9C3; color: #92400E; }
.wl-badge-done      { background: #F1F5F9; color: #64748B; }
.wl-badge-cancelled { background: #F1F5F9; color: #94A3B8; }

/* ── Card body ───────────────────────────────────────────────────────────── */

.wl-card-body { padding: 14px 16px; }

.wl-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: block;
  margin-bottom: 3px;
}

.wl-info-field { margin-bottom: 10px; }
.wl-info-field:last-child { margin-bottom: 0; }

.wl-value {
  font-size: 13px;
  color: var(--color-text);
  white-space: pre-wrap;
  word-break: break-word;
}

.wl-action-section {
  border-top: 1px solid var(--color-border);
  margin-top: 12px;
  padding-top: 12px;
}

.wl-action-row { display: flex; gap: 12px; flex-wrap: wrap; }

.wl-action-field { display: flex; flex-direction: column; }
.wl-action-field select {
  font-size: 13px;
  padding: 5px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: inherit;
  min-width: 160px;
}
.wl-action-field textarea {
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: inherit;
  width: 100%;
  resize: vertical;
  min-height: 52px;
  box-sizing: border-box;
}

.wl-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  align-items: center;
}

.wl-delete-confirm p {
  font-size: 13px;
  margin: 0 0 10px;
  color: var(--color-text);
}

/* ── New request form ────────────────────────────────────────────────────── */

.wl-form {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

.wl-form-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 14px;
}

.wl-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.wl-form-field {
  display: flex;
  flex-direction: column;
}

.wl-form-wide { grid-column: 1 / -1; }

.wl-form input,
.wl-form select,
.wl-form textarea {
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
  transition: border-color var(--transition);
}
.wl-form input:focus,
.wl-form select:focus,
.wl-form textarea:focus { outline: none; border-color: var(--color-primary); }

/* ── Slot panel — location toggle ───────────────────────────────────────────── */

.sf-location-toggle {
  display: flex;
  gap: 16px;
  margin-bottom: 6px;
}

.sf-radio-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  cursor: pointer;
  color: var(--color-text);
}

/* ── Slot panel — export indicator ──────────────────────────────────────────── */

.panel-session-exported {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: #16a34a;
  background: #dcfce7;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
  margin-top: 2px;
  width: fit-content;
}

/* ── Export view ─────────────────────────────────────────────────────────────── */

.export-page {
  padding: 20px 24px;
  max-width: 900px;
}

.export-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.export-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}

.export-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.export-term-name {
  font-size: 13px;
  color: var(--color-text-muted);
}

.export-all-done {
  font-size: 13px;
  color: #16a34a;
  font-weight: 600;
}

.export-global-status {
  margin-bottom: 14px;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.export-empty {
  padding: 40px 24px;
  color: var(--color-text-muted);
  font-size: 14px;
  text-align: center;
}

/* ── Teacher sections ────────────────────────────────────────────────────────── */

.export-teacher-section {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}

.export-teacher-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  background: var(--color-surface-alt, #f8f9fa);
  user-select: none;
  list-style: none;
}
.export-teacher-summary::-webkit-details-marker { display: none; }
.export-teacher-summary::before {
  content: '▶';
  font-size: 10px;
  color: var(--color-text-muted);
  transition: transform 0.15s;
  flex-shrink: 0;
}
details[open] > .export-teacher-summary::before { transform: rotate(90deg); }

.export-teacher-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text);
  flex: 1;
}

.export-teacher-count {
  font-size: 12px;
  color: var(--color-text-muted);
}

.export-teacher-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.export-chk-all-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--color-text-muted);
  cursor: pointer;
}

/* ── Session rows ────────────────────────────────────────────────────────────── */

.export-session-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.export-session-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s;
}
.export-session-row:hover { background: var(--color-hover, #f1f5f9); }
.export-session-row.is-exported { cursor: default; }

.export-action-select {
  flex-shrink: 0;
  font-size: 11px;
  padding: 2px 4px;
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: var(--radius-sm);
  background: white;
  cursor: pointer;
  color: var(--color-text-muted);
}

.export-session-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.export-session-subject {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.export-session-meta {
  font-size: 11px;
  color: var(--color-text-muted);
}

.export-badge-done {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  color: #16a34a;
  background: #dcfce7;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

/* ── Status messages ─────────────────────────────────────────────────────────── */

.export-teacher-status {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  margin-top: 4px;
}

.export-status-progress {
  background: #eff6ff;
  color: #1d4ed8;
}

.export-status-success {
  background: #dcfce7;
  color: #15803d;
}

.export-status-error {
  background: #fef2f2;
  color: #dc2626;
}
/* ── WorkHours sync section ──────────────────────────────────────────────────── */

.wh-sync-section {
  margin-top: 24px;
  padding: 14px 16px;
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: var(--radius);
  background: var(--color-surface, #f8fafc);
}

.wh-sync-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.wh-sync-desc {
  display: block;
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.wl-form textarea { resize: vertical; min-height: 60px; }
