:root {
  --navy: #031e42;
  --maroon: #9e1f20;
  --font-serif: Georgia, sans-serif;
  --font-sans: "Work Sans", sans-serif;
  --max-width: 56rem;
  --border: #e5e5e5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: #1a1a1a;
  background: #fff;
  line-height: 1.5;
}

h1,
h2,
h3 {
  font-family: var(--font-serif);
  color: var(--navy);
  margin: 0 0 0.25em;
}

a {
  color: inherit;
}

/* Header (shared by public and admin pages) */
.site-header {
  background: var(--navy);
}

.site-header .header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.site-header .brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
}

.site-header img {
  width: 48px;
  height: 48px;
}

.site-header .site-title {
  font-family: var(--font-serif);
  color: #fff;
  font-size: 1.25rem;
}

.site-header .header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.875rem;
}

.site-header .header-right a,
.site-header .header-right button {
  color: #fff;
  background: none;
  border: none;
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
  padding: 0;
}

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

/* Class list cards */
.class-grid {
  display: grid;
  gap: 1rem;
  margin-top: 2rem;
}

@media (min-width: 640px) {
  .class-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.class-card {
  display: block;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1.5rem;
  text-decoration: none;
  color: inherit;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.class-card:hover {
  border-color: var(--navy);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.class-card h2 {
  font-size: 1.25rem;
}

.class-card p {
  margin: 0.25rem 0 0;
  color: #555;
  font-size: 0.9rem;
}

.empty-state {
  color: #737373;
  margin-top: 2rem;
}

/* Class page header (name/teacher + subscribe button) */
.class-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}

.class-header p {
  margin: 0.25rem 0 0;
  color: #555;
}

.class-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--maroon);
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

/* "This week" update card */
.update-card {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1.5rem 2rem;
}

.update-card .date-range {
  color: var(--maroon);
  font-weight: 600;
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.update-items {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.subject-block {
  border-left: 4px solid var(--navy);
  padding-left: 1rem;
}

.subject-block.border-maroon {
  border-left-color: var(--maroon);
}

.subject-block h3 {
  font-size: 1.1rem;
}

.subject-block .content {
  white-space: pre-line;
  color: #333;
  margin: 0.25rem 0 0;
}

.subject-block a.item-link {
  display: inline-block;
  margin-top: 0.5rem;
  color: var(--maroon);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: underline;
}

/* Rich content section — the only place real HTML structure is rendered
   instead of escaped text, so it needs its own typography rules. */
.rich-content {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.rich-content p {
  margin: 0 0 1rem;
}

.rich-content ul,
.rich-content ol {
  margin: 0 0 1rem;
  padding-left: 1.5rem;
}

.rich-content img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 0.25rem;
  margin: 0.75rem 0;
}

.rich-content a {
  color: var(--maroon);
}

/* Memory verses (manually attached from the bank) */
.verses-section {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.verses-section h3 {
  font-size: 1.1rem;
}

.verse-card {
  margin-top: 0.75rem;
}

.verse-card h4 {
  font-size: 0.95rem;
  color: var(--maroon);
  margin: 0;
}

.verse-card p {
  white-space: pre-line;
  color: #333;
  margin: 0.25rem 0 0;
}

/* Homework (generated day-by-day from the update's date range) */
.homework-section {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.homework-section h3 {
  font-size: 1.1rem;
}

.homework-days {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.homework-day h4 {
  font-size: 0.95rem;
  color: var(--maroon);
  margin: 0;
}

.homework-day ul {
  margin: 0.25rem 0 0;
  padding-left: 1.25rem;
}

/* Important dates (auto-matched from the bank, inside the update card) */
.important-dates {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.important-dates h3 {
  font-size: 1.1rem;
}

.important-dates ul {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
}

.important-dates li {
  display: flex;
  gap: 0.75rem;
  padding: 0.4rem 0;
}

.important-dates .date {
  color: var(--maroon);
  font-weight: 600;
  white-space: nowrap;
}

/* Past updates list */
.past-updates {
  margin-top: 3rem;
}

.past-updates ul {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.past-updates li {
  border-top: 1px solid var(--border);
}

.past-updates li:first-child {
  border-top: none;
}

.past-updates a {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  text-decoration: none;
}

.past-updates a:hover {
  color: var(--maroon);
}

.past-updates .date {
  color: #737373;
  font-size: 0.875rem;
}

/* Forms */
.subscribe-form {
  max-width: 24rem;
  margin-top: 2rem;
}

.form-field {
  margin-bottom: 1rem;
}

.form-field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.form-field input,
.form-field textarea {
  width: 100%;
  border: 1px solid #d4d4d4;
  border-radius: 0.25rem;
  padding: 0.5rem 0.75rem;
  font: inherit;
}

.form-field textarea {
  min-height: 6rem;
  resize: vertical;
}

.form-field-dates {
  display: flex;
  gap: 1rem;
}

.form-field-dates > div {
  flex: 1;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  border-radius: 0.25rem;
  padding: 0.6rem 1.25rem;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: var(--navy);
  color: #fff;
}

.btn-primary:hover {
  background: #052a5c;
}

.btn-outline {
  background: none;
  border: 1px solid var(--maroon);
  color: var(--maroon);
}

.btn-outline:hover {
  background: var(--maroon);
  color: #fff;
}

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

.message-error {
  color: var(--maroon);
  background: rgba(158, 31, 32, 0.06);
  border: 1px solid rgba(158, 31, 32, 0.2);
  border-radius: 0.25rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
}

.message-success {
  color: var(--navy);
  background: rgba(3, 30, 66, 0.06);
  border: 1px solid rgba(3, 30, 66, 0.15);
  border-radius: 0.25rem;
  padding: 1rem;
}

/* Auth / access gate screens */
.access-gate {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  max-width: 28rem;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Admin: class picker links (below the class-card grid on /admin) */
.admin-links {
  margin-top: 2rem;
}

/* Admin: updates table */
.admin-table {
  width: 100%;
  margin-top: 1.5rem;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.admin-table th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #737373;
}

.status-badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.status-published {
  background: rgba(3, 30, 66, 0.08);
  color: var(--navy);
}

.status-draft {
  background: rgba(158, 31, 32, 0.08);
  color: var(--maroon);
}

/* Admin: subscribers */
.subscribers-section {
  margin-top: 3rem;
}

.subscribers-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.subscribers-header h2 {
  margin: 0;
}

.subscriber-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
}

.subscriber-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.subscriber-name {
  color: #737373;
}

/* Admin: update form — repeatable item editors */
.item-editor {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.item-editor-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.item-editor-row:last-child {
  margin-bottom: 0;
}

.item-editor-row input {
  flex: 1;
  border: 1px solid #d4d4d4;
  border-radius: 0.25rem;
  padding: 0.5rem 0.75rem;
  font: inherit;
}

.item-editor .item-content {
  width: 100%;
  min-height: 5rem;
  resize: vertical;
  border: 1px solid #d4d4d4;
  border-radius: 0.25rem;
  padding: 0.5rem 0.75rem;
  font: inherit;
  margin-bottom: 0.75rem;
}

.btn-remove-item {
  background: none;
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  color: var(--maroon);
  cursor: pointer;
  white-space: nowrap;
}

#add-item-btn {
  margin-bottom: 1.5rem;
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.section-header h2 {
  margin: 0;
}

#rich-content-editor {
  background: #fff;
  margin-top: 0.5rem;
}

#rich-content-editor .ql-editor {
  min-height: 8rem;
}

/* Admin: update form — homework day-by-day editor */
.homework-day-editor {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.homework-day-editor h4 {
  margin: 0 0 0.5rem;
}

.homework-entry-editor {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.homework-entry-content {
  flex: 1;
  border: 1px solid #d4d4d4;
  border-radius: 0.25rem;
  padding: 0.5rem 0.75rem;
  font: inherit;
}

.btn-move-up,
.btn-move-down,
.btn-remove-homework-entry,
.btn-add-homework-entry {
  background: none;
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

.btn-remove-homework-entry {
  color: var(--maroon);
}

.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

/* Admin-super: generic inline forms below a table/list */
.inline-form {
  max-width: 28rem;
  margin-top: 1.5rem;
}

.fine-print {
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: #737373;
}

/* Admin-super: teacher cards */
.teacher-cards {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.teacher-card {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
}

.teacher-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.teacher-card-header > div {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.teacher-email {
  color: #737373;
  font-size: 0.85rem;
}

.teacher-classes {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.class-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(3, 30, 66, 0.06);
  color: var(--navy);
  border-radius: 999px;
  padding: 0.2rem 0.4rem 0.2rem 0.7rem;
  font-size: 0.85rem;
}

.class-chip button {
  background: none;
  border: none;
  color: var(--maroon);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.3rem;
}

.assign-class-row {
  margin-top: 0.75rem;
  display: flex;
  gap: 0.5rem;
}

.assign-class-row select {
  flex: 1;
  border: 1px solid #d4d4d4;
  border-radius: 0.25rem;
  padding: 0.4rem 0.6rem;
  font: inherit;
}

.checkbox-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-top: 0.25rem;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  font-weight: 400;
}

/* Admin-super: classes table row actions + inline edit/delete states */
.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.row-actions button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  cursor: pointer;
}

.row-actions .btn-delete-class {
  color: var(--maroon);
  border-color: rgba(158, 31, 32, 0.3);
}

.edit-class-message {
  width: 100%;
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
}

.admin-table input[type="text"] {
  width: 100%;
  border: 1px solid #d4d4d4;
  border-radius: 0.25rem;
  padding: 0.4rem 0.6rem;
  font: inherit;
}

.delete-warning-row td {
  background: rgba(158, 31, 32, 0.04);
}

.delete-warning {
  padding: 0.75rem 0;
}

.delete-warning .message-error {
  margin-bottom: 0.75rem;
}

.delete-confirm-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.delete-confirm-label input {
  border: 1px solid #d4d4d4;
  border-radius: 0.25rem;
  padding: 0.3rem 0.6rem;
  font: inherit;
}

.delete-warning .btn-confirm-delete,
.delete-warning .btn-cancel-delete {
  display: inline-flex;
  margin-right: 0.5rem;
}

.delete-warning .btn-confirm-delete {
  border-color: var(--maroon);
  color: var(--maroon);
}

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