/* Student register: a practical, paper-led directory treatment. */

.directory-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: clamp(20px, 3vw, 32px);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface-1);
  box-shadow: var(--shadow-md);
}

.directory-panel .panel-header {
  align-items: center;
}

.directory-panel .panel-header h2 {
  margin: 0 0 5px;
  font-size: clamp(1.45rem, 3vw, 1.85rem);
  letter-spacing: -0.035em;
}

.directory-panel .panel-copy {
  max-width: 58ch;
  font-size: 0.9rem;
}

.directory-local-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.directory-local-tag i {
  color: var(--success);
  font-size: 0.95rem;
}

.directory-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.directory-search {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  order: 0;
  grid-column: auto;
}

.directory-search > .ph-magnifying-glass {
  position: absolute;
  left: 16px;
  z-index: 1;
  color: var(--accent);
  font-size: 1.1rem;
  pointer-events: none;
}

.directory-search .input {
  width: 100%;
  height: 54px;
  padding: 0 16px 0 46px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  box-shadow: none;
  font-size: 0.98rem;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.directory-search .input:focus {
  border-color: var(--accent);
  background: var(--surface-1);
  box-shadow: 0 0 0 4px var(--focus);
  outline: none;
}

.directory-search .input::placeholder {
  color: var(--text-secondary);
  opacity: 0.85;
}

.directory-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  order: 1;
}

.directory-actions .btn {
  min-height: 46px;
  padding-inline: 13px;
  white-space: nowrap;
}

.directory-actions #dbAddStudentBtn {
  color: var(--color-primary-content);
  border-color: var(--color-primary);
  background: var(--color-primary);
}

.directory-actions #dbAddStudentBtn:hover {
  filter: brightness(1.12);
}

/* Status line: icon + state + detail. No card, no tinted fill — the tone
   lives in the icon and the label so it stays quiet next to the register. */
.status-box {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 2px 0 0;
  padding: 0 2px;
  border: 0;
  background: none;
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.45;
}

.status-icon {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  height: 1.45em;
  font-size: inherit;
  line-height: 1;
  color: var(--accent);
}

.status-icon i { font-size: 1.05rem; }

.status-copy { display: block; min-width: 0; }

.status-copy strong {
  margin-right: 6px;
  color: var(--text-primary);
  font-weight: 700;
}

.status-detail { color: var(--text-secondary); }

.status-box[data-tone='loading'] .status-icon { color: var(--accent); }
.status-box[data-tone='loading'] .status-icon i { animation: status-spin 1s linear infinite; }

.status-box[data-tone='success'] .status-icon,
.status-box[data-tone='success'] .status-copy strong { color: var(--tint-success-ink); }

.status-box[data-tone='warning'] .status-icon,
.status-box[data-tone='warning'] .status-copy strong { color: var(--tint-warning-ink); }

.status-box[data-tone='error'] .status-icon,
.status-box[data-tone='error'] .status-copy strong { color: var(--tint-danger-ink); }

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

.table-container {
  border-color: var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}

.table-container::-webkit-scrollbar {
  height: 8px;
}

.table-container::-webkit-scrollbar-thumb {
  border: 2px solid var(--surface-1);
  border-radius: var(--radius-full);
  background: var(--line-strong);
}

#studentTable {
  min-width: 520px;
  font-size: 0.92rem;
}

#studentTable thead {
  background: var(--surface-3);
}

#studentTable th {
  padding: 13px 16px;
  color: var(--text-secondary);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
}

#studentTable td {
  padding: 10px 16px;
  vertical-align: middle;
}

#studentTable tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--accent) 3%, var(--surface-1));
}

#studentTable tbody tr:hover {
  background: var(--accent-soft);
}

#studentTable .id-cell {
  width: 120px;
}

#studentTable .id-link {
  min-height: 40px;
  padding: 7px 10px;
  margin: -7px -10px;
  border-radius: 8px;
}

#studentTable .actions-col {
  padding-right: 12px;
}

#studentTable .edit-icon-button {
  width: 40px;
  height: 40px;
}

.empty-state {
  height: 220px;
  color: var(--text-secondary);
}

.empty-state > .empty-icon,
.empty-state > strong,
.empty-state > span:not(.empty-icon) {
  display: block;
}

.empty-state > .empty-icon {
  margin-bottom: 10px;
  color: var(--accent);
  font-size: 1.8rem;
}

.empty-state > strong {
  margin-bottom: 4px;
  color: var(--text-primary);
  font-size: 1rem;
}

.empty-state > span:not(.empty-icon) {
  font-size: 0.85rem;
}

.table-footer {
  padding-top: 0;
}

.page-btn {
  width: 42px;
  height: 42px;
}

.page-indicator {
  min-width: 74px;
  font-weight: 700;
}

.page-size-select {
  height: 42px;
  min-height: 42px;
}

/* Register note: a plain disclosure under the table, separated by a rule
   instead of sitting in its own card. */
.database-notice {
  --notice-indent: 56px;
  margin: 6px 0 0;
  padding: 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: none;
  color: var(--text-secondary);
  font-size: .82rem;
}

.database-notice summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0;
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.database-notice summary .summary-info-icon {
  border-radius: 0;
  background: none;
  color: var(--accent);
  font-size: 1rem;
}

.database-notice summary .disclosure-arrow { color: var(--text-secondary); font-size: .85rem; }

.database-notice .notice-tag {
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--text-secondary);
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  opacity: .8;
}

.database-notice .notice-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  margin: 2px 0 0 var(--notice-indent);
}

.database-notice .stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--text-secondary);
  font-size: .8rem;
}

.database-notice .stat-chip i { color: var(--accent); font-size: .95rem; }

.database-notice .stat-chip strong {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.database-notice > p {
  margin: 8px 0 0 var(--notice-indent);
  max-width: 78ch;
  font-size: .82rem;
  line-height: 1.55;
}

@media (max-width: 820px) {
  .directory-toolbar {
    grid-template-columns: 1fr;
  }

  .directory-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 620px) {
  .directory-panel {
    gap: 14px;
    padding: 18px 14px;
  }

  .directory-panel .panel-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .directory-local-tag {
    white-space: normal;
  }

  .directory-search .input {
    height: 50px;
    padding-right: 16px;
  }

  .directory-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .directory-actions .btn {
    justify-content: center;
    padding-inline: 8px;
    font-size: 0.83rem;
  }

  .directory-actions #dbAddStudentBtn {
    grid-column: 1 / -1;
    width: 100%;
    height: auto;
    min-height: 46px;
    padding-inline: 10px;
  }

  #studentTable {
    min-width: 500px;
  }

  .table-footer {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .table-footer .page-info {
    grid-column: 1 / -1;
  }

  .table-footer .page-size-wrap {
    justify-self: end;
  }
}

/* Directory surfaces: a bounded, searchable register rather than a hero card. */
/* Compact header: one line of orientation plus the two register totals. */
.directory-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 28px;
  min-height: 0;
  margin: 0 0 14px;
  padding: 15px 22px;
  border-color: var(--panel-strong-line);
  border-radius: 10px;
  background: var(--panel-strong);
  box-shadow: none;
  color: var(--on-strong);
}
.directory-hero-copy { min-width: 0; }
.directory-hero h1 {
  margin: 0;
  color: var(--on-strong);
  font-size: 1.32rem;
  letter-spacing: -.025em;
  line-height: 1.25;
  text-wrap: balance;
}
.directory-hero h1 span { color: var(--on-strong-highlight); }
.directory-lede {
  max-width: 64ch;
  margin: 3px 0 0;
  color: var(--on-strong-muted);
  font-size: .84rem;
  line-height: 1.45;
}
.directory-facts {
  display: flex;
  flex: 0 0 auto;
  gap: 26px;
  margin: 0;
}
.directory-facts div { display: grid; gap: 1px; }
.directory-facts dt {
  color: var(--on-strong-faint);
  font-size: .63rem;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.directory-facts dd {
  margin: 0;
  color: var(--on-strong);
  font-size: 1.12rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.directory-panel { gap: 15px; padding: 23px; border-color: var(--line-strong); border-radius: 10px; background: var(--surface-1); box-shadow: var(--shadow-sm); }
.directory-panel .panel-header h2 { font-size: 1.3rem; letter-spacing: -.025em; }
.directory-panel .panel-copy { color: var(--text-secondary); font-size: .84rem; }
.directory-local-tag { border-radius: 6px; color: var(--tint-success-ink); background: var(--tint-success-bg); border-color: var(--tint-success-line); font-size: .72rem; }
.directory-local-tag i { color: var(--success); }
.directory-search .input { height: 48px; border-radius: 7px; background: var(--surface-2); font-size: .9rem; }
.directory-search > .ph-magnifying-glass { color: var(--accent); }
.directory-actions .btn { min-height: 42px; }
.directory-actions #dbAddStudentBtn { border-color: var(--color-primary); background: var(--color-primary); color: var(--color-primary-content); }
.table-container { border-radius: 7px; padding: 6px 8px; }
#studentTable { font-size: .87rem; }
#studentTable thead { background: var(--table-head-bg); }
#studentTable th { color: var(--text-secondary); font-size: .67rem; }
#studentTable td { border-bottom: 1px solid var(--line); }
#studentTable tbody tr:nth-child(even) { background: var(--table-zebra); }
#studentTable tbody tr:hover { background: var(--table-hover); }
#studentTable .id-link { color: var(--accent); border-radius: 4px; font-variant-numeric: tabular-nums; }
#studentTable .id-link:hover { background: var(--accent-soft); }

@media (max-width: 620px) {
  .directory-hero { padding: 14px 16px; gap: 10px 18px; }
  .directory-hero h1 { font-size: 1.16rem; overflow-wrap: anywhere; }
  .directory-lede { font-size: .8rem; }
  .directory-facts { gap: 18px; }
  .directory-facts dd { font-size: 1rem; }
  .directory-panel { padding: 17px 13px; }
  .directory-hero,
  .directory-panel { width: 100%; min-width: 0; }
  .directory-hero-copy,
  .directory-panel > * { min-width: 0; }
  .table-container {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
  }
}

/* Compact register: dense rows, scannable names, quiet chrome. */
.table-container {
  padding: 0;
  border-color: var(--line);
  border-radius: 8px;
  background: var(--surface-1);
}

#studentTable {
  min-width: 320px;
  font-size: .865rem;
}

#studentTable th {
  height: 34px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--line);
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .07em;
}

#studentTable td {
  padding: 5px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

#studentTable tbody tr:last-child td {
  border-bottom: 0;
}

#studentTable tbody tr {
  transition: background .12s ease, box-shadow .12s ease;
}

#studentTable tbody tr:hover td:first-child {
  box-shadow: inset 2px 0 var(--accent);
}

/* ID: fixed gutter, digits never jitter between rows. */
#studentTable th.id-col,
#studentTable td.id-cell {
  width: 104px;
}

#studentTable td.id-cell {
  padding-right: 6px;
}

#studentTable .id-link {
  min-height: 30px;
  padding: 4px 7px;
  margin: -4px -7px;
  gap: 5px;
  border-radius: 5px;
  color: var(--accent);
  font-size: .855rem;
  font-weight: 700;
  letter-spacing: .01em;
}

#studentTable .id-link i {
  font-size: .78em;
  opacity: .35;
  transition: opacity .12s ease;
}

#studentTable .id-link:hover i,
#studentTable .id-link:focus-visible i {
  opacity: 1;
}

@media (hover: hover) {
  #studentTable .id-link i {
    opacity: 0;
  }

  #studentTable tbody tr:hover .id-link i,
  #studentTable .id-link:focus-visible i {
    opacity: .7;
  }

  #studentTable .id-link:hover i {
    opacity: 1;
  }
}

/* Name: the primary label of each row. */
#studentTable th.name-col {
  min-width: 220px;
}

#studentTable td.name-cell {
  color: var(--text-primary);
  font-weight: 500;
}

/* Actions: small icon buttons, quiet until the row is engaged. */
#studentTable .actions-col {
  width: 1%;
  padding-left: 4px;
  padding-right: 10px;
}

#studentTable .edit-icon-button {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-size: .95rem;
}

#studentTable .edit-icon-button + .edit-icon-button {
  margin-left: 2px;
}

@media (hover: hover) {
  #studentTable .actions-col .edit-icon-button {
    opacity: .5;
    transition: opacity .12s ease, background .12s ease, color .12s ease;
  }

  #studentTable tr:hover .edit-icon-button,
  #studentTable .actions-col .edit-icon-button:focus-visible {
    opacity: 1;
  }
}

/* Pagination keeps the same compact rhythm as the rows. */
.table-footer {
  padding: 4px 2px 0;
  font-size: .82rem;
}

.page-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
}

.page-indicator {
  min-width: 60px;
  font-size: .82rem;
}

.page-size-select {
  height: 32px;
  min-height: 32px;
  font-size: .8rem;
}

@media (max-width: 620px) {
  #studentTable th,
  #studentTable td {
    padding-inline: 10px;
  }

  #studentTable th.id-col,
  #studentTable td.id-cell {
    width: 84px;
  }
}

/* Phone view: strip the page down to the register itself.
   The hero repeats what the nav and the table footer already say, the panel
   explainer repeats the search placeholder, and the local-edits chip repeats
   the register notice, so all three step aside on small screens. */
@media (max-width: 620px) {
  /* Visually hidden, not removed: keeps the page's h1 in the accessibility tree. */
  .directory-hero {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .directory-panel { gap: 12px; padding: 15px 13px; }
  .directory-panel .panel-header { gap: 0; }
  .directory-panel .panel-copy { display: none; }
  .directory-local-tag { display: none; }

  .directory-search .input { height: 46px; font-size: 16px; }

  /* One primary action, then the two utilities as an equal pair. */
  .directory-actions {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    gap: 8px;
  }

  .directory-actions .btn {
    flex: 1 1 0;
    min-width: 0;
    min-height: 44px;
    padding-inline: 6px;
    font-size: .78rem;
    gap: 5px;
    justify-content: center;
  }

  .directory-actions #dbAddStudentBtn {
    order: -1;
    flex: 1 1 100%;
    min-height: 46px;
  }

  .directory-actions .button-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .status-box { gap: 7px; padding: 0; font-size: .79rem; }
  .status-copy strong { margin-right: 5px; }

  .database-notice { --notice-indent: 0px; }
  .database-notice summary { min-height: 36px; }

  /* The notice body already explains local-only edits; the chip only wraps here. */
  .database-notice .notice-tag { display: none; }

  .table-container { border-radius: 6px; }
  #studentTable { font-size: .84rem; }
  #studentTable th,
  #studentTable td { padding-inline: 8px; }
  #studentTable th.id-col,
  #studentTable td.id-cell { width: 72px; }
  #studentTable .edit-icon-button { width: 32px; height: 32px; font-size: 1rem; }
  #studentTable .actions-col { padding-right: 6px; }
}

/* Phones: the name column was pinned at 220px, which pushed the actions
   column past the container edge. Let it shrink so the table always fits. */
@media (max-width: 620px) {
  #studentTable th.name-col { min-width: 140px; }
}

@media (max-width: 420px) {
  #studentTable { min-width: 0; }
  #studentTable th.name-col { min-width: 0; }
  #studentTable .actions-col { padding-right: 2px; }
}

/* Tablet widths: the shared mobile rule makes .btn 100% wide up to 720px,
   which blew the register actions apart. Keep them content-sized and wrap. */
.directory-actions { flex-wrap: wrap; }
.directory-actions .btn { width: auto; }

/* Tablet range (621–820px): the shared mobile rule stretches every .btn to
   100% up to 720px. Keep the register actions at their own size and stop
   anything from re-ordering them. */
@media (min-width: 621px) {
  .directory-actions { flex-wrap: wrap; justify-content: flex-end; }
  .directory-actions .btn.btn { width: auto; flex: 0 0 auto; }
  .directory-actions > .btn { order: 0; }
}
