﻿/* ================================================================
   ELWAT — Complete Design System (Velor-inspired)
   Every Learning Way Tech | _shared.css
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Patrick+Hand&display=swap');
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css');

/* ================================================================
   CSS VARIABLES - DARK MODE (Default)
   ================================================================ */
:root {
  --font-display: 'Patrick Hand', 'Comic Sans MS', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-ui:      'Patrick Hand', 'Comic Sans MS', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body:    'Patrick Hand', 'Comic Sans MS', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Spacing scale */
  --sp-1: 0.25rem;  --sp-2: 0.5rem;  --sp-3: 0.75rem;
  --sp-4: 1rem;     --sp-5: 1.25rem; --sp-6: 1.5rem;
  --sp-8: 2rem;     --sp-10: 2.5rem; --sp-12: 3rem;

  /* Container */
  --page-max: 760px;
  --page-wide: 1180px;

  /* Background texture (dark) */
  --v-dot:     rgba(37, 99, 235, 0.12);
  --v-glow-a:  rgba(37, 99, 235, 0.15);
  --v-glow-b:  rgba(37, 99, 235, 0.08);

  /* Glass / card surfaces — visible raised panels on pure black */
  --glass-bg:     rgba(255, 255, 255, 0.055);
  --glass-bg-2:   linear-gradient(158deg, #17181d 0%, #0d0e11 100%);
  --card-hi:      inset 0 1px 0 rgba(255,255,255,0.06);
  --blue-grad:    linear-gradient(135deg, #3b82f6 0%, #2563eb 55%, #1d4ed8 100%);
  
  /* Surface — dark (default). Base is pure black; surfaces lift with subtle greys. */
  --bg:            #000000;
  --bg-2:          #0f0f0f;
  --bg-3:          #181818;
  --bg-hover:      #242424;

  /* Premium blue palette (primary accent) */
  --blue:          #2563eb;
  --blue-light:    #60a5fa;
  --blue-dim:      rgba(37,99,235,0.18);
  --blue-faint:    rgba(37,99,235,0.08);
  
  --primary:       var(--blue);

  /* Foreground */
  --cream:         #f5efe6;
  --muted:         #7a7a7a;
  --muted-dim:     #4a4a4a;

  /* Legacy overrides for existing elements */
  --text:         var(--cream);
  --text-2:       var(--muted);
  --text-3:       var(--muted-dim);

  /* Feedback */
  --danger:        #d94b4b;
  --danger-soft:   rgba(217,75,75,0.12);
  --success:       #4ade80;
  --success-soft:  rgba(74,222,128,0.12);
  --info:          #60a5fa;

  /* Navigation (blurred) */
  --nav-bg:        rgba(0,0,0,0.85);

  /* Rhythm */
  --radius:        12px;
  --radius-lg:     20px;
  --radius-sm:     8px;
  --radius-pill:   999px;

  /* Shadows — top highlight + soft drop for tactile depth */
  --shadow:        inset 0 1px 0 rgba(255,255,255,0.06), 0 10px 28px rgba(0,0,0,0.55);
  --shadow-lg:     inset 0 1px 0 rgba(255,255,255,0.07), 0 24px 60px rgba(0,0,0,0.65);
  --shadow-primary: 0 8px 24px rgba(37,99,235,0.45);

  /* Layout */
  --nav-h:         64px;
  --bottom-nav-h:  72px;
  --max-w:         1200px;

  /* Motion */
  --transition:    0.25s cubic-bezier(0.4,0,0.2,1);
  --transition-slow: 0.45s cubic-bezier(0.4,0,0.2,1);

  /* Safe areas */
  --safe-top:      env(safe-area-inset-top, 0px);
  --safe-bottom:   env(safe-area-inset-bottom, 0px);
}

/* ================================================================
   CSS VARIABLES - LIGHT MODE
   ================================================================ */
[data-theme="light"] {
  --blue:          #1d4ed8;
  --blue-light:    #2563eb;
  --blue-dim:      rgba(29,78,216,0.14);
  --blue-faint:    rgba(29,78,216,0.06);

  --v-dot:     rgba(29, 78, 216, 0.16);
  --v-glow-a:  rgba(37, 99, 235, 0.12);
  --v-glow-b:  rgba(37, 99, 235, 0.07);

  --glass-bg:     rgba(0, 0, 0, 0.04);
  --glass-bg-2:   linear-gradient(158deg, #ffffff 0%, #f4f1ea 100%);
  --card-hi:      inset 0 1px 0 rgba(255,255,255,0.9);

  --bg:            #f8f5f0;
  --bg-2:          #ffffff;
  --bg-3:          #f0ece5;
  --bg-hover:      #e8e3d8;
  --cream:         #2a2218;
  --muted:         #8a7a6a;
  --muted-dim:     #b8ac9c;
  
  --nav-bg:        rgba(248,245,240,0.88);
  --shadow:        0 8px 32px rgba(29,78,216,0.1);
  --shadow-lg:     0 20px 60px rgba(29,78,216,0.15);

  --text:         var(--cream);
  --text-2:       var(--muted);
  --text-3:       var(--muted-dim);
  --primary:       var(--blue);
}

/* ================================================================
   RESET & BASE
   ================================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; border: none !important; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scrollbar-width: none;
}

::-webkit-scrollbar { width: 0px; height: 0px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: transparent; }

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--cream);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
  transition: background var(--transition), color var(--transition);
  position: relative;
  padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 1.5rem);
}

/* ── Animated background: dot grid + breathing glows ──────── */
body::before {
  content: '';
  position: fixed;
  inset: -10% -10% -10% -10%;
  z-index: -2;
  pointer-events: none;
  background-image: radial-gradient(circle, var(--v-dot) 1px, transparent 1.5px);
  background-size: 26px 26px;
  -webkit-mask-image: radial-gradient(130% 110% at 50% 0%, #000 45%, transparent 92%);
          mask-image: radial-gradient(130% 110% at 50% 0%, #000 45%, transparent 92%);
  animation: vGridDrift 60s linear infinite;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(42% 38% at 16% 8%,  var(--v-glow-a), transparent 72%),
    radial-gradient(48% 42% at 88% 86%, var(--v-glow-b), transparent 74%);
  animation: vGlowBreathe 16s ease-in-out infinite alternate;
}

@keyframes vGridDrift {
  from { background-position: 0 0; }
  to   { background-position: 26px 52px; }
}
@keyframes vGlowBreathe {
  0%   { opacity: 0.65; transform: scale(1)    translateY(0); }
  100% { opacity: 1;    transform: scale(1.08) translateY(-1.5%); }
}

@media (prefers-reduced-motion: reduce) {
  body::before, body::after { animation: none !important; }
}

img, svg, video { max-width: 100%; display: block; }
a { color: var(--blue); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--blue-light); }
button, input, select, textarea { font-family: inherit; color: inherit; background: none; outline: none; }
button { cursor: pointer; }

::selection { background: var(--blue-dim); color: var(--blue-light); }

/* ================================================================
   TYPOGRAPHY
   ================================================================ */
h1, h2, h3, h4, h5, h6 { font-family: var(--font-display); line-height: 1.15; letter-spacing: -0.01em; font-weight: 600; }
h1 { font-size: clamp(1.9rem, 6vw, 2.6rem); }
h2 { font-size: clamp(1.35rem, 4vw, 2rem); }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }

.display { font-family: var(--font-display); font-weight: 700; }

/* ── Page container ──────────────────────────────────────── */
.page {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: calc(var(--safe-top) + 1.25rem) 1.25rem 0;
}
@media (min-width: 768px) {
  .page { padding-left: 1.5rem; padding-right: 1.5rem; }
}

/* ================================================================
   TOP NAVIGATION (Desktop & Mobile-First)
   ================================================================ */
.topnav {
  position: sticky; top: 0; z-index: 50;
  background: var(--nav-bg);
  backdrop-filter: blur(22px) saturate(170%);
  -webkit-backdrop-filter: blur(22px) saturate(170%);
  padding: calc(var(--safe-top) + 0.7rem) 1.25rem 0.7rem;
  display: flex; align-items: center; gap: 0.6rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}
@media (min-width: 768px) {
  .topnav { padding: calc(var(--safe-top) + 0.85rem) 1.5rem 0.85rem; gap: 0.75rem; }
}
.topnav-brand {
  font-family: var(--font-ui); font-size: 1.25rem;
  letter-spacing: 0.22em; color: var(--blue); font-weight: 700;
  cursor: pointer; user-select: none;
}
.topnav-brand .dot { color: var(--cream); }
.topnav-spacer { flex: 1; }
.topnav-icon {
  width: 40px; height: 40px; min-width: 40px; min-height: 40px;
  border-radius: 50%;
  background: var(--bg-3);
  display: grid; place-items: center;
  color: var(--cream); cursor: pointer;
  transition: all var(--transition); position: relative;
}
.topnav-icon:hover { color: var(--blue); background: var(--blue-faint); }
.topnav-icon:active { transform: scale(0.94); }

/* ================================================================
   BARE CHROME — router sets body.bare for immersive page modules
   (lesson, reels…) that render their own header/nav. Hide the shell
   topnav + bottom-nav so those modules own the whole viewport.
   ================================================================ */
body.bare .topnav,
body.bare .bottom-nav { display: none !important; }

/* ================================================================
   BOTTOM NAVIGATION (Floating Pill)
   ================================================================ */
.bottom-nav {
  position: fixed; bottom: calc(var(--safe-bottom) + 1.1rem);
  left: 50%; transform: translateX(-50%); z-index: 40;
  display: flex; align-items: center; justify-content: center;
}
.bn-main {
  display: flex; align-items: center;
  background: rgba(28,28,30,0.55);
  backdrop-filter: blur(28px) saturate(200%);
  -webkit-backdrop-filter: blur(28px) saturate(200%);
  border-radius: 999px;
  padding: 0.5rem 0.75rem; gap: 0.25rem;
  box-shadow: 0 14px 40px rgba(0,0,0,0.45);
}
[data-theme="light"] .bn-main {
  background: rgba(248,245,240,0.7);
  box-shadow: var(--shadow);
}
.bn-item {
  display: grid; place-items: center; width: 42px; height: 42px;
  color: var(--muted); cursor: pointer; border-radius: 50%;
  transition: all var(--transition); position: relative;
  text-decoration: none;
}
.bn-item span { display: none; } /* Hide text, icon only */
.bn-item:hover { color: var(--cream); }
.bn-item.active { color: var(--blue); }
.bn-item.active::after {
  content: ''; position: absolute; bottom: 2px; left: 50%;
  width: 4px; height: 4px; border-radius: 50%; background: var(--blue);
  transform: translateX(-50%);
}
.bn-ico, .bn-item i { font-size: 1.05rem; line-height: 1; }

.bn-plus {
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--blue-grad);
  color: #fff; display: grid; place-items: center; cursor: pointer;
  box-shadow: var(--shadow);
  transition: all var(--transition); margin: 0 0.25rem;
  position: relative; z-index: 1; text-decoration: none;
}
.bn-plus:hover { transform: scale(1.06) rotate(6deg); box-shadow: var(--shadow); color: #fff; }
.bn-plus i { font-size: 1.1rem; }

/* ================================================================
   AVATARS (global) — avatarEl() emits `.avatar .avatar-<size>` for
   images and `.avatar-placeholder .avatar-<size>` for initials.
   Without these, an uploaded image avatar renders at its natural
   size and blows out every layout it appears in.
   ================================================================ */
.avatar {
  border-radius: 50%; object-fit: cover; flex-shrink: 0;
  background: var(--bg-3); display: block;
}
.avatar-placeholder {
  border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  font-family: var(--font-ui); font-weight: 700;
  color: var(--blue); background: var(--blue-dim);
  line-height: 1; text-transform: uppercase;
}
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-md { width: 44px; height: 44px; font-size: 16px; }
.avatar-lg { width: 64px; height: 64px; font-size: 22px; }
.avatar-xl { width: 96px; height: 96px; font-size: 28px; }

/* ================================================================
   AI ASSISTANT STYLES
   ================================================================ */

/* The AI assistant now lives inside the bottom nav (.bn-ai), so the old
   floating action button is hidden. Kept in the DOM because ai-assistant.js
   still binds its click/active state to #aiAssistantBtn. */
.ai-assistant-btn {
  display: none !important;
}
/* AI entry point now lives inside the bottom nav as a normal .bn-item —
   same muted treatment as its siblings (no dominant center pill). */
.ai-assistant-btn svg,
.ai-assistant-btn i {
  font-size: 24px;
  width: 24px;
  height: 24px;
}

.ai-assistant-panel {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 600px;
  max-height: calc(100vh - 120px);
  background: var(--glass-bg-2);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-bg);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  z-index: 100;
  overflow: hidden;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}
.ai-assistant-panel.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

[data-theme="light"] .ai-assistant-panel {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.ai-assistant-header {
  padding: 1rem;
  border-bottom: 1px solid var(--glass-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--glass-bg);
}
.ai-assistant-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.ai-avatar {
  font-size: 1.5rem;
  background: var(--blue-faint);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ai-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--cream);
  line-height: 1.2;
}
[data-theme="light"] .ai-name {
  color: var(--bg);
}
.ai-status {
  font-size: 0.75rem;
  color: var(--blue-light);
}

.ai-close-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.25rem;
  cursor: pointer;
  transition: color var(--transition);
}
.ai-close-btn:hover {
  color: var(--cream);
}
[data-theme="light"] .ai-close-btn:hover {
  color: var(--bg);
}

.ai-chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ai-message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}
.ai-message-assistant {
  align-self: flex-start;
}
.ai-message-user {
  align-self: flex-end;
}

.ai-message-content {
  padding: 0.75rem 1rem;
  border-radius: 1.2rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--cream);
}
[data-theme="light"] .ai-message-content {
  color: var(--bg);
}

.ai-message-assistant .ai-message-content {
  background: var(--bg-3);
  border-bottom-left-radius: 0.25rem;
}
[data-theme="light"] .ai-message-assistant .ai-message-content {
  background: #f1f5f9;
}

.ai-message-user .ai-message-content {
  background: var(--blue);
  color: #fff !important;
  border-bottom-right-radius: 0.25rem;
}

.ai-input-container {
  padding: 0.75rem;
  border-top: 1px solid var(--glass-bg);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-2);
}
[data-theme="light"] .ai-input-container {
  background: #fff;
}

.ai-voice-btn, .ai-send-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}
.ai-voice-btn:hover, .ai-send-btn:hover {
  background: var(--glass-bg);
  color: var(--blue-light);
}
.ai-voice-btn.recording {
  color: #ef4444;
  animation: ai-pulse 1.5s infinite;
}
@keyframes ai-pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.ai-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--cream);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  padding: 0.5rem;
  outline: none;
}
[data-theme="light"] .ai-input {
  color: var(--bg);
}

/* ================================================================
   FORM SYSTEM  (admin shell + shared pages)
   Pages mark forms up with .form-group/.form-label/.form-row and drop in
   un-classed <input>/<textarea>/<select>. These rules give every bare control
   the Velor look. `:where()` keeps them at ZERO specificity so any page-level
   class still wins; `.ai-input` is excluded so the chat box keeps its own style.
   ================================================================ */
:where(
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]):not([type=submit]):not([type=button]):not([type=reset]):not([type=image]):not(.ai-input),
  textarea,
  select
) {
  width: 100%;
  min-height: 46px;
  padding: 0 1rem;
  font-family: var(--font-ui); font-size: 0.95rem; color: var(--text);
  background: var(--bg-3);
  border: 1px solid transparent;
  border-radius: var(--radius);
  box-shadow: var(--card-hi);
  transition: border-color var(--transition), box-shadow var(--transition);
}
:where(textarea) { min-height: 110px; padding: 0.75rem 1rem; line-height: 1.5; resize: vertical; }
:where(input, textarea, select)::placeholder { color: var(--muted); }
:where(input, textarea, select):focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-faint); outline: none; }
:where(select) {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  padding-right: 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a7a7a' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 1rem center; background-size: 1.05rem;
}
:where(input[type=checkbox], input[type=radio]) { width: 18px; height: 18px; accent-color: var(--blue); cursor: pointer; }
:where(input[type=range]) { accent-color: var(--blue); }
:where(input[type=file]) { font-size: 0.9rem; color: var(--muted); padding: 9px 1rem; }
:where(input[type=file])::file-selector-button {
  margin-right: 0.75rem; padding: 8px 1rem;
  font: inherit; font-weight: 600; font-size: 0.85rem;
  color: var(--text); background: var(--bg-hover);
  border: 0; border-radius: var(--radius-sm); cursor: pointer;
}

.form-group { display: grid; gap: 0.4rem; margin-bottom: 1rem; text-align: left; }
.form-group:last-child { margin-bottom: 0; }
.form-label { font-size: 0.82rem; font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.form-label i { color: var(--muted-dim); }
.form-hint { font-size: 0.78rem; color: var(--muted-dim); line-height: 1.4; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.form-section { margin-bottom: 1.5rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.25rem; }
.form-actions .btn { flex: 1; min-width: 140px; }
.form-card { padding: 1.25rem; background: var(--glass-bg-2); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.input-group { position: relative; display: flex; align-items: stretch; gap: 0.5rem; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }

/* iOS-style toggle switch */
.toggle-switch { position: relative; display: inline-flex; flex-shrink: 0; width: 46px; height: 28px; cursor: pointer; }
.toggle-switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.toggle-slider { position: absolute; inset: 0; border-radius: var(--radius-pill); background: var(--bg-hover); transition: background var(--transition); }
.toggle-slider::before {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.4);
  transition: transform var(--transition);
}
.toggle-switch input:checked + .toggle-slider { background: var(--blue); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }
.toggle-switch input:focus-visible + .toggle-slider { box-shadow: 0 0 0 3px var(--blue-faint); }
