/* ════════════════════════════════════════════════════════════════════
   EDU Shell — Fixes & Polish (Sprints 1, 2, 5, 7)
   Overflow, dark mode, polish, animations
   ════════════════════════════════════════════════════════════════════ */

/* ─── Sprint 1: Layout/Taşma fixes (1-20) ─────────────────────────── */

/* #1 tb-page max-width — modül-bazlı override */
@media (min-width: 1600px) {
  body.edu-shell-active main .tb-grid {
    grid-template-columns: repeat(4, 1fr) !important;
  }
}
@media (min-width: 2000px) {
  body.edu-shell-active main .tb-page { max-width: 1600px; }
}

/* #2 Modal mobile rotate safe — max-height + scroll */
body.edu-shell-active .app-modal-backdrop > *,
body.edu-shell-active [class*="-modal-bg"] > * {
  max-height: 90vh; overflow-y: auto;
}
@media (max-width: 480px) {
  body.edu-shell-active [class*="-modal-bg"] > * { max-width: 95vw; }
}

/* #3 Toast multi-stack support */
#app-toast-host > .toast {
  margin-bottom: 8px;
  max-width: 360px;
  animation: edu-toast-in 0.22s var(--edu-tx);
}
@keyframes edu-toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* #4 Sidebar item — 2 satır + ellipsis */
.app-side-subj-name,
.tb-side-item-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal !important;
  word-break: break-word;
}

/* #5 Right aside scroll */
body.edu-shell-active .tb-chat-aside-right {
  max-height: calc(100vh - var(--edu-header-h));
  overflow-y: auto;
}

/* #6 Pearl text — hover full tooltip via title attribute (zaten var) */
.tb-aside-pearl {
  cursor: help;
}

/* #7 Chat bubbles — uzun mesajlar */
.tb-msg-bubble,
.tb-msg-ai-text {
  max-width: 100%;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* #8 Permanent bar — <320px scaling */
@media (max-width: 380px) {
  .tb-perm-bar { padding: 6px 8px; }
  .tb-perm-emoji { font-size: 18px; }
  .tb-perm-label { font-size: 8.5px; }
}

/* #9 Spot reader content scroll */
.spot-reader-content,
.tb-spot-content {
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding-right: 8px;
}

/* #10 Konsept tree depth */
.tb-concept-row { padding-left: calc(var(--depth, 0) * 16px); }

/* #11 Soru kartı — collapsed answer */
.tb-question-detail.is-collapsed .tb-question-explanation { display: none; }

/* #12 FAB tamamen unmount */
body.edu-shell-active #fab-btn,
body.edu-shell-active #fab-menu,
body.edu-shell-active .tw-fab,
body.edu-shell-active .tw-fab-menu {
  display: none !important;
  pointer-events: none !important;
}

/* #13 Search palette focus trap */
.edu-search-palette { isolation: isolate; }
.edu-search-box input:focus { outline: 2px solid var(--edu-accent); outline-offset: -2px; }

/* #14 Safari backdrop fallback */
@supports not (backdrop-filter: blur(6px)) {
  .edu-search-bd,
  [class*="modal-bg"],
  .app-modal-backdrop {
    background: rgba(15,23,42,0.7) !important;
  }
}

/* #15 Scroll restoration */
body.edu-shell-active main {
  scroll-behavior: smooth;
}

/* #16 iOS safe area */
@supports (padding: env(safe-area-inset-bottom)) {
  body.edu-shell-active main {
    padding-bottom: env(safe-area-inset-bottom);
  }
  body.edu-shell-active .tb-chat-input-area {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}

/* #17 Sticky tb-pill — z-index ve top hesap */
body.edu-shell-active main .tb-pill {
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(8px);
}

/* #18 Image overflow global */
body.edu-shell-active main img,
body.edu-shell-active main video,
body.edu-shell-active main iframe {
  max-width: 100%;
  height: auto;
}

/* #19 Table overflow wrapper */
body.edu-shell-active main table {
  display: block;
  overflow-x: auto;
  max-width: 100%;
  border-collapse: collapse;
}

/* #20 iframe aspect ratio */
body.edu-shell-active main .video-embed,
body.edu-shell-active main .iframe-wrap {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
}
body.edu-shell-active main .video-embed iframe,
body.edu-shell-active main .iframe-wrap iframe {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
}

/* ════════════════════════════════════════════════════════════════════
   Sprint 2: Dark/Light Mode (56-70)
   ════════════════════════════════════════════════════════════════════ */

/* #56-57 — CSS vars ve currentColor zaten edu-shell-v2.css'te. Burada legacy override */
body.dark-mode {
  /* Eski modüllerin hardcoded color'larını force etmek için */
  color-scheme: dark;
}
body:not(.dark-mode) { color-scheme: light; }

/* #58-59 System theme listener — JS tarafında, burada CSS bahsetmiyorum */

/* #60 Image dark filter */
body.edu-shell-active.dark-mode main img:not([src*=".svg"]):not(.no-dark-filter) {
  filter: brightness(0.9) contrast(0.95);
}

/* #61 Code block themes */
body.dark-mode pre, body.dark-mode code {
  background: #1A2332;
  color: #E5E7EB;
}
body:not(.dark-mode) pre, body:not(.dark-mode) code {
  background: #F8FAFC;
  color: #1F2937;
}
pre, code {
  border-radius: 6px;
  padding: 2px 6px;
  font-family: ui-monospace, SF Mono, monospace;
  font-size: 0.92em;
}
pre { padding: 12px 16px; overflow-x: auto; }

/* #62 Border opacity dark */
body.dark-mode {
  --edu-border:       rgba(255, 255, 255, 0.12);
  --edu-border-soft:  rgba(255, 255, 255, 0.06);
}

/* #63 Shadow values dark */
body.dark-mode {
  --edu-shadow-sm:    0 1px 3px rgba(0,0,0,0.3);
  --edu-shadow:       0 4px 14px -2px rgba(0,0,0,0.4);
  --edu-shadow-lg:    0 12px 32px -8px rgba(0,0,0,0.5);
}

/* #64 Focus ring */
body:not(.dark-mode) button:focus-visible,
body:not(.dark-mode) input:focus-visible,
body:not(.dark-mode) textarea:focus-visible {
  outline: 2px solid #3B82F6;
  outline-offset: 2px;
}
body.dark-mode button:focus-visible,
body.dark-mode input:focus-visible,
body.dark-mode textarea:focus-visible {
  outline: 2px solid #60A5FA;
  outline-offset: 2px;
}

/* #65 Selection color */
body:not(.dark-mode) ::selection { background: rgba(99, 102, 241, 0.25); color: inherit; }
body.dark-mode ::selection { background: rgba(99, 102, 241, 0.45); color: #fff; }

/* #66 Custom scrollbar */
body.edu-shell-active *::-webkit-scrollbar { width: 8px; height: 8px; }
body.edu-shell-active *::-webkit-scrollbar-track { background: transparent; }
body.edu-shell-active *::-webkit-scrollbar-thumb {
  background: rgba(15,23,42,0.18);
  border-radius: 4px;
}
body.edu-shell-active *::-webkit-scrollbar-thumb:hover {
  background: rgba(15,23,42,0.28);
}
body.dark-mode.edu-shell-active *::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
}
body.dark-mode.edu-shell-active *::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.25);
}

/* #67 Pearl pill dark — daha okunabilir amber */
body.dark-mode .tb-msg-ai-pearl-pill {
  background: linear-gradient(135deg, rgba(245,158,11,0.20), rgba(217,119,6,0.10));
  border: 1px solid rgba(245,158,11,0.40);
  color: #FDE68A;
  box-shadow: 0 2px 8px -2px rgba(0,0,0,0.4);
}

/* #68 Yield badge dark mode */
body.dark-mode .tb-msg-ai-yield[data-y="high"]   { background: rgba(239,68,68,0.20);  color: #FCA5A5; }
body.dark-mode .tb-msg-ai-yield[data-y="medium"] { background: rgba(245,158,11,0.20); color: #FCD34D; }
body.dark-mode .tb-msg-ai-yield[data-y="low"]    { background: rgba(99,102,241,0.20); color: #A5B4FC; }

/* #69 Toast dark */
body.dark-mode #app-toast-host .toast,
body.dark-mode [class*="toast"] {
  background: rgba(30,41,59,0.95);
  color: #F1F5F9;
  backdrop-filter: blur(8px);
}

/* #70 Modal backdrop dark daha yoğun */
body.dark-mode .edu-search-bd,
body.dark-mode .app-modal-backdrop {
  background: rgba(0,0,0,0.65);
}

/* ════════════════════════════════════════════════════════════════════
   Sprint 7: UX Polish (86-95)
   ════════════════════════════════════════════════════════════════════ */

/* #91 Tooltip delay (CSS-only impossible — use title attribute timing in JS or hover delay) */
[title]:hover { /* native browser tooltip has built-in delay */ }

/* #88 Undo notification toast — special styling */
.toast.toast--undo {
  background: rgba(15,23,42,0.95);
  color: #fff;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
}
.toast--undo button {
  background: transparent; color: #FCD34D;
  border: 0; font-weight: 700; cursor: pointer;
  padding: 4px 8px; border-radius: 4px;
}
.toast--undo button:hover { background: rgba(255,255,255,0.1); }

/* #94 Achievement toast — confetti placeholder */
.toast.toast--achievement {
  background: linear-gradient(135deg, #8B5CF6, #6366F1);
  color: #fff;
  font-weight: 700;
  padding: 14px 18px;
  border-radius: 14px;
  box-shadow: 0 10px 30px -10px rgba(139,92,246,0.5);
}

/* ════════════════════════════════════════════════════════════════════
   Sprint 4: Article Reader (21-35)
   ════════════════════════════════════════════════════════════════════ */

.edu-reader {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 24px 80px;
  font-family: Charter, "Source Serif", Georgia, serif;
  font-size: 18px;
  line-height: 1.7;
  color: var(--edu-text);
}
.edu-reader h1 {
  font-size: 32px; font-weight: 800;
  margin: 0 0 8px;
  letter-spacing: -0.5px;
  line-height: 1.2;
}
.edu-reader-meta {
  display: flex; gap: 12px;
  color: var(--edu-text-mute);
  font-size: 13px;
  margin-bottom: 28px;
  font-family: -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}
.edu-reader-progress {
  position: fixed; top: var(--edu-header-h); left: 0; right: 0;
  height: 3px; background: rgba(15,23,42,0.05);
  z-index: 80;
}
.edu-reader-progress-bar {
  height: 100%; width: 0;
  background: var(--edu-accent);
  transition: width 0.1s linear;
}
.edu-reader p { margin: 0 0 18px; }
.edu-reader h2 { font-size: 24px; font-weight: 700; margin: 36px 0 14px; }
.edu-reader h3 { font-size: 19px; font-weight: 700; margin: 28px 0 10px; }
.edu-reader blockquote {
  border-left: 3px solid var(--edu-accent);
  padding: 4px 18px;
  color: var(--edu-text-mute);
  font-style: italic;
  margin: 20px 0;
}
.edu-reader ul, .edu-reader ol { padding-left: 24px; margin: 0 0 18px; }
.edu-reader li { margin-bottom: 6px; }

/* #34 Font size toggle */
.edu-reader.is-size-sm { font-size: 16px; }
.edu-reader.is-size-md { font-size: 18px; }
.edu-reader.is-size-lg { font-size: 21px; }

/* #33 Reading themes */
.edu-reader.is-theme-sepia {
  background: #F4ECD8;
  color: #5B4636;
}
body.dark-mode .edu-reader { color: var(--edu-text); }

/* #35 Reader actions toolbar */
.edu-reader-actions {
  display: flex; gap: 6px;
  position: sticky; top: calc(var(--edu-header-h) + 4px);
  background: var(--edu-surface);
  padding: 10px 0;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--edu-border);
  z-index: 6;
}
.edu-reader-act {
  background: transparent; border: 1px solid var(--edu-border);
  padding: 5px 11px; border-radius: 6px;
  font-size: 12.5px; font-weight: 600;
  color: var(--edu-text-mute);
  cursor: pointer;
  font-family: inherit;
}
.edu-reader-act:hover { color: var(--edu-text); border-color: rgba(15,23,42,0.2); }
.edu-reader-act.is-active { background: var(--edu-text); color: var(--edu-surface); border-color: var(--edu-text); }

/* ════════════════════════════════════════════════════════════════════
   Sprint 3: Anasayfa Akış (46-55)
   ════════════════════════════════════════════════════════════════════ */

.edu-feed {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px;
}
@media (min-width: 900px) {
  .edu-feed { grid-template-columns: 2fr 1fr; }
}

.edu-continue-card {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, var(--edu-accent), var(--edu-accent-2));
  color: #fff;
  border-radius: 14px;
  padding: 18px 22px;
  display: flex; align-items: center; gap: 16px;
  cursor: pointer;
  transition: transform 0.14s;
}
.edu-continue-card:hover { transform: translateY(-2px); }
.edu-continue-card-icon { font-size: 28px; }
.edu-continue-card-body { flex: 1; }
.edu-continue-card-label { font-size: 11px; font-weight: 800; letter-spacing: 0.5px; opacity: 0.85; text-transform: uppercase; }
.edu-continue-card-title { font-size: 16px; font-weight: 700; margin-top: 3px; }
.edu-continue-card-arrow { font-size: 22px; opacity: 0.7; }

/* #48 Daily goal ring */
.edu-goal-ring {
  display: flex; align-items: center; gap: 14px;
  background: var(--edu-surface);
  border: 1px solid var(--edu-border);
  border-radius: 14px;
  padding: 14px 16px;
}
.edu-goal-ring-svg { width: 56px; height: 56px; flex-shrink: 0; }
.edu-goal-ring-body { flex: 1; }
.edu-goal-ring-label { font-size: 11px; font-weight: 800; letter-spacing: 0.4px; color: var(--edu-text-mute); text-transform: uppercase; }
.edu-goal-ring-val { font-size: 22px; font-weight: 800; color: var(--edu-text); line-height: 1.1; margin-top: 2px; }

/* #49 Streak */
.edu-streak {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, #FEF3C7, #FED7AA);
  border: 1px solid rgba(217,119,6,0.2);
  border-radius: 14px;
  padding: 14px 16px;
}
.edu-streak-icon { font-size: 28px; }
.edu-streak-body { flex: 1; }
.edu-streak-num { font-size: 22px; font-weight: 800; color: #92400E; line-height: 1.1; }
.edu-streak-label { font-size: 11px; font-weight: 700; color: #B45309; }
body.dark-mode .edu-streak {
  background: linear-gradient(135deg, rgba(245,158,11,0.15), rgba(217,119,6,0.08));
  border-color: rgba(245,158,11,0.3);
}
body.dark-mode .edu-streak-num { color: #FCD34D; }
body.dark-mode .edu-streak-label { color: #FCD34D; }

/* Feed item card */
.edu-feed-item {
  background: var(--edu-surface);
  border: 1px solid var(--edu-border);
  border-radius: 12px;
  padding: 16px 18px;
  cursor: pointer;
  transition: transform 0.14s, box-shadow 0.14s;
}
.edu-feed-item:hover { transform: translateY(-1px); box-shadow: var(--edu-shadow); }
.edu-feed-item-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 10.5px; font-weight: 800; letter-spacing: 0.4px;
  color: var(--edu-text-mute);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.edu-feed-item-title { font-size: 15px; font-weight: 700; color: var(--edu-text); line-height: 1.4; }
.edu-feed-item-meta { font-size: 12px; color: var(--edu-text-mute); margin-top: 6px; }

/* ════════════════════════════════════════════════════════════════════
   Sprint 6: Profile / Settings (71-72)
   ════════════════════════════════════════════════════════════════════ */

.edu-profile,
.edu-settings {
  max-width: 760px;
  margin: 20px auto;
  padding: 24px;
}
.edu-profile-head {
  display: flex; align-items: center; gap: 16px;
  background: var(--edu-surface);
  border: 1px solid var(--edu-border);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 16px;
}
.edu-profile-avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--edu-accent), var(--edu-accent-2));
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 800;
}
.edu-profile-info { flex: 1; }
.edu-profile-name { font-size: 18px; font-weight: 800; color: var(--edu-text); }
.edu-profile-email { font-size: 13px; color: var(--edu-text-mute); margin-top: 2px; }

.edu-profile-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 16px;
}
@media (min-width: 600px) { .edu-profile-stats { grid-template-columns: repeat(4, 1fr); } }
.edu-profile-stat {
  background: var(--edu-surface);
  border: 1px solid var(--edu-border);
  border-radius: 12px;
  padding: 14px 12px;
  text-align: center;
}
.edu-profile-stat-num { font-size: 22px; font-weight: 800; color: var(--edu-text); line-height: 1.1; }
.edu-profile-stat-label { font-size: 11px; font-weight: 700; color: var(--edu-text-mute); margin-top: 4px; letter-spacing: 0.2px; text-transform: uppercase; }

/* Settings list */
.edu-settings-section {
  background: var(--edu-surface);
  border: 1px solid var(--edu-border);
  border-radius: 14px;
  padding: 8px 4px;
  margin-bottom: 14px;
}
.edu-settings-section-head {
  font-size: 10.5px; font-weight: 800; letter-spacing: 0.5px;
  color: var(--edu-text-mute); text-transform: uppercase;
  padding: 10px 14px 6px;
}
.edu-settings-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  border-radius: 9px;
  margin: 0 4px;
}
.edu-settings-row:hover { background: rgba(15,23,42,0.04); }
.edu-settings-row-icon { font-size: 18px; }
.edu-settings-row-label { flex: 1; font-size: 14px; font-weight: 600; color: var(--edu-text); }
.edu-settings-row-val { font-size: 12.5px; color: var(--edu-text-mute); }
.edu-settings-row-arrow { font-size: 18px; color: var(--edu-text-soft); }
