/* ════════════════════════════════════════════════════════════════════
   EDU SHELL V2 — Full-screen unified layout for all modules
   Header (48px) + Rail (64px collapsed / 240px expanded) + Main content
   Feature flag controlled via body.edu-shell-active
   ════════════════════════════════════════════════════════════════════ */

/* ─── Design tokens ───────────────────────────────────────────── */
:root {
  --edu-bg:           #F5F7FA;
  --edu-surface:      #FFFFFF;
  --edu-surface-2:    #F8FAFC;
  --edu-border:       rgba(15, 23, 42, 0.08);
  --edu-border-soft:  rgba(15, 23, 42, 0.04);
  --edu-text:         #0F172A;
  --edu-text-mute:    #64748B;
  --edu-text-soft:    #94A3B8;
  --edu-accent:       #6366F1;
  --edu-accent-2:     #8B5CF6;
  --edu-accent-soft:  rgba(99, 102, 241, 0.12);
  --edu-warn:         #F59E0B;
  --edu-success:      #10B981;
  --edu-danger:       #EF4444;

  --edu-radius-sm:    6px;
  --edu-radius:       10px;
  --edu-radius-lg:    14px;
  --edu-radius-xl:    20px;

  --edu-shadow-sm:    0 1px 3px rgba(15,23,42,0.06);
  --edu-shadow:       0 4px 14px -2px rgba(15,23,42,0.10);
  --edu-shadow-lg:    0 12px 32px -8px rgba(15,23,42,0.18);

  --edu-header-h:     48px;
  --edu-rail-w:       240px;
  --edu-rail-w-col:   60px;
  --edu-tx:           cubic-bezier(0.4, 0, 0.2, 1);
}
.dark-mode {
  --edu-bg:           #0B1220;
  --edu-surface:      #111827;
  --edu-surface-2:    #18222E;
  --edu-border:       rgba(255, 255, 255, 0.08);
  --edu-border-soft:  rgba(255, 255, 255, 0.04);
  --edu-text:         #F1F5F9;
  --edu-text-mute:    #94A3B8;
  --edu-text-soft:    #64748B;
}

/* System theme preference (prefers-color-scheme) — sayfa yüklenirken auto-apply edilmediyse fallback */
@media (prefers-color-scheme: dark) {
  body.edu-shell-active:not(.theme-manual) {
    --edu-bg:           #0B1220;
    --edu-surface:      #111827;
    --edu-text:         #F1F5F9;
    --edu-text-mute:    #94A3B8;
  }
}

/* Module geçişi — content fade-in */
body.edu-shell-active main > * {
  animation: edu-fade-in 0.22s var(--edu-tx);
}
@keyframes edu-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Body & global resets when shell is active ──────────────── */
body.edu-shell-active {
  margin: 0; padding: 0;
  background: var(--edu-bg);
  color: var(--edu-text);
  overflow: hidden;
  height: 100vh;
}
body.edu-shell-active > #header,
body.edu-shell-active > .fl-bottom-nav,
body.edu-shell-active > .auth-screen-hint,
body.edu-shell-active > .fl-top-bar {
  display: none !important;
}
body.edu-shell-active main {
  position: fixed;
  top: var(--edu-header-h);
  left: var(--edu-rail-w);
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  background: var(--edu-bg);
  transition: left 0.22s var(--edu-tx);
}
body.edu-shell-active.edu-rail-collapsed main {
  left: var(--edu-rail-w-col);
}

/* ─── Header (top) ─────────────────────────────────────────────── */
body.edu-shell-active .edu-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--edu-header-h);
  background: var(--edu-surface);
  border-bottom: 1px solid var(--edu-border);
  display: flex; align-items: center;
  padding: 0 12px;
  gap: 8px;
  z-index: 100;
}
.edu-header-btn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; cursor: pointer;
  border-radius: var(--edu-radius-sm);
  color: var(--edu-text-mute);
  transition: background 0.15s, color 0.15s;
}
.edu-header-btn:hover {
  background: var(--edu-border-soft);
  color: var(--edu-text);
}
.edu-header-spacer { flex: 1; min-width: 0; }

/* Gri EDU pill (header sol, mobildeki gibi) */
.edu-header-edu {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px;
  background: rgba(15,23,42,0.05);
  border: 1px solid rgba(15,23,42,0.08);
  border-radius: 99px;
  margin-left: 4px;
}
.edu-header-edu-icon { font-size: 12px; opacity: 0.7; line-height: 1; }
.edu-header-edu-label {
  font-size: 10.5px; font-weight: 800;
  letter-spacing: 0.6px;
  color: var(--edu-text-mute);
  text-transform: uppercase;
}
.dark-mode .edu-header-edu {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.08);
}

/* ─── Rail (left) ──────────────────────────────────────────────── */
body.edu-shell-active .edu-rail {
  position: fixed;
  top: var(--edu-header-h);
  left: 0;
  bottom: 0;
  width: var(--edu-rail-w);
  background: var(--edu-surface);
  border-right: 1px solid var(--edu-border);
  display: flex; flex-direction: column;
  padding: 8px 0;
  z-index: 90;
  transition: width 0.22s var(--edu-tx);
  overflow: hidden;
}
body.edu-shell-active.edu-rail-collapsed .edu-rail {
  width: var(--edu-rail-w-col);
}
.edu-rail-list {
  flex: 1; overflow-y: auto;
  padding: 4px 8px;
  display: flex; flex-direction: column; gap: 1px;
}
.edu-rail-list::-webkit-scrollbar { width: 4px; }
.edu-rail-list::-webkit-scrollbar-thumb { background: var(--edu-border); border-radius: 2px; }
.edu-rail-foot {
  padding: 8px 8px 4px;
  border-top: 1px solid var(--edu-border-soft);
}
/* ─── Rail item — monochrome grey/white/black, mobile parite SVG ─── */
.edu-rail-item {
  display: flex; align-items: center; gap: 12px;
  background: transparent; border: 0; cursor: pointer;
  padding: 10px 11px;
  border-radius: var(--edu-radius);
  font-family: inherit;
  color: #6B7280;
  width: 100%; min-width: 0;
  text-align: left;
  position: relative;
  transition: background 0.16s, color 0.16s;
}
.edu-rail-item:hover {
  background: rgba(15,23,42,0.045);
  color: #1F2937;
}
.edu-rail-item.is-active {
  background: rgba(15,23,42,0.07);
  color: #0F172A;
  font-weight: 700;
}
/* Aktif item için sol kenarda ince yüksek-kontrast bar (silah ucu) */
.edu-rail-item.is-active::before {
  content: ''; position: absolute;
  left: 4px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px;
  background: #0F172A;
  border-radius: 2px;
}
.dark-mode .edu-rail-item {
  color: #9CA3AF;
}
.dark-mode .edu-rail-item:hover {
  background: rgba(255,255,255,0.05);
  color: #E5E7EB;
}
.dark-mode .edu-rail-item.is-active {
  background: rgba(255,255,255,0.08);
  color: #FFFFFF;
}
.dark-mode .edu-rail-item.is-active::before {
  background: #FFFFFF;
}

.edu-rail-icon {
  flex-shrink: 0;
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
}
.edu-rail-icon svg {
  width: 22px; height: 22px;
  display: block;
}
.edu-rail-label {
  font-size: 13.5px; font-weight: 600;
  letter-spacing: -0.1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: opacity 0.18s, max-width 0.22s var(--edu-tx);
}
body.edu-shell-active.edu-rail-collapsed .edu-rail-label {
  opacity: 0; max-width: 0; margin: 0;
}
body.edu-shell-active.edu-rail-collapsed .edu-rail-item {
  justify-content: center; padding: 10px 0; gap: 0;
}
body.edu-shell-active.edu-rail-collapsed .edu-rail-item.is-active::before {
  display: none; /* collapsed durumda silah ucu yerine icon kendisi yeterli */
}

/* ─── Tooltip on collapsed rail items (hover) ──────────────────── */
body.edu-shell-active.edu-rail-collapsed .edu-rail-item {
  position: relative;
}
body.edu-shell-active.edu-rail-collapsed .edu-rail-item:hover::after {
  content: attr(aria-label);
  position: absolute; left: calc(100% + 6px); top: 50%;
  transform: translateY(-50%);
  background: var(--edu-text);
  color: var(--edu-surface);
  font-size: 12px; font-weight: 600;
  padding: 5px 9px; border-radius: 6px;
  white-space: nowrap;
  box-shadow: var(--edu-shadow);
  pointer-events: none;
  z-index: 200;
}

/* ─── Content area: tüm modüller buraya render olur ───────────── */
body.edu-shell-active #content {
  padding: 16px 20px 24px;
  min-height: 100%;
  box-sizing: border-box;
  max-width: none;
}

/* tb-page'leri shell içinde edge-to-edge yap. Modüllere göre özelleştirilebilir. */
body.edu-shell-active main .tb-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 24px;
}
/* Geniş ekranlarda biraz daha geniş alan */
@media (min-width: 1440px) {
  body.edu-shell-active main .tb-page {
    max-width: 1320px;
    padding: 20px 32px;
  }
}
@media (min-width: 1920px) {
  body.edu-shell-active main .tb-page {
    max-width: 1480px;
  }
}
/* Mobile'da edge-to-edge */
@media (max-width: 767px) {
  body.edu-shell-active main .tb-page {
    padding: 12px 14px;
  }
}

/* ─── Chat shell + Shell rail çakışması — chat side daha dar ────── */
@media (min-width: 1024px) and (max-width: 1439px) {
  body.edu-shell-active .tb-chat-shell {
    grid-template-columns: 220px 1fr !important;
  }
  body.edu-shell-active .tb-chat-side { padding: 0; }
}
@media (min-width: 1440px) {
  /* 1440px+ → shell rail (240) + chat side (240) + main (flex) + aside (260) */
  body.edu-shell-active .tb-chat-shell {
    grid-template-columns: 240px 1fr 260px !important;
  }
}
@media (max-width: 1023px) {
  body.edu-shell-active .tb-chat-shell {
    grid-template-columns: 1fr !important;
  }
  body.edu-shell-active .tb-chat-side {
    display: none !important;
  }
}

/* Right aside breakpoint adjustment — 1280px'den itibaren göster (önceki 1440) */
@media (min-width: 1280px) and (max-width: 1439px) {
  body.edu-shell-active .tb-chat-shell {
    grid-template-columns: 240px 1fr 240px !important;
  }
  body.edu-shell-active .tb-chat-aside-right {
    display: flex !important;
    flex-direction: column;
    border-left: 1px solid var(--edu-border);
    background: var(--edu-surface-2);
    overflow-y: auto;
    padding: 14px 12px;
    gap: 14px;
  }
}

/* ─── Chat shell — full ekran content alanı içinde de tam ekran ── */
body.edu-shell-active.coach-chat-active main {
  overflow: hidden;
  padding: 0;
}
body.edu-shell-active .tb-chat-shell {
  position: absolute;
  top: 0; bottom: 0; left: 0; right: 0;
  inset: 0;
}
body.edu-shell-active #content {
  position: relative;
  padding: 0;
}
body.edu-shell-active main > #content,
body.edu-shell-active main #content {
  height: 100%;
}

/* ─── Tablet (768-1024): rail auto-collapse ────────────────────── */
@media (min-width: 768px) and (max-width: 1023px) {
  body.edu-shell-active main {
    left: var(--edu-rail-w-col);
  }
  body.edu-shell-active .edu-rail {
    width: var(--edu-rail-w-col);
  }
  body.edu-shell-active .edu-rail-label {
    opacity: 0; max-width: 0;
  }
  body.edu-shell-active .edu-rail-item {
    justify-content: center; padding: 10px 0; gap: 0;
  }
}

/* ─── Mobile (<768px): rail = drawer ──────────────────────────── */
@media (max-width: 767px) {
  body.edu-shell-active main {
    left: 0;
    top: var(--edu-header-h);
    bottom: 0;
  }
  body.edu-shell-active .edu-rail {
    transform: translateX(-100%);
    transition: transform 0.22s var(--edu-tx);
    box-shadow: var(--edu-shadow-lg);
    z-index: 110;
    width: 75vw; max-width: 280px;
  }
  body.edu-shell-active.edu-rail-open .edu-rail {
    transform: translateX(0);
  }
  body.edu-shell-active.edu-rail-open::before {
    content: ''; position: fixed; inset: 0;
    background: rgba(15,23,42,0.4);
    z-index: 105; cursor: pointer;
  }
  body.edu-shell-active .edu-rail-label {
    opacity: 1 !important; max-width: none !important;
  }
  body.edu-shell-active .edu-rail-item {
    padding: 12px 14px !important; gap: 14px !important;
    min-height: 44px;
  }
  /* Mobile'da touch target 44px */
}

/* ═══════════════════════════════════════════════════════════════
   SPRINT 1 — Critical fixes
   ═══════════════════════════════════════════════════════════════ */

/* Unified empty state */
.edu-empty {
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  padding: 80px 20px 60px;
  max-width: 440px; margin: 0 auto;
}
.edu-empty-icon {
  width: 72px; height: 72px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(15,23,42,0.04);
  border-radius: 50%;
  margin-bottom: 18px;
  color: var(--edu-text-mute);
}
.edu-empty-icon svg { width: 36px; height: 36px; }
.dark-mode .edu-empty-icon { background: rgba(255,255,255,0.06); }
.edu-empty-title {
  font-size: 18px; font-weight: 800;
  color: var(--edu-text);
  margin-bottom: 8px;
  letter-spacing: -0.2px;
}
.edu-empty-desc {
  font-size: 13.5px; color: var(--edu-text-mute);
  line-height: 1.5;
}

/* Loading skeleton */
.edu-skeleton {
  background: linear-gradient(90deg, rgba(15,23,42,0.05) 25%, rgba(15,23,42,0.08) 50%, rgba(15,23,42,0.05) 75%);
  background-size: 200% 100%;
  animation: edu-skeleton-shimmer 1.4s infinite linear;
  border-radius: 6px;
}
@keyframes edu-skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.edu-skeleton-row { height: 14px; margin: 6px 0; }
.edu-skeleton-card {
  height: 80px; margin: 8px 0;
  border-radius: 12px;
}

/* ⌘K Search Palette */
.edu-search-palette {
  position: fixed; inset: 0;
  z-index: 200;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh;
}
.edu-search-bd {
  position: absolute; inset: 0;
  background: rgba(15,23,42,0.45);
  backdrop-filter: blur(6px);
}
.edu-search-box {
  position: relative;
  width: 100%; max-width: 520px;
  background: var(--edu-surface);
  border-radius: 14px;
  box-shadow: var(--edu-shadow-lg);
  overflow: hidden;
  margin: 0 16px;
}
.edu-search-input-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--edu-border);
}
.edu-search-icon { color: var(--edu-text-mute); display: flex; }
.edu-search-input-wrap input {
  flex: 1; min-width: 0;
  background: transparent; border: 0; outline: none;
  font-size: 15px; font-family: inherit;
  color: var(--edu-text);
}
.edu-search-kbd {
  font-size: 10px; font-weight: 700; letter-spacing: 0.4px;
  padding: 3px 6px;
  background: rgba(15,23,42,0.06); color: var(--edu-text-mute);
  border-radius: 4px;
}
.dark-mode .edu-search-kbd { background: rgba(255,255,255,0.08); }
.edu-search-list { max-height: 50vh; overflow-y: auto; padding: 6px; }
.edu-search-row {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13.5px; font-weight: 600;
  color: var(--edu-text);
  cursor: pointer;
}
.edu-search-row:hover, .edu-search-row.is-active {
  background: rgba(15,23,42,0.06);
}
.dark-mode .edu-search-row:hover, .dark-mode .edu-search-row.is-active {
  background: rgba(255,255,255,0.06);
}
.edu-search-empty {
  padding: 24px 12px; text-align: center;
  color: var(--edu-text-mute); font-size: 13px;
}

/* Anasayfa Hub — büyük kartlar */
body.edu-shell-active .edu-hub {
  max-width: 980px;
  margin: 20px auto;
  padding: 8px 12px 40px;
}
.edu-hub-head { padding: 8px 4px 18px; }
.edu-hub-h1 {
  font-size: 26px; font-weight: 800;
  color: var(--edu-text);
  letter-spacing: -0.4px;
  margin: 0 0 6px;
}
.edu-hub-sub {
  font-size: 14px; color: var(--edu-text-mute);
  line-height: 1.5;
}
.edu-hub-kbd {
  display: inline-block;
  padding: 1px 7px;
  background: rgba(15,23,42,0.06);
  color: var(--edu-text);
  border-radius: 5px;
  font-size: 11.5px; font-weight: 700;
  font-family: ui-monospace, SF Mono, Menlo, monospace;
}
.dark-mode .edu-hub-kbd { background: rgba(255,255,255,0.08); }
.edu-hub-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 700px) { .edu-hub-grid { grid-template-columns: 1fr 1fr; gap: 12px; } }
@media (min-width: 1100px) { .edu-hub-grid { grid-template-columns: 1fr 1fr 1fr; gap: 14px; } }
.edu-hub-tile {
  display: flex; align-items: center; gap: 14px;
  background: var(--edu-surface);
  border: 1px solid var(--edu-border);
  border-radius: var(--edu-radius-lg);
  padding: 18px 18px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: transform 0.14s, box-shadow 0.14s, border-color 0.14s;
  box-shadow: var(--edu-shadow-sm);
}
.edu-hub-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--edu-shadow);
  border-color: rgba(15,23,42,0.14);
}
.dark-mode .edu-hub-tile:hover { border-color: rgba(255,255,255,0.16); }
.edu-hub-tile-ico {
  flex-shrink: 0;
  width: 42px; height: 42px;
  background: rgba(15,23,42,0.04);
  border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
}
.edu-hub-tile-ico svg { width: 24px; height: 24px; }
.dark-mode .edu-hub-tile-ico { background: rgba(255,255,255,0.06); }
.edu-hub-tile-body { flex: 1; min-width: 0; }
.edu-hub-tile-label {
  font-size: 15.5px; font-weight: 800;
  color: var(--edu-text);
  margin-bottom: 2px;
  letter-spacing: -0.1px;
}
.edu-hub-tile-desc {
  font-size: 12.5px; color: var(--edu-text-mute);
  line-height: 1.4;
}
.edu-hub-tile-arrow {
  font-size: 22px; color: var(--edu-text-soft);
  flex-shrink: 0;
  transition: transform 0.14s;
}
.edu-hub-tile:hover .edu-hub-tile-arrow {
  transform: translateX(2px);
  color: var(--edu-text-mute);
}

/* Mobile bottom nav shell aktifken gizle */
body.edu-shell-active > .fl-bottom-nav,
body.edu-shell-active #fl-bottom-nav,
body.edu-shell-active .fl-bottom-nav {
  display: none !important;
}
/* Mobile'da rail drawer açıkken bottom nav gizli kalır */

/* FAB butonunu shell aktifken gizle (header'da yeni search butonu var) */
body.edu-shell-active #fab-btn,
body.edu-shell-active .tw-fab,
body.edu-shell-active #fab-menu {
  display: none !important;
}

/* Toast: header altında konumlandır */
body.edu-shell-active #app-toast-host,
body.edu-shell-active [class*="toast-host"] {
  top: calc(var(--edu-header-h) + 12px) !important;
}

/* Bottom sheet — shell aktifken main alanı içinde gerçekleşir */
body.edu-shell-active #bottom-sheet {
  z-index: 150;
}

/* Eski position:fixed sticky bottom elementlerin offset'i */
body.edu-shell-active .tw-fab-menu {
  display: none !important;
}

/* Backdrop (auth, bottom-sheet) full kalır — shell rail önde değil */
body.edu-shell-active .bottom-sheet,
body.edu-shell-active .modal-backdrop {
  z-index: 9500;
}

/* tb-perm-bar (chat sticky bottom) main içinde absolute */
body.edu-shell-active .tb-perm-bar {
  z-index: 60;
}

/* Modal'lar: backdrop full viewport (doğru), iç içerik rail-aware ortalansın */
@media (min-width: 1024px) {
  body.edu-shell-active .app-modal-backdrop {
    /* Backdrop full kalır; içerik centered olduğu için zaten merkezleniyor */
    padding-left: var(--edu-rail-w);
  }
  body.edu-shell-active.edu-rail-collapsed .app-modal-backdrop {
    padding-left: var(--edu-rail-w-col);
  }
}

/* Auth screen — shell aktifken görünmesin, login pop-up'ı modal olarak gelir */
body.edu-shell-active > .auth-screen,
body.edu-shell-active > .fl-auth-page {
  z-index: 200; /* shell üstüne */
}

/* Global modal positioning — backdrop full ama içerik shell rail-aware */
body.edu-shell-active [class*="-modal-bg"],
body.edu-shell-active [class*="modal-backdrop"] {
  z-index: 9500;
}
@media (min-width: 1024px) {
  body.edu-shell-active [class*="-modal-bg"]:not(.no-rail-offset),
  body.edu-shell-active [class*="modal-backdrop"]:not(.no-rail-offset) {
    /* Backdrop full kalır — modaller centered olduğu için rail offset gerekmez */
  }
}

/* Eski html.edu-mode-on davranışı shell aktifken bypass et */
html.edu-mode-on body.edu-shell-active .fl-bottom-nav { display: none !important; }

/* Sticky tb-pill header'ları shell aktifken doğru top'a otursun */
body.edu-shell-active main .tb-pill {
  top: 0;
  z-index: 5;
}

/* Reels takeover — shell rail görünür kalır ama main full uses */
body.edu-shell-active .br-active,
body.edu-shell-active .br-ground {
  /* Spot reader / Reels full-screen modu — rail dışı, takeover */
  left: var(--edu-rail-w) !important;
  top: var(--edu-header-h) !important;
}
@media (max-width: 767px) {
  body.edu-shell-active .br-active,
  body.edu-shell-active .br-ground {
    left: 0 !important;
  }
}
body.edu-shell-active.edu-rail-collapsed .br-active,
body.edu-shell-active.edu-rail-collapsed .br-ground {
  left: var(--edu-rail-w-col) !important;
}

/* ─── Mevcut .app-shell artık gerek yok — shell zaten kapsıyor ── */
body.edu-shell-active .app-shell {
  grid-template-columns: 1fr !important;
  padding: 0 !important;
  gap: 0 !important;
}
body.edu-shell-active .app-shell > .app-side {
  display: none !important;
}
body.edu-shell-active .app-shell .app-main {
  max-width: none !important;
}

/* ─── Headers / pills internal — mevcut stil korunur ──────────── */
body.edu-shell-active .tb-pill {
  position: sticky;
  top: 0;
  z-index: 5;
}

/* ─── Mevcut coach chat shell (tb-chat-shell) yine kendi 3-col'unu kullanır ── */
@media (min-width: 1024px) {
  body.edu-shell-active main .tb-chat-shell {
    /* shell zaten left rail veriyor; chat'in kendi sol nav'ı bunun yanına */
  }
}
