/* =========================================================================
   Blooming Buds — School Diary
   Design language: a school diary/planner, not a generic admin dashboard.
   Signature elements: torn-tab cards (like planner page dividers), a
   spiral-bound edge on the login card, and role colours that persist
   everywhere a role shows up (teacher / student / parent).
   ========================================================================= */

:root {
  /* ---- Colour tokens -------------------------------------------------- */
  --ink: #1F2A3C;
  --ink-soft: #616E82;
  --ink-faint: #98A2B3;

  --canvas: #F2F5FA;
  --paper: #FFFFFF;
  --paper-line: #E4E9F1;

  --marigold: #F5A623;
  --marigold-dark: #D5890C;
  --marigold-wash: #FEF3DF;

  --leaf: #2E9E6D;
  --leaf-dark: #227D56;
  --leaf-wash: #E4F6EE;

  --sky: #3E6BE0;
  --sky-dark: #2E51B3;
  --sky-wash: #E8EEFD;

  --coral: #E0575B;
  --coral-dark: #C13F43;
  --coral-wash: #FBE7E7;

  /* ---- Type ------------------------------------------------------------ */
  --font-display: 'Fredoka', 'Segoe UI', sans-serif;
  --font-body: 'Inter', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  /* ---- Shape / motion --------------------------------------------------- */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --shadow-card: 0 1px 2px rgba(31, 42, 60, 0.04), 0 8px 24px -12px rgba(31, 42, 60, 0.16);
  --shadow-pop: 0 12px 32px -8px rgba(31, 42, 60, 0.22);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---- Reset -------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--canvas);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(31,42,60,0.05) 1px, transparent 0);
  background-size: 22px 22px;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; margin: 0; color: var(--ink); }
p { margin: 0; }
a { color: var(--sky); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
img { max-width: 100%; display: block; }

:focus-visible {
  outline: 2.5px solid var(--sky);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---- Layout shells -------------------------------------------------------- */
.page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.container {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 0 20px;
}
.stack { display: flex; flex-direction: column; gap: 16px; }

/* ---- Top app bar ------------------------------------------------------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid var(--paper-line);
}
.appbar__inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand__mark {
  width: 38px; height: 38px;
  flex-shrink: 0;
}
.brand__text { display: flex; flex-direction: column; line-height: 1.15; }
.brand__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--ink);
}
.brand__subtitle {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 600;
}
.appbar__actions { display: flex; align-items: center; gap: 10px; }

.person {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.person strong { color: var(--ink); font-weight: 600; }

/* ---- Role badge / chip -------------------------------------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}
.chip--teacher { background: var(--sky-wash); color: var(--sky-dark); }
.chip--student { background: var(--marigold-wash); color: var(--marigold-dark); }
.chip--parent  { background: var(--coral-wash); color: var(--coral-dark); }

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease), background-color 0.15s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn--block { width: 100%; }
.btn--primary { background: var(--marigold); color: #4A2E00; box-shadow: 0 6px 16px -6px rgba(245,166,35,0.55); }
.btn--primary:hover { background: var(--marigold-dark); }
.btn--sky { background: var(--sky); color: #fff; box-shadow: 0 6px 16px -6px rgba(62,107,224,0.5); }
.btn--sky:hover { background: var(--sky-dark); }
.btn--leaf { background: var(--leaf); color: #fff; box-shadow: 0 6px 16px -6px rgba(46,158,109,0.5); }
.btn--leaf:hover { background: var(--leaf-dark); }
.btn--coral { background: var(--coral); color: #fff; box-shadow: 0 6px 16px -6px rgba(224,87,91,0.5); }
.btn--coral:hover { background: var(--coral-dark); }
.btn--ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--paper-line);
  box-shadow: none;
}
.btn--ghost:hover { background: var(--canvas); color: var(--ink); }
.btn[disabled] { opacity: 0.55; cursor: progress; transform: none; }

/* ---- Cards & the "diary tab" signature ---------------------------------- */
.card {
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 24px;
  position: relative;
}
@media (max-width: 560px) {
  .card { padding: 18px; border-radius: var(--radius-md); }
}

/* a small coloured tab peeking out of the top-left corner, like a
   divider tab on a page in a school diary */
.tab-card { padding-top: 30px; }
.tab-card::before {
  content: attr(data-tab);
  position: absolute;
  top: -1px;
  left: 22px;
  transform: translateY(-100%);
  background: var(--tab-color, var(--sky));
  color: #fff;
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 14px 5px;
  border-radius: 8px 8px 0 0;
}

/* ---- Login page ----------------------------------------------------------- */
.auth {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}
.auth__frame { width: 100%; max-width: 420px; }
.auth__intro { text-align: center; margin-bottom: 22px; }
.auth__intro .brand__mark { width: 56px; height: 56px; margin: 0 auto 12px; }
.auth__intro h1 { font-size: 1.5rem; }
.auth__intro p { color: var(--ink-soft); margin-top: 4px; font-size: 0.92rem; }

.auth-card {
  position: relative;
  background: var(--paper);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: 28px 26px 26px 38px;
  overflow: hidden;
}
/* spiral-bound left edge */
.auth-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 18px;
  background-image: radial-gradient(circle, var(--canvas) 3.5px, transparent 3.6px);
  background-size: 100% 26px;
  background-position: 9px 13px;
  background-repeat: repeat-y;
  border-right: 1px dashed var(--paper-line);
}

.role-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}
.role-tabs input { position: absolute; opacity: 0; pointer-events: none; }
.role-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 6px 10px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--paper-line);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
  transition: all 0.15s var(--ease);
  user-select: none;
}
.role-tab svg { width: 20px; height: 20px; }
.role-tabs input:checked + .role-tab {
  border-color: transparent;
  color: #fff;
  transform: translateY(-2px);
}
.role-tabs input:focus-visible + .role-tab { outline: 2.5px solid var(--sky); outline-offset: 2px; }
.role-tabs input[value="teacher"]:checked + .role-tab { background: var(--sky); box-shadow: 0 8px 18px -8px rgba(62,107,224,0.6); }
.role-tabs input[value="student"]:checked + .role-tab { background: var(--marigold); color: #4A2E00; box-shadow: 0 8px 18px -8px rgba(245,166,35,0.6); }
.role-tabs input[value="parent"]:checked + .role-tab { background: var(--coral); box-shadow: 0 8px 18px -8px rgba(224,87,91,0.6); }

/* ---- Floating-label fields ------------------------------------------------ */
.field { position: relative; margin-bottom: 16px; }
.field:last-of-type { margin-bottom: 0; }
.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1.5px solid var(--paper-line);
  background: var(--canvas);
  border-radius: var(--radius-sm);
  padding: 18px 14px 8px;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.field textarea { padding-top: 20px; resize: vertical; min-height: 110px; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--sky);
  background: var(--paper);
}
.field label {
  position: absolute;
  left: 15px;
  top: 13px;
  font-size: 0.95rem;
  color: var(--ink-faint);
  pointer-events: none;
  transition: all 0.13s var(--ease);
  background: transparent;
}
.field input:focus + label,
.field input:not(:placeholder-shown) + label,
.field select:focus + label,
.field select.has-value + label,
.field textarea:focus + label,
.field textarea:not(:placeholder-shown) + label {
  top: 6px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--sky-dark);
}
.field--select select { appearance: none; padding-right: 36px; cursor: pointer; }
.field--select::after {
  content: '';
  position: absolute;
  right: 15px; top: 22px;
  width: 9px; height: 9px;
  border-right: 2px solid var(--ink-faint);
  border-bottom: 2px solid var(--ink-faint);
  transform: rotate(45deg);
  pointer-events: none;
}
.field--select label { top: 6px; font-size: 0.68rem; font-weight: 600; letter-spacing: 0.02em; color: var(--ink-soft); position: static; display: block; margin-bottom: 4px; }
.field--select select { padding: 12px 32px 12px 12px; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }

.password-field .toggle-visibility {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 6px;
  display: flex;
}
.password-field .toggle-visibility:hover { color: var(--ink-soft); }

/* ---- Alerts / toast --------------------------------------------------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-bottom: 18px;
}
.alert--error { background: var(--coral-wash); color: var(--coral-dark); }
.alert svg { flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px; }

.hint-note {
  margin-top: 18px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--ink-faint);
}

/* ---- Section headings on dashboards ------------------------------------- */
.page-head { padding: 26px 0 8px; }
.page-head h2 { font-size: 1.4rem; }
.page-head p { color: var(--ink-soft); font-size: 0.92rem; margin-top: 3px; }

/* ---- Filter bar (student/parent) ---------------------------------------- */
.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.filter-bar .field { margin-bottom: 0; min-width: 170px; flex: 1; }
.filter-bar .btn { flex-shrink: 0; }

/* ---- Child chips (parent) ---------------------------------------------- */
.child-picker {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 20px;
  -webkit-overflow-scrolling: touch;
}
.child-chip {
  flex-shrink: 0;
  border: 1.5px solid var(--paper-line);
  background: var(--paper);
  border-radius: 999px;
  padding: 9px 18px;
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.child-chip.is-active {
  background: var(--coral);
  border-color: var(--coral);
  color: #fff;
  box-shadow: 0 6px 14px -6px rgba(224,87,91,0.55);
}

/* ---- Homework diary entries --------------------------------------------- */
.entry-list { display: flex; flex-direction: column; gap: 16px; }
.entry {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius-md);
  padding: 18px 18px 18px 22px;
  box-shadow: var(--shadow-card);
}
.entry::before {
  content: '';
  position: absolute;
  left: 0; top: 14px; bottom: 14px;
  width: 4px;
  border-radius: 4px;
  background: var(--entry-accent, var(--sky));
}
.entry__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.entry__date {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 6px;
}
.entry__date svg { width: 16px; height: 16px; color: var(--ink-faint); }
.due-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.due-badge--overdue { background: var(--coral-wash); color: var(--coral-dark); }
.due-badge--soon { background: var(--marigold-wash); color: var(--marigold-dark); }
.due-badge--ok { background: var(--leaf-wash); color: var(--leaf-dark); }
.entry__desc { color: var(--ink); font-size: 0.95rem; white-space: pre-line; }
.entry__attachments {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.attachment-thumb {
  width: 76px; height: 76px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--paper-line);
  position: relative;
  display: block;
}
.attachment-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ---- Empty state --------------------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 44px 20px;
  color: var(--ink-soft);
}
.empty-state svg { width: 64px; height: 64px; margin: 0 auto 14px; color: var(--paper-line); }
.empty-state h3 { font-size: 1.05rem; color: var(--ink); margin-bottom: 4px; }
.empty-state p { font-size: 0.88rem; }

/* ---- Upload dropzone (teacher) ------------------------------------------- */
.dropzone {
  border: 2px dashed var(--paper-line);
  border-radius: var(--radius-md);
  padding: 26px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s var(--ease);
  background: var(--canvas);
}
.dropzone.is-dragover { border-color: var(--sky); background: var(--sky-wash); }
.dropzone svg { width: 30px; height: 30px; color: var(--ink-faint); margin: 0 auto 8px; }
.dropzone__title { font-weight: 600; font-size: 0.92rem; }
.dropzone__hint { font-size: 0.78rem; color: var(--ink-faint); margin-top: 2px; }
.dropzone input[type="file"] { display: none; }

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.preview-item { position: relative; border-radius: 10px; overflow: hidden; aspect-ratio: 1; border: 1px solid var(--paper-line); }
.preview-item img { width: 100%; height: 100%; object-fit: cover; }
.preview-item .remove-btn {
  position: absolute;
  top: 3px; right: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: rgba(31,42,60,0.65);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
}

/* ---- Footer --------------------------------------------------------------- */
.app-footer {
  margin-top: auto;
  padding: 26px 20px 32px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--ink-faint);
}

/* ---- Small helpers --------------------------------------------------------- */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.section-gap { margin-top: 26px; }

@media (max-width: 640px) {
  .appbar__inner { padding: 12px 16px; }
  .brand__title { font-size: 0.95rem; }
  .container { padding: 0 16px; }
  .page-head h2 { font-size: 1.2rem; }
}
