/* ============================================================
   ArchEdTech — app stylesheet (mobile-first)
   Base styles target small screens; breakpoints scale up.
   ============================================================ */

:root {
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --brand-soft: #eef2ff;
  --accent: #10b981;
  --accent-dark: #059669;
  --accent-soft: #ecfdf5;
  --danger: #dc2626;
  --danger-dark: #b91c1c;
  --danger-soft: #fef2f2;
  --amber: #f59e0b;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --bg-soft: #f1f5f9;
  --surface: #ffffff;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 40px rgba(15, 23, 42, 0.12);
  --font: 'Plus Jakarta Sans', "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

img, iframe { max-width: 100%; }

h1 { letter-spacing: -0.01em; line-height: 1.2; }
h2 { margin-top: 32px; letter-spacing: -0.01em; line-height: 1.25; }

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* .container is provided by Bootstrap — do not override */

main.page { padding: 28px 0 64px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  font-family: inherit;
  line-height: 1.2;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-lg { min-height: 52px; padding: 14px 28px; font-size: 1.05rem; border-radius: 12px; }
.btn-sm { min-height: 34px; padding: 6px 14px; font-size: 0.85rem; border-radius: 8px; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-dark); }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-warning:hover { background: #d97706; }

/* ---------- CTA ---------- */
.cta-banner {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4338ca 100%);
  color: #fff;
  border-radius: 20px;
  padding: 44px 22px;
  text-align: center;
}
.cta-banner h2 { margin: 0 0 12px; font-size: clamp(1.5rem, 3vw, 2.1rem); }
.cta-banner p { margin: 0 auto 24px; max-width: 520px; opacity: 0.9; }
.cta-banner .btn-primary { background: #fff; color: var(--brand); }
.cta-banner .btn-primary:hover { background: #eef2ff; }
.cta-banner .btn-outline { border-color: rgba(255, 255, 255, 0.5); color: #fff; }
.cta-banner .btn-outline:hover { border-color: #fff; }

@media (min-width: 640px) {
  .cta-banner { padding: 56px 40px; }
}

/* ---------- Typography helpers ---------- */
.small { font-size: 0.88rem; }
.center { text-align: center; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 10px 0; border-bottom: 1px solid var(--line); }
ul.plain li:last-child { border-bottom: none; }

/* ---------- Forms ---------- */
label { display: block; margin: 14px 0 6px; font-weight: 600; font-size: 0.92rem; }

/* ---------- Auth box ---------- */
.auth-box {
  max-width: 460px;
  margin: 24px auto;
  padding: 26px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.auth-box h1 { margin: 0 0 6px; font-size: 1.45rem; }

@media (min-width: 640px) {
  .auth-box { margin: 48px auto; padding: 34px 30px; }
}

.auth-box.auth-box-wide { max-width: 720px; }

/* ---------- Alerts ---------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin: 14px 0;
  font-size: 0.94rem;
  border: 1px solid transparent;
}
.alert-success { background: var(--accent-soft); color: var(--accent-dark); border-color: #a7f3d0; }
.alert-error { background: var(--danger-soft); color: var(--danger-dark); border-color: #fecaca; }
.alert-info { background: var(--brand-soft); color: var(--brand-dark); border-color: #c7d2fe; }
.alert a { font-weight: 600; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.badge-green { background: var(--accent-soft); color: var(--accent-dark); }
.badge-gray { background: var(--bg-soft); color: #475569; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; min-width: 560px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table tr:last-child td { border-bottom: none; }
.table .num { text-align: right; white-space: nowrap; }
.table .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.88rem; }

@media (min-width: 640px) {
  .table { font-size: 0.93rem; min-width: 0; }
  .table th, .table td { padding: 12px 16px; }
}

/* ---------- Stats ---------- */
.stat-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
.stat { text-align: center; padding: 18px 12px; }
.stat-num { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.stat div:last-child { color: var(--muted); font-size: 0.82rem; }

@media (min-width: 640px) {
  .stat-grid { grid-template-columns: repeat(3, 1fr); gap: 18px; }
}
@media (min-width: 900px) {
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .stat { padding: 20px 14px; }
}

/* ---------- Cards (extended) ---------- */
.card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-top h3 { margin: 0 0 8px; }

/* ---------- Directory / filters ---------- */
.filter-bar { display: flex; flex-direction: column; gap: 12px; margin: 20px 0 28px; }
.filter-bar input { margin-top: 0; }
.filter-bar .btn { margin-top: 0; }
.profile { align-items: start; }

@media (min-width: 640px) {
  .filter-bar { flex-direction: row; align-items: flex-end; flex-wrap: wrap; }
  .filter-bar input { width: auto; flex: 1; min-width: 160px; }
}

.inline-label { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.inline-label select { width: 100%; margin-top: 0; }

@media (min-width: 640px) {
  .inline-label { flex-direction: row; align-items: center; gap: 10px; }
  .inline-label select { width: auto; min-width: 200px; }
}

/* ---------- Dashboard ---------- */
.nav-stack { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.nav-stack .btn { justify-content: flex-start; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); display: grid; place-items: center; padding: 16px; z-index: 100; }
.modal-box { width: 100%; max-width: 480px; margin: 0; max-height: 90vh; overflow-y: auto; }

/* ---------- Profile page ---------- */
.profile-card { margin-bottom: 18px; }
.profile-card h3 { margin-top: 0; }
.profile-form [data-editable]:disabled {
  background: var(--bg-soft);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.85;
}
.profile-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }

@media (min-width: 640px) {
  .profile-actions { flex-direction: row; gap: 12px; }
}

/* ---------- Admin tabs ---------- */
.tabs { display: flex; gap: 6px; border-bottom: 2px solid var(--line); margin: 24px 0 20px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tab {
  padding: 10px 16px;
  border-radius: 10px 10px 0 0;
  font-weight: 600;
  white-space: nowrap;
  color: var(--muted);
  border: 1px solid transparent;
  border-bottom: none;
  margin-bottom: -2px;
}
.tab:hover { color: var(--ink); background: var(--bg-soft); text-decoration: none; }
.tab.active {
  color: var(--brand);
  background: var(--surface);
  border-color: var(--line);
  box-shadow: inset 0 -2px 0 var(--brand);
}
.tab-count { font-weight: 800; }

/* ---------- Admin children rows ---------- */
.children-toggle { border-color: var(--line); color: var(--brand); }
.children-row td { background: var(--bg-soft); padding: 4px 16px 16px; }
.children-table { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }

/* ---------- Fee follow-ups ---------- */
.table td .form-check-input { width: 1.2em; height: 1.2em; margin: 0; cursor: pointer; }
.table th .form-check-input { width: 1.2em; height: 1.2em; margin: 0; cursor: pointer; }
.table .form-check { margin-bottom: 0; min-height: auto; line-height: 1; }
.followup-composer { margin-top: 18px; }
.followup-composer h3 { margin-top: 0; }
.followup-composer code { background: var(--bg-soft); padding: 1px 6px; border-radius: 6px; font-size: 0.85em; }
.followup-actions { display: flex; align-items: center; gap: 16px; margin-top: 16px; flex-wrap: wrap; }

/* ---------- Pagination ---------- */
.pagination { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; margin-top: 16px; }
.pagination-links { display: flex; gap: 6px; flex-wrap: wrap; }
.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
}
.page-link:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.page-link.current { background: var(--brand); color: #fff; border-color: var(--brand); }

@media (min-width: 640px) {
  .pagination { flex-direction: row; align-items: center; justify-content: space-between; }
}

/* ---------- Admin settings ---------- */
.form-card h3 { margin: 26px 0 6px; }
.form-card h3:first-child { margin-top: 0; }
.form-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 26px; }

@media (min-width: 640px) {
  .form-actions { flex-direction: row; gap: 12px; flex-wrap: wrap; }
}

/* ---------- Analytics ---------- */
.range-select { display: flex; align-items: center; gap: 8px; }
.stat-grid .stat { padding: 18px 12px; }
.analytics-grid { grid-template-columns: 1fr; align-items: start; margin-top: 22px; }
.analytics-grid .card h3 { margin-top: 0; }
.bar-chart { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding-top: 10px; }
.bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar { width: 100%; max-width: 34px; background: linear-gradient(180deg, var(--brand), var(--accent)); border-radius: 5px 5px 0 0; }
.bar-label { margin-top: 6px; font-size: 0.68rem; color: var(--muted); }

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

/* ---------- Subject picker (teacher profile) ---------- */
.subject-picker {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: center;
  margin-top: 8px;
}
.subject-picker select {
  width: 100%;
  min-height: 160px;
  margin-top: 0;
}
.subject-picker-actions { display: flex; flex-direction: row; gap: 8px; justify-content: center; }
.subject-picker-add { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.subject-picker-add input { margin-top: 0; flex: 1; }
.subject-picker-add .btn { margin-top: 0; }

@media (min-width: 640px) {
  .subject-picker { grid-template-columns: 1fr auto 1fr; }
  .subject-picker-actions { flex-direction: column; justify-content: center; }
  .subject-picker-add { flex-direction: row; }
}

/* ---------- Chip pickers (teacher profile) ---------- */
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.chip-group-label { font-weight: 600; margin: 0 0 4px; color: var(--muted, #6c757d); }
.chip-group .btn { border-radius: 999px; }
.picker-title { font-weight: 600; margin: 0 0 2px; font-size: 0.95rem; }
.custom-add-row { display: flex; flex-direction: row; gap: 8px; align-items: center; }
.custom-add-row .form-control { flex: 1; }
.custom-add-row .btn { white-space: nowrap; }

/* ---------- Language table (teacher profile) ---------- */
.lang-table { margin-top: 10px; }
.lang-table thead th,
.lang-table td { padding: 0; }
.lang-table .form-check-input {
  margin-top: 0;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 0;
  cursor: pointer;
}
.lang-name { font-weight: 600; }
.lang-add-row { max-width: 340px; }

/* ---------- Switch list (teacher profile) ---------- */
.form-switch-list .form-check { margin-bottom: 10px; }


/* ---------- Weekly availability slots (teacher profile) ---------- */
.field-label { font-weight: 600; margin: 0 0 6px; }
.slots-editor { margin-top: 18px; padding: 14px; border: 1px solid var(--border, #ddd); border-radius: 8px; }

.availability-day {
  border: 1px solid var(--border, #ddd);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.availability-day:last-child { margin-bottom: 0; }
.availability-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.day-name {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  color: var(--brand, #2b6cb0);
}
.day-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.day-copy-panel {
  margin-top: 10px;
  padding: 10px;
  background: var(--bg, #f7f7f7);
  border: 1px dashed var(--border, #ddd);
  border-radius: 8px;
}
.time-slot-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  flex-wrap: wrap;
}
.time-slot-row:first-child { padding-top: 0; }
.time-slot-row:last-child { padding-bottom: 0; }
.time-slot-row input[type="time"] { width: 150px; flex: 0 1 auto; }
.time-slot-row .slot-remove { flex: 0 0 auto; }

/* Live directory filtering feedback */
#dir-results { transition: opacity 0.15s ease; }
#dir-results.dir-loading { opacity: 0.45; pointer-events: none; }

/* ---------- Admin contact inbox ---------- */
.table .msg-cell { min-width: 280px; max-width: 420px; white-space: pre-wrap; }

/* Admin messages inbox: user reports (differentiated from contact messages) */
.report-inbox { border: 1px solid #fecaca; background: #fffbfb; }
.report-inbox-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.report-inbox-head h2 { margin: 0; }
.report-inbox-head p { margin: 0; width: 100%; }
.badge-red { background: var(--danger-soft); color: var(--danger-dark); }
.report-list { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.report-card {
  border: 1px solid var(--line);
  border-left: 4px solid #fca5a5;
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--surface);
}
.report-card.report-open { border-left-color: var(--danger); }
.report-from-to { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.report-party { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.report-arrow { color: var(--muted); font-weight: 700; }
.report-status { margin-left: auto; }
.report-message {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border-radius: 8px;
  font-size: 0.92rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.report-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.report-foot form { margin: 0; }
.inbox-divider { margin: 28px 0 22px; border: 0; border-top: 1px solid var(--line); }

/* ---------- Dashboard grids ---------- */
.dash-grid { gap: 18px; }
.dash-section-title { margin: 32px 0 8px; }

@media (min-width: 640px) {
  .dash-grid { gap: 22px; }
}

/* ---------- Connection chat window ---------- */
/* Chat styles live in app.theme.css (shared design system). */

/* Moderation block / report controls */
.moderation-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.moderation-actions form { margin: 0; }
.report-box summary { cursor: pointer; list-style: none; }
.report-box[open] summary { margin-bottom: 8px; }
.report-box form { min-width: 280px; }
.report-box textarea { width: 100%; }
