/* ================================================================
   LAYOUT.CSS — Topbar, Sidebar, Content Area, Toolbars & Responsive
   Grammar Strategies — Ayed Academy
   ================================================================ */

/* ── SPLASH ── */
#splash {
  position: fixed; inset: 0; z-index: 2000;
  background: linear-gradient(145deg, var(--navy) 0%, var(--navy-mid) 40%, #0D3B6B 100%);
  display: flex; align-items: center; justify-content: center;
  overflow-y: auto;
  padding: 2rem 0;
}
#splash.fade-out { animation: splashOut 0.7s var(--ease) forwards; }
@keyframes splashOut { to { opacity: 0; transform: scale(1.04); pointer-events: none; } }

.splash-orbs { position: absolute; inset: 0; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; filter: blur(60px); animation: orbFloat 12s ease-in-out infinite; }
.o1 { width:500px; height:500px; background:rgba(245,166,35,0.18); top:-150px; right:-100px; }
.o2 { width:400px; height:400px; background:rgba(0,180,216,0.15); bottom:-100px; left:-100px; animation-delay:-4s; }
.o3 { width:250px; height:250px; background:rgba(6,214,160,0.12); top:40%; left:35%; animation-delay:-8s; }
.o4 { width:200px; height:200px; background:rgba(37,99,235,0.1); bottom:20%; right:20%; animation-delay:-2s; }
@keyframes orbFloat { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(20px,-30px) scale(1.08); } }

.splash-card {
  position: relative; z-index: 1;
  background: rgba(255,255,255,0.06); backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.12); border-radius: var(--r-xl);
  padding: 3rem 3.5rem; max-width: 520px; width: 90%;
  box-shadow: 0 40px 100px rgba(0,0,0,0.4);
  animation: cardIn 0.8s var(--spring);
}
@keyframes cardIn { from { opacity:0; transform: translateY(40px) scale(0.96); } to { opacity:1; transform: translateY(0) scale(1); } }

.splash-logo-wrap { display: flex; align-items: center; gap: 1rem; margin-bottom: 2.5rem; }
.splash-book { font-size: 3.5rem; animation: bookBob 3s ease-in-out infinite; }
@keyframes bookBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.splash-brand { font-family: var(--ff-en); font-size: 1.7rem; font-weight: 900; color: var(--gold); }
.splash-brand-ar { font-size: 0.9rem; color: rgba(255,255,255,0.55); margin-top: 2px; }
.splash-headline { font-size: 1.9rem; font-weight: 900; color: #fff; line-height: 1.3; margin-bottom: 0.75rem; }
.splash-sub { font-size: 1rem; color: rgba(255,255,255,0.6); margin-bottom: 2rem; }

.name-input {
  width: 100%; padding: 1rem 1.2rem;
  background: rgba(255,255,255,0.1); border: 1.5px solid rgba(255,255,255,0.2);
  border-radius: var(--r-md); color: #fff;
  font-size: 1.1rem; font-weight: 600; outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.name-input::placeholder { color: rgba(255,255,255,0.4); }
.name-input:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(245,166,35,0.2); }

.splash-cta {
  width: 100%; padding: 1.1rem;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-lt) 100%);
  color: var(--navy); border-radius: var(--r-md);
  font-size: 1.15rem; font-weight: 800; letter-spacing: 0.01em;
  display: flex; align-items: center; justify-content: center; gap: 0.75rem;
  box-shadow: 0 8px 24px rgba(245,166,35,0.4);
  transition: transform 0.25s var(--spring), box-shadow 0.25s;
  margin-bottom: 2rem;
}
.splash-cta:hover { transform: translateY(-3px); box-shadow: 0 12px 32px rgba(245,166,35,0.5); }
.splash-stats-row { display: flex; align-items: center; justify-content: center; gap: 0; }
.s-stat { text-align: center; padding: 0 1.5rem; color: rgba(255,255,255,0.7); font-size: 0.9rem; }
.s-stat span { display: block; font-family: var(--ff-en); font-size: 1.4rem; font-weight: 800; color: var(--teal); }
.s-divider { width: 1px; height: 36px; background: rgba(255,255,255,0.15); }
.auth-tabs { display: flex; gap: 10px; margin-bottom: 1rem; justify-content: center; }
.auth-tab { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); color: white; padding: 0.5rem 1rem; border-radius: 8px; cursor: pointer; }
.auth-tab.active { background: var(--gold); border-color: var(--gold); color: var(--navy); }

/* ── TOP BAR ── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-h); z-index: 100;
  background: var(--navy);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1rem;
  box-shadow: 0 2px 16px rgba(0,0,0,0.25);
}
.topbar-section { display: flex; align-items: center; gap: 0.75rem; }
.topbar-left { flex: 0 0 auto; }
.topbar-center { flex: 1; justify-content: center; }
.topbar-right { flex: 0 0 auto; gap: 0.6rem; }

.icon-btn {
  width: 38px; height: 38px; border-radius: var(--r-sm);
  background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.85);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; transition: all 0.2s;
}
.icon-btn:hover { background: rgba(255,255,255,0.16); color: #fff; }

.topbar-brand { display: flex; align-items: center; gap: 0.5rem; }
.brand-icon { font-size: 1.3rem; }
.brand-name { font-family: var(--ff-en); font-weight: 800; color: #fff; font-size: 1rem; white-space: nowrap; }

.breadcrumb { display: flex; align-items: center; gap: 0.5rem; color: rgba(255,255,255,0.7); font-size: 0.88rem; }
.bc-sep { opacity: 0.4; }
#bc-unit { font-weight: 700; color: var(--gold); }
#bc-strat { font-weight: 600; }

.student-chip {
  display: flex; align-items: center; gap: 0.5rem;
  background: rgba(255,255,255,0.08); border-radius: var(--r-pill);
  padding: 4px 12px 4px 4px; color: rgba(255,255,255,0.85);
  font-size: 0.88rem; font-weight: 600;
}
.student-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold-lt));
  color: var(--navy); font-weight: 800; font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
}
.progress-pill {
  position: relative; width: 120px; height: 8px;
  background: rgba(255,255,255,0.12); border-radius: var(--r-pill); overflow: hidden;
}
.progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--gold), var(--green));
  border-radius: var(--r-pill); transition: width 0.8s var(--ease);
}
.progress-label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--ff-en); font-size: 0.65rem; font-weight: 800;
  color: rgba(255,255,255,0.9); pointer-events: none;
}

/* ── APP BODY LAYOUT ── */
#app { height: 100vh; display: flex; flex-direction: column; }
.app-body {
  margin-top: var(--topbar-h); flex: 1; display: flex;
  height: calc(100vh - var(--topbar-h)); overflow: hidden;
}

/* ── UNITS SIDEBAR ── */
.units-panel {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--navy-soft); display: flex; flex-direction: column;
  overflow: hidden; transition: transform 0.35s var(--ease), width 0.35s var(--ease); z-index: 50;
}

/* Desktop collapsed: mini rail showing unit numbers only */
@media (min-width: 901px) {
  .units-panel.collapsed { width: 64px; }
  .units-panel.collapsed .panel-head { padding: 1rem 0.5rem 0.75rem; text-align: center; }
  .units-panel.collapsed .panel-title,
  .units-panel.collapsed .panel-progress-text,
  .units-panel.collapsed .unit-nav-info,
  .units-panel.collapsed .unit-nav-check { display: none; }
  /* !important: JS sets inline display:block on this element */
  .units-panel.collapsed #overall-prog-sidebar { display: none !important; }
  .units-panel.collapsed .unit-nav-item {
    justify-content: center; padding: 0.85rem 0;
    border-right-width: 3px;
  }
}
.panel-head { padding: 1.25rem 1.25rem 0.75rem; border-bottom: 1px solid rgba(255,255,255,0.06); }
.panel-title { font-size: 0.95rem; font-weight: 800; color: rgba(255,255,255,0.85); }
.panel-progress-text { font-size: 0.78rem; color: var(--gold); margin-top: 3px; }
.panel-progress-bar { height: 3px; background: rgba(255,255,255,0.08); }
.panel-progress-inner { height: 100%; background: linear-gradient(90deg, var(--gold), var(--teal)); transition: width 0.8s var(--ease); }
.units-nav { flex: 1; overflow-y: auto; padding: 0.5rem 0; }

.unit-nav-item {
  display: flex; align-items: center; gap: 0.9rem;
  padding: 0.85rem 1.25rem; cursor: pointer; transition: all 0.2s;
  border-right: 3px solid transparent; position: relative;
}
.unit-nav-item:hover { background: rgba(255,255,255,0.05); }
.unit-nav-item.active { background: rgba(245,166,35,0.1); border-right-color: var(--gold); }
.unit-nav-item.completed .unit-nav-num { background: var(--green); }
.unit-nav-num {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.8);
  font-family: var(--ff-en); font-size: 0.8rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.unit-nav-item.active .unit-nav-num { background: var(--gold); color: var(--navy); }
.unit-nav-info { flex: 1; text-align: right; }
.unit-nav-ar { font-size: 0.9rem; font-weight: 700; color: rgba(255,255,255,0.85); }
.unit-nav-en { font-family: var(--ff-en); font-size: 0.72rem; color: rgba(255,255,255,0.4); margin-top: 1px; }
.unit-nav-check { font-size: 0.85rem; color: var(--green); }

/* ── CONTENT AREA ── */
.content-area { flex: 1; overflow: hidden; display: flex; flex-direction: column; background: var(--bg); }
.mode-bar {
  background: var(--gold); color: var(--navy);
  padding: 8px 1.5rem; display: flex; justify-content: space-between; align-items: center;
  font-weight: 800; font-size: 0.9rem; z-index: 5; flex-shrink: 0;
}
.mode-bar.eraser { background: var(--red); color: #fff; }
.mode-bar-close { font-size: 1rem; color: inherit; opacity: 0.7; }
.mode-bar-close:hover { opacity: 1; }
.page-content { flex: 1; overflow-y: auto; padding: 2rem; max-width: 1020px; width: 100%; margin: 0 auto; }

/* ── BOTTOM NAV ── */
.bottom-nav {
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 0.85rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.bottom-btn {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 1.2rem; border-radius: var(--r-md);
  font-size: 0.9rem; font-weight: 700; color: var(--text-sec);
  background: var(--surface2); border: 1px solid var(--border); transition: all 0.2s;
}
.bottom-btn:hover { background: var(--border); }
.bottom-btn.primary { background: var(--gold); color: var(--navy); border-color: transparent; }
.bottom-btn.primary:hover { filter: brightness(1.05); }
.bottom-unit-indicator { font-family: var(--ff-en); font-size: 0.9rem; font-weight: 700; color: var(--text-muted); }

/* ── RIGHT TOOLBAR ── */
.right-toolbar {
  width: var(--toolbar-w); flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  padding: 1rem 0; gap: 0.5rem;
}
.rtool-btn {
  width: 38px; height: 38px; border-radius: var(--r-sm);
  font-size: 1.1rem; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; border: 1.5px solid transparent;
}
.rtool-btn:hover { background: var(--bg); color: var(--text-primary); }
.rtool-btn.active { background: var(--gold-dim); border-color: var(--gold); color: var(--navy); }
.rtool-btn.active-eraser { background: var(--red-dim); border-color: var(--red); }
.rtool-divider { width: 28px; height: 1px; background: var(--border); margin: 2px 0; }

/* ── MOBILE TOOLBAR ── */
.mobile-toolbar {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  height: 60px; background: var(--surface); border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.1); z-index: 200;
  flex-direction: row; align-items: center; justify-content: space-around;
  padding: 0 0.5rem; backdrop-filter: blur(12px);
}
.mobile-toolbar .rtool-btn { width: 44px; height: 44px; border-radius: var(--r-md); font-size: 1.25rem; }

/* ── OVERLAY ── */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 49; backdrop-filter: blur(3px); }

/* ── DASHBOARD ── */
#main-dashboard {
  min-height: 100vh; padding: 4rem 2rem; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  animation: fadeUp 0.6s ease-out;
}
.dash-header { text-align: center; margin-bottom: 4rem; }
.dash-logo { font-size: 2rem; color: var(--gold); font-weight: 900; margin-bottom: 1rem; }
.dash-title { font-size: 2.5rem; color: var(--text-primary); font-weight: 800; margin-bottom: 0.5rem; }
.dash-subtitle { font-size: 1.2rem; color: var(--text-sec); }
.dash-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem; width: 100%; max-width: 1000px;
}
.dash-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: 2rem; text-align: center;
  cursor: pointer; transition: all 0.3s ease; box-shadow: var(--sh-md);
}
.dash-card:hover { transform: translateY(-8px); box-shadow: 0 15px 30px rgba(245,158,11,0.15); border-color: var(--gold); }
.dash-icon { font-size: 3rem; margin-bottom: 1.5rem; background: rgba(245,158,11,0.1); width: 80px; height: 80px; line-height: 80px; border-radius: 50%; margin: 0 auto 1.5rem auto; }
.dash-card h3 { color: var(--text-primary); font-size: 1.4rem; font-weight: 800; margin-bottom: 0.8rem; }
.dash-card p { color: var(--text-sec); font-size: 0.95rem; line-height: 1.6; }
.dash-count-badge { display: inline-block; margin-top: 0.8rem; background: rgba(245,166,35,0.12); color: var(--gold); border: 1px solid rgba(245,166,35,0.3); border-radius: 30px; padding: 0.3rem 0.8rem; font-size: 0.78rem; font-weight: 800; }
.dash-footer { margin-top: 4rem; }
.dash-logout-btn { background: transparent; color: var(--text-muted); border: none; font-weight: 600; cursor: pointer; font-size: 1rem; transition: color 0.2s; }
.dash-logout-btn:hover { color: var(--red); }

/* ── EMPTY STATE ── */
.empty-track-msg { text-align: center; padding: 5rem 2rem; color: var(--text-muted); }
.empty-track-msg .empty-icon { font-size: 4rem; margin-bottom: 1rem; opacity: 0.5; }
.empty-track-msg h2 { font-size: 1.5rem; color: var(--text-sec); margin-bottom: 0.5rem; }
.empty-track-msg p { font-size: 1rem; line-height: 1.7; }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; --toolbar-w: 48px; }
  .page-content { padding: 1.5rem; }
  .unit-header { padding: 1.5rem 2rem; }
  .sc-body { grid-template-columns: 200px 1fr; }
  .topbar-center { display: none; }
}

@media (max-width: 768px) {
  :root { --topbar-h: 54px; --sidebar-w: 100%; }
  body { overflow: hidden; }
  #app { height: 100vh; }
  .app-body { height: calc(100vh - var(--topbar-h) - 60px); margin-bottom: 60px; }
  .mobile-toolbar { display: flex; }
  .right-toolbar { display: none; }
  .topbar { padding: 0 0.75rem; }
  .topbar-center { display: none; }
  .topbar-right { gap: 0.35rem; }
  .brand-name { display: none; }
  .student-chip { padding: 3px 8px 3px 3px; }
  #student-name-display { max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.8rem; }
  .progress-pill { width: 80px; }
  .units-panel { position: fixed; top: var(--topbar-h); left: 0; right: 0; bottom: 60px; transform: translateX(100%); z-index: 300; width: 100%; border-radius: 0; }
  .units-panel.open { transform: translateX(0); }
  .content-area { width: 100%; }
  .page-content { padding: 1rem; max-width: 100%; }
  .bottom-nav { padding: 0.65rem 0.75rem; }
  .bottom-btn { padding: 0.5rem 0.75rem; font-size: 0.8rem; gap: 0.3rem; }
  .bottom-btn span:last-child { display: none; }
  .notes-panel { width: 100%; }
  .quiz-overlay { padding: 0; align-items: flex-end; }
  .quiz-modal { max-width: 100%; max-height: 90vh; border-radius: var(--r-xl) var(--r-xl) 0 0; }
  .quiz-opts-grid { grid-template-columns: 1fr; }
  .splash-card { padding: 2rem 1.5rem; max-width: 95%; }
  .dash-grid { gap: 1rem; }
  .fab-scroll { bottom: 4.5rem; left: 1rem; width: 44px; height: 44px; font-size: 1.2rem; }
}

@media (max-width: 480px) {
  .page-content { padding: 0.75rem; }
  .splash-card { padding: 1.5rem 1.25rem; }
  .splash-headline { font-size: 1.3rem; }
}

@media (hover: none) {
  .mini-opt:hover:not(:disabled) { transform: none; }
  .q-opt:hover:not(:disabled) { transform: none; }
  .splash-cta:hover { transform: none; }
  .unit-end-cta button:hover { transform: none; }
}

@media (max-width: 768px) and (orientation: landscape) {
  .app-body { height: calc(100vh - var(--topbar-h) - 52px); margin-bottom: 52px; }
  .units-panel { top: var(--topbar-h); bottom: 52px; }
  .mobile-toolbar { height: 52px; }
}
