/* ===== HEADER ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(7, 9, 26, 0.7);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1500px;
  margin: 0 auto;
  padding: 0 32px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.logo { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.logo-icon {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-blue);
  line-height: 1;
  filter: drop-shadow(0 0 10px rgba(96,151,255,0.5));
}
.logo-text { display: flex; flex-direction: column; }
.logo-title { font-size: 14px; font-weight: 700; color: var(--text-primary); letter-spacing: 0.02em; }
.logo-sub   { font-size: 10px; color: var(--text-muted); letter-spacing: 0.04em; }

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

/* ===== MODE TABS ===== */
.mode-tabs-wrapper {
  background: rgba(7, 9, 26, 0.5);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.mode-tabs {
  max-width: 1500px;
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
}
.mode-tab {
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-sans);
  white-space: nowrap;
}
.mode-tab:hover  { color: var(--text-secondary); }
.mode-tab.active { color: var(--accent-blue); border-bottom-color: var(--accent-blue); }

/* ===== CONTROL PANEL ===== */
.control-panel {
  background: rgba(7, 9, 26, 0.5);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 64px;
  z-index: 90;
}
.control-panel-inner {
  max-width: 1500px;
  margin: 0 auto;
  padding: 10px 28px;
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}
.control-group { display: flex; flex-direction: column; gap: 5px; }
.control-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ===== EXAM NAV ===== */
.exam-nav {
  background: rgba(7, 9, 26, 0.5);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 110px;
  z-index: 85;
}
.exam-nav-inner {
  max-width: 1500px;
  margin: 0 auto;
  padding: 8px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.exam-nav-pills { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.exam-nav-score { font-size: 13px; font-weight: 600; color: var(--text-secondary); white-space: nowrap; }

/* ===== MAIN LAYOUT ===== */
.main-layout {
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px 28px;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}

/* ===== TASK SECTION ===== */
.task-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: calc(100vh - 200px);
}

/* ===== PROGRESS SIDEBAR ===== */
.progress-sidebar {
  background: rgba(255,255,255,0.03);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: sticky;
  top: 120px;
}

.sb-header {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
}
.sb-stat-row { display: flex; align-items: center; }
.sb-stat { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.sb-stat-divider { width: 1px; height: 28px; background: var(--border); flex-shrink: 0; }
.sb-stat-val { font-size: 20px; font-weight: 700; color: var(--text-primary); line-height: 1; }
.sb-stat-streak { font-size: 16px; }
.sb-stat-lbl { font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; text-align: center; }
.sb-accuracy-bar-wrap { margin-top: 10px; height: 3px; background: rgba(255,255,255,0.06); border-radius: 99px; overflow: hidden; }
.sb-accuracy-bar { height: 100%; background: var(--accent-green); border-radius: 99px; transition: width 0.5s ease; }
.sb-accuracy-label { margin-top: 4px; font-size: 10px; color: var(--accent-green); text-align: right; }

.sb-cats-label { padding: 12px 16px 5px; font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.sb-cats { display: flex; flex-direction: column; padding: 0 16px 12px; gap: 7px; }
.sb-cat { display: flex; align-items: center; gap: 8px; }
.sb-cat-left { display: flex; align-items: center; gap: 6px; flex: 0 0 165px; min-width: 0; }
.sb-cat-icon { font-size: 12px; line-height: 1; flex-shrink: 0; width: 15px; text-align: center; }
.sb-cat-name { font-size: 11px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-cat-right { flex: 1; display: flex; align-items: center; gap: 6px; min-width: 0; }
.sb-bar-track { flex: 1; height: 4px; background: rgba(255,255,255,0.06); border-radius: 99px; overflow: hidden; min-width: 30px; }
.sb-bar-fill { height: 100%; border-radius: 99px; transition: width 0.4s ease; }
.sb-cat-pct { font-size: 10px; font-weight: 600; width: 26px; text-align: right; flex-shrink: 0; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .main-layout { grid-template-columns: 1fr 290px; padding: 18px 20px; }
  .sb-cat-left { flex: 0 0 140px; }
}
@media (max-width: 800px) {
  .main-layout { grid-template-columns: 1fr; padding: 14px 16px; }
  .progress-sidebar { position: static; }
  .header-inner, .mode-tabs, .control-panel-inner, .exam-nav-inner { padding-left: 16px; padding-right: 16px; }
}

/* ===== TABLET ===== */
@media (max-width: 640px) {
  .header-inner { padding: 0 14px; height: 56px; }
  .mode-tabs-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .mode-tabs-wrapper::-webkit-scrollbar { display: none; }
  .mode-tabs { padding: 0 14px; min-width: max-content; }
  .mode-tab { padding: 10px 16px; font-size: 13px; }
  .control-panel { top: 56px; }
  .exam-nav { top: 56px; }
}

/* ===== TABLET/PHABLET — chowaj etykiety w headerze ===== */
@media (max-width: 700px) {
  .btn-label { display: none; }
  .btn-icon-only { display: inline !important; }
  .header-actions .btn-sm { padding: 8px 11px; }
  .user-email-short { display: none; }
  .limit-badge { display: none !important; }
}

/* ===== MOBILE ===== */
@media (max-width: 480px) {
  .header-inner { padding: 0 10px; height: 52px; gap: 4px; }
  .logo-sub { display: none; }
  .logo-title { font-size: 13px; }
  .header-actions { gap: 2px; }
  .header-actions .btn-sm { padding: 7px 9px; font-size: 15px; }

  .mode-tabs { padding: 0 10px; }
  .mode-tab { padding: 9px 13px; font-size: 12px; }

  .control-panel { top: 52px; }
  .control-panel-inner { padding: 8px 10px; gap: 8px; flex-wrap: wrap; }
  .exam-nav { top: 52px; }
  .exam-nav-inner { padding: 6px 10px; }

  .main-layout { padding: 10px 10px; gap: 12px; }
  .task-section { gap: 10px; min-height: auto; }
}

/* ===== SMALL PHONE ===== */
@media (max-width: 380px) {
  .mode-tab { padding: 8px 10px; font-size: 11px; }
}

/* ===== KARTY WZORÓW ===== */
.wzory-panel { max-width: 1500px; margin: 0 auto; padding: 20px 28px 28px; box-sizing: border-box; width: 100%; }
.wzory-panel-inner { display: flex; flex-direction: column; gap: 12px; height: calc(100vh - 160px); }
.wzory-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  background: rgba(255,255,255,0.04);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}
.wzory-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.wzory-pdf-container { flex: 1; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; background: #fff; }
.wzory-pdf-iframe { width: 100%; height: 100%; border: none; display: block; }

@media (max-width: 768px) {
  .wzory-panel { padding: 12px 16px 16px; }
  .wzory-panel-inner { height: calc(100vh - 180px); }
}

/* ===== WZORY — MOBILE PDF FALLBACK ===== */
/* Urządzenia dotykowe (telefon/tablet) nie obsługują iframe z PDF */
.wzory-mobile-fallback { display: none; }

@media (hover: none) {
  /* touch device — pokaż fallback, ukryj iframe */
  .wzory-pdf-iframe { display: none; }
  .wzory-mobile-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 48px 24px;
    text-align: center;
    flex: 1;
  }
}

.wzory-mobile-icon { font-size: 56px; line-height: 1; }
.wzory-mobile-text {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 320px;
  margin: 0;
}

@media (max-width: 480px) {
  .wzory-panel { padding: 8px 10px 12px; }
  .wzory-panel-inner { height: calc(100dvh - 160px); }
  .wzory-mobile-fallback { padding: 32px 16px; gap: 14px; }
  .wzory-mobile-icon { font-size: 44px; }
  .wzory-mobile-text { font-size: 14px; }
}
