/* Student Scheduler — grid UI (Phase 3).
   Day columns of class cards with checkboxes, mirroring the MyStudio "Schedule"
   modal mockup. No build step, no framework. */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #dfe3e8;
  --text: #1c2331;
  --muted: #6b7684;
  --accent: #2f6fd0;
  --accent-text: #ffffff;
  --checked-bg: #eaf2fd;
  --checked-border: #2f6fd0;
  --warn-bg: #fff5e5;
  --warn-border: #e8a33d;
  --warn-text: #7a4c00;
  --add: #1f8a4c;
  --remove: #c0392b;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161d;
    --surface: #1b2029;
    --border: #2d3542;
    --text: #e6e9ef;
    --muted: #93a0b0;
    --accent: #5b96e8;
    --accent-text: #0d1117;
    --checked-bg: #17293f;
    --checked-border: #5b96e8;
    --warn-bg: #33260f;
    --warn-border: #a8752a;
    --warn-text: #f0c986;
    --add: #4bbd7c;
    --remove: #e8756a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

main { padding: 20px 24px 60px; max-width: 1600px; margin: 0 auto; }

/* --- top bar ------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.brand h1 { font-size: 18px; margin: 0; }
.location {
  font-size: 12px; color: var(--muted);
  border: 1px solid var(--border); border-radius: 20px; padding: 2px 10px;
}

.btn-save {
  background: var(--accent); color: var(--accent-text);
  border: 0; border-radius: 6px; padding: 9px 18px;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-save:disabled { opacity: .45; cursor: default; }
.btn-save:not(:disabled):hover { filter: brightness(1.08); }

/* --- search -------------------------------------------------------------- */
.search-panel { margin-bottom: 20px; position: relative; max-width: 560px; }
.search-label {
  display: block; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin-bottom: 6px;
}
.search-wrap { position: relative; }
#search {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font-size: 15px;
}
#search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.search-status {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-size: 12px; color: var(--muted);
}

.results {
  list-style: none; margin: 6px 0 0; padding: 4px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  position: absolute; width: 100%; z-index: 5;
  max-height: 320px; overflow-y: auto;
}
.results li {
  padding: 9px 10px; border-radius: 6px; cursor: pointer;
  display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
}
.results li:hover, .results li[aria-selected="true"] { background: var(--checked-bg); }
.results .r-name { font-weight: 600; }
.results .r-meta { font-size: 12px; color: var(--muted); }
.results .r-none { color: var(--muted); cursor: default; }
.results .r-none:hover { background: transparent; }

/* --- student header ------------------------------------------------------ */
.student-panel { margin-bottom: 16px; }
.student-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
}
.student-head h2 { margin: 0; font-size: 20px; }
.muted { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.change-count { font-size: 13px; color: var(--muted); white-space: nowrap; }
.change-count.dirty { color: var(--accent); font-weight: 600; }

.warning {
  margin-top: 12px; padding: 10px 12px;
  background: var(--warn-bg); border: 1px solid var(--warn-border);
  border-left-width: 4px; border-radius: 6px;
  color: var(--warn-text); font-size: 13px;
}

/* --- grid ---------------------------------------------------------------- */
/* The week must read as ONE row of days. auto-fit would wrap Fri/Sat onto a
   second row on a narrow window, which breaks that read — so the column count is
   pinned to the number of days with classes and the grid scrolls sideways inside
   its own container instead. The page body never scrolls horizontally. */
.grid-scroll { overflow-x: auto; padding-bottom: 4px; }
.grid {
  display: grid;
  grid-template-columns: repeat(var(--day-count, 6), minmax(165px, 1fr));
  gap: 12px; align-items: start; min-width: min-content;
}
.day-col {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow);
}
.day-head {
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted);
  padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between;
}
.day-head .n { font-weight: 400; }

.card {
  display: block; position: relative;
  border: 1px solid var(--border); border-left: 4px solid var(--card-hue, var(--muted));
  border-radius: 6px; padding: 8px 8px 8px 32px;
  margin-bottom: 8px; cursor: pointer;
  background: var(--bg);
}
.card:last-child { margin-bottom: 0; }
.card:hover { border-color: var(--accent); }
.card.checked { background: var(--checked-bg); border-color: var(--checked-border); }
.card.disabled { opacity: .5; cursor: not-allowed; }
.card.disabled:hover { border-color: var(--border); }

.card input[type="checkbox"] {
  position: absolute; left: 9px; top: 9px;
  width: 15px; height: 15px; accent-color: var(--accent); cursor: inherit;
}
.card .c-time { font-size: 12px; font-weight: 700; color: var(--card-hue, var(--text)); }
.card .c-title { font-size: 13px; font-weight: 600; line-height: 1.3; margin: 1px 0; }
.card .c-sub, .card .c-count { font-size: 11px; color: var(--muted); }
.card .c-count { margin-top: 3px; }

.badge {
  display: inline-block; margin-top: 4px; padding: 1px 6px;
  border-radius: 10px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em;
  background: var(--warn-bg); color: var(--warn-text); border: 1px solid var(--warn-border);
}

.footer-actions { display: flex; justify-content: flex-end; margin-top: 20px; }

/* --- results / empty ----------------------------------------------------- */
.empty { color: var(--muted); text-align: center; padding: 60px 20px; }

.result-panel {
  margin-top: 20px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.result-panel h3 { margin: 0 0 10px; font-size: 15px; }
.result-panel ul { margin: 0; padding-left: 18px; }
.result-panel li { font-size: 13px; margin-bottom: 3px; }
.result-panel .add { color: var(--add); font-weight: 600; }
.result-panel .remove { color: var(--remove); font-weight: 600; }
.result-panel .preview-note {
  margin-top: 10px; padding: 8px 10px; font-size: 12px;
  background: var(--warn-bg); border: 1px solid var(--warn-border);
  border-radius: 6px; color: var(--warn-text);
}
.result-panel .err { color: var(--remove); }

.spinner { opacity: .6; }

/* --- nav (topbar links + logout) ------------------------------------------ */
.nav-links { display: flex; align-items: center; gap: 14px; }
.nav-links a {
  font-size: 13px; color: var(--muted); text-decoration: none; font-weight: 600;
}
.nav-links a:hover, .nav-links a.active { color: var(--accent); }
#location-switcher {
  font-size: 13px; font-weight: 600; padding: 5px 8px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text);
}
.btn-link {
  background: none; border: 0; color: var(--muted); font-size: 13px;
  font-weight: 600; cursor: pointer; padding: 0;
}
.btn-link:hover { color: var(--remove); }

/* --- login page ------------------------------------------------------------ */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 28px 26px;
}
.login-card h1 { font-size: 18px; margin: 0 0 4px; }
.login-card p.muted { margin: 0 0 20px; }
.form-field { margin-bottom: 14px; }
.form-field label {
  display: block; font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); margin-bottom: 6px;
}
.form-field input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg); color: var(--text); font-size: 15px;
}
.form-field input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.btn-primary {
  width: 100%; background: var(--accent); color: var(--accent-text);
  border: 0; border-radius: 6px; padding: 11px 18px;
  font-size: 14px; font-weight: 600; cursor: pointer; margin-top: 4px;
}
.btn-primary:disabled { opacity: .5; cursor: default; }
.login-error {
  margin: 0 0 14px; padding: 8px 10px; font-size: 13px;
  background: var(--warn-bg); border: 1px solid var(--warn-border);
  border-radius: 6px; color: var(--warn-text);
}
.login-hint { font-size: 12px; color: var(--muted); margin-top: 14px; }

/* --- report page ------------------------------------------------------------ */
.report-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 16px; flex-wrap: wrap;
}
.report-meta { font-size: 13px; color: var(--muted); }
.report-table {
  width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.report-table th, .report-table td {
  text-align: left; padding: 10px 14px; font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.report-table th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); background: var(--bg);
}
.report-table tr:last-child td { border-bottom: none; }
.report-wrap { overflow-x: auto; }
