/* =========================================================
   Hermer MonProf ID — VIP Theme Core Tokens
   ========================================================= */
:root {
  --bg: #f6f8fb;
  --bg-soft: #f1f5f9;
  --panel: #ffffff;
  --panel-strong: #f8fafd;
  --surface: #ffffffd9;
  --primary: #ff7a59;
  --primary-strong: #ff5522;
  --primary-soft: #fff2ee;
  --secondary: #22b8cf;
  --secondary-soft: #eef8fb;
  --muted: #7b8aa0;
  --text: #1f2a36;
  --text-secondary: #4b5568;
  --border: #e4e9f0;
  --border-light: #eef1f6;
  --ok: #20c997;
  --warn: #ffc107;
  --err: #ff4d4f;
  --shadow: 0 10px 30px rgba(16, 28, 48, .08);
  --shadow-sm: 0 4px 12px rgba(16, 28, 48, .06);
  --shadow-glow: 0 0 0 3px rgba(34,184,207,.18), 0 6px 18px rgba(16, 28, 48,.08);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 10px;
  --max: 1100px;
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
.container { width: min(var(--max), 92vw); margin-inline: auto; }

/* =========================================================
   Navbar
   ========================================================= */
.navbar {
  background: rgba(255,255,255,.82);
  backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}
.nav-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: 12px;
}
.logo { display: inline-flex; gap: 10px; align-items: center; font-weight: 700; font-size: 16px; }
.logo-icon { font-size: 22px; }
.nav-actions { display: flex; gap: 10px; align-items: center; }

/* =========================================================
   Buttons
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  font-weight: 600;
  cursor: pointer;
  transition: .15s transform,.15s filter,.15s box-shadow,.15s border-color;
  outline: none;
  background: var(--surface);
  color: var(--text);
}
.btn-primary {
  background: linear-gradient(180deg,#ff9a7f,#ff6b4a);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 18px rgba(255,122,89,.28);
}
.btn-primary:hover { filter: brightness(.97); border-color: var(--border-light); }
.btn-secondary {
  background: var(--panel);
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost { background: transparent; color: #2c3a47; }
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn-lg { padding: 13px 18px; border-radius: var(--radius-sm); font-size: 16px; }
.btn:focus-visible { box-shadow: 0 0 0 3px rgba(34,184,207,.25); border-color: var(--secondary); }

/* =========================================================
   Alerts
   ========================================================= */
.flash-debug { position: fixed; inset: 0 0 auto; pointer-events: none; z-index: 100; display: grid; justify-items: center; padding-top: 12px; }
.flash-msg {
  pointer-events: auto;
  max-width: min(var(--max), 96vw);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: white;
  font-weight: 600;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}
.flash-success { background: linear-gradient(180deg,#20c997,#14a37a); }
.flash-error { background: linear-gradient(180deg,#ff6b6b,#d63030); }
.flash-warning { background: linear-gradient(180deg,#ffc107,#e6a100); color: #2b1d00; }
.flash-info { background: linear-gradient(180deg,#22b8cf,#1096a8); }
.flash-close { cursor: pointer; opacity: .9; }

/* =========================================================
   Forms
   ========================================================= */
.form {
  background: var(--panel);
  padding: 22px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}
.form h2 { margin: 0 0 14px; }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field label { font-weight: 600; font-size: 14px; color: #3b4855; }
.field input {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: #fafbfc;
}
.field input:focus { outline: none; border-color: var(--secondary); box-shadow: var(--shadow-glow); }
.hint { color: var(--muted); font-size: 13px; }
.mt-16 { margin-top: 16px; }

/* =========================================================
   Cards & grids
   ========================================================= */
.card {
  background: var(--panel);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 780px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* =========================================================
   Lists & badges
   ========================================================= */
.list { display: grid; gap: 10px; }
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}
.badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--secondary-soft);
  color: #0b7b8c;
  border: 1px solid rgba(34,184,207,.18);
}
.badge-ok { background: #e6f9f2; color: #127a5a; }
.badge-warn { background: #fff8e1; color: #8a6d10; }

/* =========================================================
   Modals
   ========================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20,30,45,.45);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 80;
}
.modal-overlay.hidden { display: none; }
.modal-overlay:not(.hidden) { display: flex; }
dialog.modal {
  border: none;
  border-radius: var(--radius);
  padding: 18px;
  max-width: min(520px, 94vw);
  box-shadow: var(--shadow);
  background: var(--panel);
}
dialog.modal::backdrop {
  background: rgba(20,30,45,.35);
  backdrop-filter: blur(4px);
}
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 10px; }

/* =========================================================
   Misc primitives
   ========================================================= */
.empty { color: var(--muted); }
.panel-title { font-weight: 700; margin: 0 0 10px; }
.section { margin-block: 24px; }

/* =========================================================
   Layout (shared)
   ========================================================= */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 280px;
  background: rgba(255,255,255,.92);
  border-right: 1px solid var(--border-light);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform .28s cubic-bezier(.22,.61,.36,1);
  backdrop-filter: saturate(1.1) blur(12px);
}
.main { flex: 1; padding: 24px; }
@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    transform: translateX(-100%);
    width: min(86vw, 320px);
    box-shadow: 0 16px 40px rgba(16,28,48,.18);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-footer { margin-top: auto; }
  .main { padding: 16px; }
}
.sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 70;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: 0 12px 28px rgba(255,122,89,.28);
  cursor: pointer;
  font-size: 16px;
  transition: .2s transform;
}
.sidebar-toggle:active { transform: scale(.96); }
@media (max-width: 860px) { .sidebar-toggle { display: inline-flex; } }

/* =========================================================
   Child dashboard sidecar
   ========================================================= */
.mini-profile { display: flex; align-items: center; gap: 12px; }
.mini-avatar {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg,#ffd2c2,#ffc4a3);
  display: grid;
  place-items: center;
  font-size: 20px;
  box-shadow: var(--shadow-sm);
}
.mini-name { font-weight: 700; }
.new-session-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: linear-gradient(180deg,#ffffff,#f8fafd);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
}
.sidebar-search input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: #fafbfc;
}
.sessions-group { display: grid; gap: 10px; overflow: auto; max-height: calc(100vh - 280px); padding-right: 4px; }
.sessions-group::-webkit-scrollbar { width: 8px; height: 8px; }
.sessions-group::-webkit-scrollbar-thumb { background: linear-gradient(180deg,#e6eaf2,#dde3ee); border-radius: 999px; }
.session-item { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.session-main { padding: 10px 12px; }
.session-title { font-weight: 700; font-size: 14px; }
.session-meta { color: var(--muted); font-size: 12px; }
.session-badge {
  margin: 0 6px 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--secondary-soft);
  color: #0f7686;
  border: 1px solid rgba(34,184,207,.18);
}
.sidebar-footer { margin-top: auto; }

/* =========================================================
   Chat block (core primitives)
   ========================================================= */
.chat-area, .chat { display: grid; gap: 12px; }
.bubble-avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(135deg,#ffd2c2,#ffc4a3);
  display: grid;
  place-items: center;
  font-size: 18px;
  box-shadow: var(--shadow-sm);
}
.bubble {
  padding: 12px 14px;
  border-radius: 14px;
  line-height: 1.45;
  background: var(--panel);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}
.welcome-bubble.teacher .bubble { background: #fff5f2; border-color: #ffe7df; }
.message { display: flex; gap: 10px; }
.message.teacher { direction: rtl; }
.message.teacher .bubble-avatar { order: 2; }
.message.teacher .bubble { background: #fff5f2; border-color: #ffe7df; }
.message.child .bubble { background: #ffffff; }
.thinking { display: flex; gap: 10px; color: var(--muted); font-size: 13px; }
.composer { display: flex; gap: 10px; }
.composer textarea { flex: 1; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: #fafbfc; resize: vertical; min-height: 44px; }

/* =========================================================
   Dashboard helpers
   ========================================================= */
.dashboard { display: grid; gap: 16px; }
.children-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 980px) { .children-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .children-grid { grid-template-columns: 1fr; } }
.child-card {
  background: var(--panel);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 14px;
}
.child-card-header { display: flex; align-items: center; gap: 12px; }
.child-avatar {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg,#ffd2c2,#ffc4a3);
  display: grid;
  place-items: center;
  font-size: 22px;
  overflow: hidden;
}
.avatar-placeholder { font-weight: 700; color: white; }
.child-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--panel-strong); border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 10px; text-align: center; }
.stat-value { font-weight: 700; font-size: 18px; display: block; }
.stat-label { color: var(--muted); font-size: 12px; }

/* =========================================================
   VIP finish: top/header/title refinements
   ========================================================= */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.topbar h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: .1px; }
.topbar-subtitle { color: var(--muted); margin: 6px 0 0; font-size: 14px; }
.avatar { width: 56px; height: 56px; border-radius: 16px; background: linear-gradient(135deg,#ffd2c2,#ffc4a3); display: grid; place-items: center; font-size: 22px; }

/* Glass VIP helper */
.glass {
  background: rgba(255, 255, 255, .72);
  backdrop-filter: saturate(1.1) blur(10px);
  border: 1px solid rgba(230, 234, 242, .7);
}
