/* Exeter Mosque Madrasah — pastel dashboard */

:root {
  --bg: #fff8f0;
  --card: #ffffff;
  --text: #3d3a50;
  --muted: #7a7690;
  --pink: #ffb5c5;
  --peach: #ffd6a5;
  --mint: #b8e0d2;
  --lavender: #c9b6e4;
  --sky: #a8d8ff;
  --lemon: #fff3a3;
  --coral: #ff9aa2;
  --shadow: 0 10px 30px rgba(90, 70, 120, 0.12);
  --radius: 20px;
  --footer-h: 76px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --max: 920px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: 'Nunito', system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 10%, #ffe8f0 0%, transparent 40%),
    radial-gradient(circle at 90% 20%, #e8f4ff 0%, transparent 35%),
    radial-gradient(circle at 50% 100%, #e8fff4 0%, transparent 40%),
    var(--bg);
}

body { overflow-x: hidden; }

#app {
  max-width: var(--max);
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(var(--footer-h) + var(--safe-bottom) + 20px);
}

.topbar {
  padding: 16px 18px 8px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

.brand h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
}

.tagline {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-chip {
  background: var(--card);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  box-shadow: var(--shadow);
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logout-btn {
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.75rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.level-switcher { display: flex; align-items: center; }

.level-select {
  border: none;
  background: linear-gradient(135deg, var(--lavender), var(--sky));
  border-radius: 999px;
  padding: 8px 14px;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.8rem;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.main {
  padding: 8px 16px 24px;
  animation: fadeUp 0.35s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.hidden { display: none !important; }

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.page-head.tight { margin-bottom: 8px; }

.page-head h2, .page-head h3 {
  margin: 0;
  font-weight: 800;
  flex: 1;
}

.head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.back-link {
  border: none;
  background: transparent;
  font-family: inherit;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 0;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.class-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  text-align: left;
  border: none;
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  transition: transform 0.15s ease;
}

.class-card:hover { transform: translateY(-2px); }

.class-icon {
  font-size: 1.8rem;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--mint), var(--lemon));
  flex-shrink: 0;
}

.class-icon.sm {
  width: 40px;
  height: 40px;
  font-size: 1.3rem;
}

.class-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.class-meta strong { font-weight: 800; }

.muted { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.tiny { font-size: 0.72rem; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0 0 12px; }

.pill {
  display: inline-block;
  background: var(--sky);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  width: fit-content;
}

.pill.warn { background: var(--peach); }

.btn {
  border: none;
  border-radius: 14px;
  padding: 10px 16px;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
  background: linear-gradient(135deg, var(--lavender), var(--pink));
  color: var(--text);
  box-shadow: var(--shadow);
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--mint), var(--sky));
}

.btn-mint { background: linear-gradient(135deg, var(--mint), var(--lemon)); }
.btn-warn { background: linear-gradient(135deg, var(--peach), var(--coral)); }
.btn-ghost {
  background: var(--card);
  box-shadow: 0 2px 10px rgba(90, 70, 120, 0.08);
}

.btn-sm { padding: 7px 12px; font-size: 0.78rem; border-radius: 12px; }
.btn-xs { padding: 5px 8px; font-size: 0.72rem; border-radius: 10px; }
.btn-block { width: 100%; }
.btn.selected { outline: 2px solid #5a4a80; }

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.row-actions.wrap { flex-wrap: wrap; margin-top: 8px; }

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.input, select.input, textarea.input {
  width: 100%;
  border: 2px solid #efe8ff;
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  background: #fff;
  color: var(--text);
  margin-top: 4px;
}

label {
  display: block;
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.login-wrap {
  display: flex;
  justify-content: center;
  padding: 40px 8px;
}

.login-card {
  width: 100%;
  max-width: 380px;
}

.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.week-label {
  font-weight: 700;
  font-size: 0.85rem;
  text-align: center;
  flex: 1;
}

.board-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.board-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f0eaf8;
}

.board-row:last-child { border-bottom: none; }
.board-name { font-weight: 700; min-width: 0; }
.board-score { font-weight: 800; font-size: 1.05rem; }
.board-comment {
  grid-column: 2 / -1;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 800;
  background: #eee8f8;
}

.rank.gold { background: linear-gradient(135deg, #ffe566, #ffc107); }
.rank.silver { background: linear-gradient(135deg, #e8e8e8, #b0b0b0); }
.rank.bronze { background: linear-gradient(135deg, #f0c9a0, #cd7f32); color: #fff; }

.me-banner {
  background: linear-gradient(135deg, var(--lemon), var(--mint));
  border-radius: var(--radius);
  padding: 12px 16px;
  font-weight: 700;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.action-card p { margin-top: 0; font-weight: 600; }

.lines-input {
  width: 6.5rem;
  max-width: 40%;
  flex: 0 0 auto;
  margin-top: 0;
  text-align: center;
  font-size: 1.15rem;
}

.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--muted);
}

.empty-emoji { font-size: 2.5rem; margin-bottom: 8px; }
.empty-state h3 { color: var(--text); margin: 0 0 6px; }

.session-card .session-top {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.att-row { display: flex; flex-direction: column; gap: 8px; }
.att-btns { display: flex; flex-wrap: wrap; gap: 6px; }

.profile-card {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.profile-info {
  min-width: 0;
  flex: 1;
}

.roster {
  list-style: none;
  margin: 0;
  padding: 0;
}

.roster li {
  padding: 8px 0;
  border-bottom: 1px solid #f0eaf8;
  font-weight: 700;
}

.roster li:last-child { border-bottom: none; }

.icon-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.icon-opt {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 2px solid transparent;
  background: #f6f2ff;
  font-size: 1.2rem;
  cursor: pointer;
}

.icon-opt.selected {
  border-color: #7b6bb0;
  background: var(--mint);
}

.cred-box {
  background: #f6fff9;
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
  border: 2px dashed var(--mint);
}

.pin-show {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: var(--text);
}

.people-teachers-pin {
  position: sticky;
  top: 0;
  z-index: 5;
  background: linear-gradient(180deg, var(--bg) 75%, transparent);
  padding-bottom: 8px;
}

.people-section-title {
  margin: 0 0 10px;
  font-weight: 800;
}

.people-divider {
  border: none;
  border-top: 2px solid #e6dff3;
  margin: 18px 0;
}

.people-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.person-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}

.person-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.assign-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.assign-row .input {
  flex: 1;
  min-width: 0;
}

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

@media (max-width: 820px) {
  .people-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 520px) {
  .people-grid {
    grid-template-columns: 1fr;
  }
  .people-teachers-pin {
    position: static;
  }
}

.tag {
  background: var(--sky);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 700;
}

.tag-x {
  border: none;
  background: transparent;
  cursor: pointer;
  font-weight: 800;
  margin-left: 4px;
}

.inbox-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.chip-tab {
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-family: inherit;
  font-weight: 800;
  background: #efe8ff;
  cursor: pointer;
}

.chip-tab.active {
  background: linear-gradient(135deg, var(--mint), var(--sky));
}

.notif-card.unread {
  border-left: 4px solid var(--coral);
}

.notif-card p { margin: 6px 0; font-weight: 600; }

.announce-card h3 { margin: 0 0 4px; }
.announce-card .hint { margin-bottom: 10px; }
.announce-card label { display: block; margin-bottom: 10px; font-weight: 700; font-size: 0.85rem; }
.announce-card textarea { min-height: 88px; resize: vertical; }

.start-chat-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  border: none;
  background: linear-gradient(135deg, var(--mint), var(--sky));
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  color: var(--text);
}

.start-chat-btn:hover,
.start-chat-btn:focus-visible {
  outline: 2px solid #5a4a80;
  outline-offset: 2px;
}

.start-chat-btn strong {
  display: block;
  font-size: 1rem;
}

.start-chat-btn .muted {
  display: block;
  font-weight: 600;
}

.start-chat-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

#dm-contact-search {
  margin-bottom: 10px;
}

.contact-list { display: flex; flex-direction: column; gap: 6px; }

.contact-btn {
  text-align: left;
  border: none;
  background: #f8f4ff;
  border-radius: 12px;
  padding: 12px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dm-thread {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 45vh;
  overflow: auto;
  padding: 8px 0 16px;
}

.dm-bubble {
  align-self: flex-start;
  background: #f0eaf8;
  border-radius: 16px 16px 16px 4px;
  padding: 10px 14px;
  max-width: 85%;
  font-weight: 600;
}

.dm-bubble.mine {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--mint), var(--sky));
  border-radius: 16px 16px 4px 16px;
}

.dm-meta { font-size: 0.7rem; color: var(--muted); margin-bottom: 2px; }

.dm-compose {
  display: flex;
  gap: 8px;
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding: 8px 0;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

@media (min-width: 640px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}

.stat-card {
  border: none;
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-num {
  font-size: 1.6rem;
  font-weight: 800;
}

.stat-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}

.check-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  padding: 10px 12px;
  background: #f8f4ff;
  border-radius: 12px;
  margin-bottom: 0;
}

.check-row.disabled {
  opacity: 0.55;
}

.check-row input {
  width: 18px;
  height: 18px;
}

.level-pick-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}

.level-title-input:disabled {
  opacity: 0.45;
  background: #f3f0f8;
}

.admin-nav {
  /* shares .footer-nav layout */
}

.footer-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: var(--max);
  height: calc(var(--footer-h) + var(--safe-bottom));
  padding: 8px 8px var(--safe-bottom);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  box-shadow: 0 -8px 30px rgba(90, 70, 120, 0.1);
  z-index: 40;
}

.nav-btn {
  position: relative;
  border: none;
  background: transparent;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.68rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  padding: 6px 4px;
  border-radius: 14px;
}

.nav-btn.active {
  color: var(--text);
  background: linear-gradient(135deg, #e8fff4, #e8f4ff);
}

.nav-icon { font-size: 1.25rem; }

.nav-badge {
  position: absolute;
  top: 2px;
  right: 18%;
  background: var(--coral);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  padding: 0 4px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--footer-h) + var(--safe-bottom) + 16px);
  transform: translateX(-50%);
  background: #3d3a50;
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  z-index: 80;
  box-shadow: var(--shadow);
  max-width: 90vw;
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(40, 30, 60, 0.45);
  backdrop-filter: blur(5px);
}

.confirm-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 24px;
  padding: 28px 22px 20px;
  box-shadow: 0 20px 50px rgba(90, 70, 120, 0.22);
  text-align: center;
  animation: confirmPop 0.22s ease;
}

@keyframes confirmPop {
  from { transform: scale(0.92) translateY(12px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.confirm-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.65rem;
  background: linear-gradient(135deg, var(--peach), var(--coral));
  box-shadow: 0 8px 18px rgba(255, 154, 162, 0.35);
}

.confirm-card h3 {
  margin: 0 0 8px;
  font-size: 1.12rem;
  font-weight: 800;
}

.confirm-card p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.confirm-actions {
  display: flex;
  gap: 10px;
}

.confirm-actions .btn {
  flex: 1;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(40, 30, 60, 0.35);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow: auto;
  background: var(--card);
  border-radius: 24px 24px 0 0;
  padding: 24px 20px 28px;
  box-shadow: var(--shadow);
  z-index: 1;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: none;
  background: #f0eaf8;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.3rem;
  cursor: pointer;
  font-weight: 700;
}

@media (min-width: 720px) {
  .modal {
    align-items: center;
  }
  .modal-card {
    border-radius: 24px;
    margin: 16px;
  }
}

@media (max-width: 520px) {
  .row-2 { grid-template-columns: 1fr; }
  .board-row {
    grid-template-columns: auto 1fr auto;
  }
}
