:root {
  /* Nötr açık gri tema: siyah ile beyaz arası, sunumlar için yüksek okunabilirlik */
  --bg-main: #e9edf2;
  --bg-surface: #ffffff;
  --bg-soft: #f4f6f9;
  --bg-hover: #eef1f6;
  --border: #d5dbe3;
  --border-strong: #c3cbd6;

  --primary: #4f46e5;
  --primary-soft: rgba(79, 70, 229, 0.10);
  --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #0891b2 100%);
  --accent: #0891b2;
  --success: #059669;
  --danger: #dc2626;

  --text-main: #1e293b;
  --text-muted: #475569;
  --text-dim: #64748b;

  --sidebar-w: 340px;
  --header-h: 64px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
  --transition: all 0.2s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.bg-orb { display: none; }

/* ---------- Header ---------- */
.portal-header {
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  z-index: 50;
  flex-shrink: 0;
  gap: 12px;
}

.brand-group { display: flex; align-items: center; gap: 12px; min-width: 0; }

.mobile-toggle-btn {
  display: none;
  align-items: center;
  gap: 6px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 7px 11px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.brand-icon {
  width: 38px; height: 38px;
  background: var(--primary-gradient);
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
}

.brand-text { min-width: 0; }
.brand-text h1 {
  font-size: 1.08rem; font-weight: 700; letter-spacing: -0.3px; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-text span { font-size: 0.74rem; color: var(--text-dim); font-weight: 500; }

.header-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.progress-summary {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-soft);
  padding: 6px 12px;
  border-radius: 30px;
  border: 1px solid var(--border);
}
.progress-track { width: 90px; height: 6px; background: #dde3ea; border-radius: 6px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--primary-gradient); border-radius: 6px; transition: width .4s ease; width: 0%; }
.progress-text { font-size: 0.8rem; font-weight: 700; color: var(--primary); }

.user-badge {
  display: flex; align-items: center; gap: 7px;
  font-size: 0.85rem; font-weight: 600;
  background: var(--bg-soft);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.btn-logout {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
  padding: 6px 14px;
  border-radius: 9px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
}
.btn-logout:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

/* ---------- Layout ---------- */
.app-container { display: flex; flex: 1; overflow: hidden; position: relative; min-height: 0; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  flex-shrink: 0;
  z-index: 40;
  transition: transform .3s cubic-bezier(.16, 1, .3, 1);
}

.sidebar-header { padding: 14px; border-bottom: 1px solid var(--border); }
.sidebar-header-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sidebar-title { font-size: 0.92rem; font-weight: 700; }

.btn-close-sidebar {
  display: none;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 30px; height: 30px;
  border-radius: 8px;
  cursor: pointer;
}

.search-input-wrap { position: relative; display: flex; align-items: center; }
.search-input-wrap .search-icon { position: absolute; left: 12px; font-size: .85rem; pointer-events: none; opacity: .55; }
.search-input-wrap input {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px 9px 34px;
  color: var(--text-main);
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}
.search-input-wrap input:focus { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.chapters-list {
  flex: 1; overflow-y: auto; padding: 10px;
  display: flex; flex-direction: column; gap: 6px;
  -webkit-overflow-scrolling: touch;
}

.chapter-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}
.chapter-item:hover { background: var(--bg-hover); border-color: var(--border); }
.chapter-item.active { background: var(--primary-soft); border-color: rgba(79, 70, 229, 0.35); }

.ch-number {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.chapter-item.active .ch-number { background: var(--primary); border-color: var(--primary); color: #fff; }
.chapter-item.completed .ch-number { border-color: var(--success); color: var(--success); }
.chapter-item.active.completed .ch-number { color: #fff; }

.ch-info { flex: 1; min-width: 0; }
.ch-title { font-size: .9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chapter-item.active .ch-title { color: var(--primary); }
.ch-sub { font-size: .75rem; color: var(--text-dim); margin-top: 2px; }

.ch-check { font-size: 1rem; color: #b6bfcb; font-weight: 700; }
.chapter-item.completed .ch-check { color: var(--success); }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 90;
}
.sidebar-overlay.active { display: block; }

/* ---------- Content ---------- */
.content-area {
  flex: 1;
  display: flex; flex-direction: column;
  background: var(--bg-main);
  position: relative;
  overflow: hidden;
  min-width: 0;
}

.viewer-topbar {
  min-height: 56px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px;
  flex-shrink: 0;
  gap: 10px;
}

.viewer-title-group { display: flex; align-items: center; gap: 10px; min-width: 0; overflow: hidden; }

.mobile-open-drawer {
  display: none;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 6px 11px;
  border-radius: 8px;
  font-size: .8rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  font-family: inherit;
}

.viewer-ch-badge {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid rgba(79, 70, 229, 0.25);
  padding: 3px 10px;
  border-radius: 12px;
  font-size: .75rem; font-weight: 700;
  white-space: nowrap; flex-shrink: 0;
}

.viewer-title { font-size: .95rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.viewer-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.btn-complete {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px;
  border-radius: 8px;
  font-size: .8rem; font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  font-family: inherit;
  background: #ecfdf5; color: var(--success); border: 1px solid #a7f3d0;
}
.btn-complete:hover { background: #d1fae5; }
.btn-complete.active { background: var(--success); color: #fff; border-color: var(--success); }

.nav-btn-group { display: flex; gap: 4px; }

.btn-icon {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text-main);
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem;
  cursor: pointer;
  transition: var(--transition);
}
.btn-icon:hover { background: var(--bg-hover); border-color: var(--border-strong); }

/* ---------- Presentation viewer ---------- */
.viewer-container {
  flex: 1;
  position: relative;
  display: flex; flex-direction: column;
  overflow: hidden;
  min-height: 0;
  background-color: #ffffff;
}

.viewer-iframe { width: 100%; height: 100%; border: none; background: transparent; display: block; flex: 1; }

.viewer-loading {
  position: absolute; inset: 0;
  background: rgba(244, 246, 249, 0.95);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px;
  z-index: 10;
  transition: opacity .3s;
}

.spinner {
  width: 34px; height: 34px;
  border: 3px solid #dde3ea;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Mobile bottom bar ---------- */
.mobile-bottom-bar {
  display: none;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  align-items: center; justify-content: space-between;
  gap: 8px;
  z-index: 30;
  flex-shrink: 0;
}
.btn-mobile-nav {
  flex: 1;
  padding: 11px 6px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 9px;
  font-size: .85rem; font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn-mobile-nav.center { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- Responsive ---------- */
@media (max-width: 920px) {
  .mobile-toggle-btn { display: none; }
  .mobile-open-drawer { display: inline-flex; }
  .progress-summary { display: none; }

  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0;
    width: min(86vw, 340px);
    z-index: 100;
    transform: translateX(-100%);
    box-shadow: 10px 0 40px rgba(15, 23, 42, 0.25);
  }
  .sidebar.open { transform: translateX(0); }
  .btn-close-sidebar { display: inline-block; }
  .mobile-bottom-bar { display: flex; }
}

@media (max-width: 600px) {
  .portal-header { padding: 0 12px; }
  .brand-icon { width: 34px; height: 34px; font-size: 17px; }
  .brand-text h1 { font-size: .95rem; }
  .brand-text span, .badge-name, .user-badge { display: none; }
  .btn-logout { padding: 5px 10px; font-size: .78rem; }

  .viewer-topbar { padding: 6px 10px; }
  .viewer-ch-badge { display: none; }
  .viewer-title { font-size: .88rem; }
  .btn-complete span:last-child { display: none; }
  .btn-complete { padding: 6px 8px; }
  .nav-btn-group { display: none; }
}
