:root {
  /* Color Palette */
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --secondary: #ec4899;
  --bg-dark: #0f172a;
  --bg-gradient: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);

  --card-bg: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  /* Learn Mode Colors */
  --learn-primary: #f97316;
  --learn-bg: linear-gradient(135deg, #431407 0%, #7c2d12 100%);

  /* Dimensions */
  --header-height: auto;
  --card-height: 420px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", sans-serif;
  background-color: var(--bg-dark);
  min-height: 100vh;
  color: var(--text-main);
  overflow-x: hidden;
  padding: 20px;
  transition: background 0.5s ease;
}

/* --- Animated Background --- */
.bg-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-gradient);
  z-index: -2;
  transition: opacity 0.5s ease;
}

.bg-shape {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  z-index: -1;
  opacity: 0.4;
  animation: float 20s infinite alternate;
}

.shape-1 {
  width: 400px;
  height: 400px;
  background: var(--primary);
  top: -100px;
  left: -100px;
}

.shape-2 {
  width: 300px;
  height: 300px;
  background: var(--secondary);
  bottom: -50px;
  right: -50px;
  animation-delay: -5s;
}

@keyframes float {
  0% {
    transform: translate(0, 0) scale(1);
  }
  100% {
    transform: translate(30px, 50px) scale(1.1);
  }
}

/* --- Learn Mode Overrides --- */
body.learn-mode .bg-overlay {
  background: var(--learn-bg);
}
body.learn-mode .shape-1 {
  background: var(--learn-primary);
}
body.learn-mode .shape-2 {
  background: #fbbf24;
}
body.learn-mode .cta-button {
  background: var(--learn-primary);
  box-shadow: 0 4px 15px rgba(249, 115, 22, 0.4);
}
body.learn-mode .cta-button:hover {
  background: #ea580c;
}
body.learn-mode h3 {
  color: var(--learn-primary);
}
body.learn-mode .filter-summary {
  color: var(--learn-primary);
}
body.learn-mode .category-badge {
  background: rgba(249, 115, 22, 0.1);
  color: var(--learn-primary);
  border-color: rgba(249, 115, 22, 0.2);
}

/* --- Layout --- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 30px;
}

/* --- Glass Panel --- */
.glass-panel {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

/* --- Header --- */
.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand h1 {
  font-family: "Poppins", sans-serif;
  font-size: 24px;
  color: white;
  font-weight: 700;
}

.brand .highlight {
  color: var(--primary);
}
body.learn-mode .brand .highlight {
  color: var(--learn-primary);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 15px;
}

.version-tag {
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  font-family: "Poppins", sans-serif;
}

/* --- Stats Grid --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 15px;
}

.stat-item {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: transform 0.2s;
}

.stat-item:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.1);
}

.stat-label {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 4px;
}

.stat-value {
  font-family: "Poppins", sans-serif;
  font-size: 24px;
  font-weight: 600;
  color: white;
}

.stat-item.danger .stat-value {
  color: #fca5a5;
}
.stat-item.info .stat-value {
  color: #93c5fd;
}
.stat-item.success .stat-value {
  color: #86efac;
}

/* --- FILTERS WRAPPER (Płynna Animacja Grid) --- */
.filters-wrapper {
  padding: 0;
  transition: background 0.3s ease;
}

.filter-toggle-btn {
  width: 100%;
  background: transparent;
  border: none;
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  color: white;
  font-family: "Inter", sans-serif;
  transition: background 0.2s;
  outline: none;
}

.filter-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.filter-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.filter-summary {
  font-size: 13px;
  background: rgba(255, 255, 255, 0.1);
  padding: 4px 10px;
  border-radius: 20px;
  color: var(--primary);
  font-weight: 600;
}

.chevron-icon {
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  color: var(--text-muted);
}

.filters-wrapper.open .chevron-icon {
  transform: rotate(180deg);
}

/* --- ANIMACJA ROZWIJANIA (Grid Trick) --- */
.categories-list {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.filters-wrapper.open .categories-list {
  grid-template-rows: 1fr;
}

.categories-scroll-wrapper {
  overflow: hidden;
}

/* Wewnętrzny kontener */
.categories-inner-content {
  max-height: 300px;
  overflow-y: auto;
  padding: 0 24px 24px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  opacity: 0;
  transition: opacity 0.3s ease;
  visibility: hidden;
}

/* Pokaż treść tylko gdy otwarte */
.filters-wrapper.open .categories-inner-content {
  opacity: 1;
  visibility: visible;
  transition-delay: 0.1s;
}

.categories-inner-content::-webkit-scrollbar {
  width: 6px;
}
.categories-inner-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.categories-grid-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 20px;
}

/* Style checkboxów */
.category-checkbox {
  display: none;
}

.category-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: #cbd5e1;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.category-label:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
}

.category-checkbox:checked + .category-label {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

body.learn-mode .category-checkbox:checked + .category-label {
  background: var(--learn-primary);
  border-color: var(--learn-primary);
}

.category-count {
  font-size: 12px;
  opacity: 0.7;
}

/* --- Mode Button --- */
.mode-toggle {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 8px 16px;
  border-radius: 50px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
.mode-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
}
.mode-toggle.active {
  background: var(--learn-primary);
  border-color: var(--learn-primary);
  box-shadow: 0 0 15px rgba(249, 115, 22, 0.3);
}

/* --- Card Grid --- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 30px;
  perspective: 1000px;
  min-height: 200px;
}

/* --- The Card --- */
.question-card {
  background: transparent;
  height: var(--card-height);
  cursor: pointer;
  animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform-style: preserve-3d;
}

.question-card.flipped .card-inner {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  background: var(--card-bg);
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.3);
}

.card-back {
  transform: rotateY(180deg);
  background: #f8fafc;
}

/* Card Header */
.card-header {
  padding: 24px 24px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.question-card h3 {
  font-family: "Poppins", sans-serif;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--primary);
  font-weight: 700;
}

.bookmark-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #cbd5e1;
  padding: 5px;
  transition: all 0.2s;
}

.bookmark-btn:hover {
  color: var(--primary);
  transform: scale(1.1);
}
.bookmark-btn.marked {
  color: #fbbf24;
  filter: drop-shadow(0 0 5px rgba(251, 191, 36, 0.5));
}
.bookmark-btn.marked svg {
  fill: currentColor;
}

/* Card Content & Badge */
.card-content {
  flex: 1;
  padding: 10px 24px;
  overflow-y: auto;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Wrapper dla wielu badge'y */
.badges-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.category-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.answer {
  font-weight: 600;
  color: var(--primary-dark);
}
body.learn-mode .answer {
  color: #c2410c;
}

.details {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px dashed #e2e8f0;
}

/* Scrollbar */
.card-content::-webkit-scrollbar {
  width: 6px;
}
.card-content::-webkit-scrollbar-track {
  background: transparent;
}
.card-content::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 20px;
}

/* Flip Hint */
.flip-hint {
  text-align: center;
  padding: 15px;
  font-size: 12px;
  color: var(--text-muted);
  background: linear-gradient(to top, rgba(255, 255, 255, 1) 40%, transparent);
  font-weight: 500;
}

/* --- Controls --- */
.controls-area {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 30px;
  padding-bottom: 40px;
  flex-wrap: wrap;
}

.cta-button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 16px 32px;
  font-size: 18px;
  border-radius: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}
.cta-button:hover:not(:disabled) {
  transform: translateY(-4px);
  box-shadow: 0 10px 25px rgba(99, 102, 241, 0.5);
}
.cta-button:disabled {
  background: #475569;
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

/* Custom Checkbox */
.custom-checkbox {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}
.custom-checkbox input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}
.checkmark {
  height: 24px;
  width: 24px;
  background-color: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.checkmark svg {
  width: 16px;
  height: 16px;
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.custom-checkbox input:checked ~ .checkmark {
  background-color: var(--primary);
  border-color: var(--primary);
}
body.learn-mode .custom-checkbox input:checked ~ .checkmark {
  background-color: var(--learn-primary);
  border-color: var(--learn-primary);
}
.custom-checkbox input:checked ~ .checkmark svg {
  opacity: 1;
  transform: scale(1);
}
.label-text {
  color: white;
  font-size: 16px;
  font-weight: 500;
}

/* Mobile */
@media (max-width: 768px) {
  .header-top {
    flex-direction: column;
    gap: 15px;
    align-items: flex-start;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  .card-content {
    font-size: 15px;
  }
}

/* --- Empty State --- */
body.no-questions #questionsContainer {
  display: none;
}
body.no-questions .controls-area {
  margin-top: 40px;
  animation: fadeUp 0.5s ease;
}
body.no-questions .container {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
}
body.no-questions .controls-area {
  margin-top: auto;
  margin-bottom: auto;
}

/* ═══════════════════════════════════════════════════════════ UTILITIES */
.hidden {
  display: none !important;
}

.view-container {
  width: 100%;
}

/* ═══════════════════════════════════════════════════════════ MENU VIEW */
.menu-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 40px 0 16px;
}

.menu-subtitle {
  color: rgba(255, 255, 255, 0.5);
  font-size: 15px;
  margin-bottom: 32px;
  padding-left: 2px;
}

.sections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  padding-bottom: 48px;
}

/* Section card */
.section-card {
  padding: 0;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.section-card:not(.coming-soon) {
  cursor: pointer;
}

.section-card:not(.coming-soon):hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.section-card-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 24px;
}

.section-emoji {
  font-size: 30px;
  flex-shrink: 0;
}

.section-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.section-title {
  font-family: "Poppins", sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: white;
}

.section-badge {
  display: inline-block;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.6);
  font-weight: 500;
  width: fit-content;
}

.direct-badge {
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
}

.coming-soon-badge {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}

.section-arrow,
.section-chevron {
  color: rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.section-card.expanded .section-chevron {
  transform: rotate(180deg);
}

.section-card.coming-soon {
  opacity: 0.45;
}

/* Subjects accordion */
.subjects-list {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.section-card.expanded .subjects-list {
  grid-template-rows: 1fr;
}

.subjects-inner {
  overflow: hidden;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.subject-btn {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.75);
  font-family: "Inter", sans-serif;
  font-size: 14px;
  text-align: left;
  transition: background 0.2s, color 0.2s;
}

.subject-btn:last-child {
  border-bottom: none;
}

.subject-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: white;
}

.subject-btn svg {
  color: rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
  margin-left: 12px;
}

.no-subjects {
  padding: 16px 24px;
  color: rgba(255, 255, 255, 0.35);
  font-size: 13px;
  font-style: italic;
}

/* ═══════════════════════════════════════════════════════════ QUIZ NAV */
.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.back-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.8);
  padding: 7px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background 0.2s, color 0.2s;
  font-family: "Inter", sans-serif;
  flex-shrink: 0;
}

.back-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: white;
}

.quiz-title {
  font-family: "Poppins", sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: white;
  line-height: 1.3;
}

@media (max-width: 768px) {
  .quiz-title {
    font-size: 14px;
  }
  .sections-grid {
    grid-template-columns: 1fr;
  }
}

/* ══════════════════════════════════════════════════════════════ THEME: CYBER */
/* Bezpieczeństwo w sieciach komputerowych — klimat terminal/matrix */
body[data-theme="cyber"] {
  --primary: #00d4aa;
  --primary-dark: #00a884;
  --secondary: #06b6d4;
}

body[data-theme="cyber"] .bg-overlay {
  background: linear-gradient(135deg, #001a12 0%, #002d20 50%, #001520 100%);
}

body[data-theme="cyber"] .shape-1 {
  background: #00d4aa;
}

body[data-theme="cyber"] .shape-2 {
  background: #06b6d4;
}

body[data-theme="cyber"] .brand .highlight {
  color: var(--primary);
}

body[data-theme="cyber"] .cta-button {
  background: var(--primary);
  box-shadow: 0 4px 15px rgba(0, 212, 170, 0.4);
}

body[data-theme="cyber"] .cta-button:hover:not(:disabled) {
  box-shadow: 0 10px 25px rgba(0, 212, 170, 0.5);
}

body[data-theme="cyber"] .question-card h3 {
  color: var(--primary);
}

body[data-theme="cyber"] .filter-summary {
  color: var(--primary);
}

body[data-theme="cyber"] .category-badge {
  background: rgba(0, 212, 170, 0.1);
  color: var(--primary);
  border-color: rgba(0, 212, 170, 0.25);
}

body[data-theme="cyber"] .category-checkbox:checked + .category-label {
  background: var(--primary);
  border-color: var(--primary);
}

body[data-theme="cyber"] .custom-checkbox input:checked ~ .checkmark {
  background-color: var(--primary);
  border-color: var(--primary);
}

body[data-theme="cyber"] .answer {
  color: var(--primary-dark);
}

/* Learn mode inside cyber theme */
body[data-theme="cyber"].learn-mode .bg-overlay {
  background: linear-gradient(135deg, #1a0a00 0%, #2d1500 100%);
}

/* ══════════════════════════════════════════════════════════════ THEME: ACADEMIC */
/* Obrona inżynierka — złoto-granatowy klimat dyplomowy */
body[data-theme="academic"] {
  --primary: #f59e0b;
  --primary-dark: #d97706;
  --secondary: #fbbf24;
}

body[data-theme="academic"] .bg-overlay {
  background: linear-gradient(135deg, #0c1222 0%, #1a2540 50%, #0f1b35 100%);
}

body[data-theme="academic"] .shape-1 {
  background: #f59e0b;
}

body[data-theme="academic"] .shape-2 {
  background: #3b82f6;
}

body[data-theme="academic"] .brand .highlight {
  color: var(--primary);
}

body[data-theme="academic"] .cta-button {
  background: var(--primary);
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
}

body[data-theme="academic"] .cta-button:hover:not(:disabled) {
  box-shadow: 0 10px 25px rgba(245, 158, 11, 0.5);
}

body[data-theme="academic"] .question-card h3 {
  color: var(--primary);
}

body[data-theme="academic"] .filter-summary {
  color: var(--primary);
}

body[data-theme="academic"] .category-badge {
  background: rgba(245, 158, 11, 0.1);
  color: var(--primary);
  border-color: rgba(245, 158, 11, 0.25);
}

body[data-theme="academic"] .category-checkbox:checked + .category-label {
  background: var(--primary);
  border-color: var(--primary);
}

body[data-theme="academic"] .custom-checkbox input:checked ~ .checkmark {
  background-color: var(--primary);
  border-color: var(--primary);
}

body[data-theme="academic"] .answer {
  color: var(--primary-dark);
}

/* Learn mode inside academic theme */
body[data-theme="academic"].learn-mode .bg-overlay {
  background: linear-gradient(135deg, #431407 0%, #7c2d12 100%);
}
