/* ============================================================
   CYBERBEZPIECZEŃSTWO - Design System
   Paleta: grafit + elektryczny błękit (zaufanie, ochrona)
   + bursztyn (ostrzeżenia) + zieleń (bezpieczne działania)
   Typografia: Space Grotesk (display) + IBM Plex Sans (body)
   ============================================================ */

:root {
  /* Light theme (default) */
  --bg-primary: #f7f8fa;
  --bg-secondary: #eef1f5;
  --bg-card: #ffffff;
  --bg-code: #eef1f5;
  --text-primary: #1a2332;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  --border: #dde3ea;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-soft: rgba(29, 78, 216, 0.08);
  --accent-2: #0ea5e9;
  --warning: #b45309;
  --warning-bg: #fef3c7;
  --success: #047857;
  --success-bg: #d1fae5;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --header-bg: rgba(255, 255, 255, 0.9);
  --sidebar-bg: #f7f8fa;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.12);
  --accent-light: rgba(29, 78, 216, 0.35);
  --accent-subtle: rgba(29, 78, 216, 0.12);
  --footer-bg: #111827;
  --footer-text: #9ca3af;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #0f172a;
    --bg-code: #1e293b;
    --text-primary: #e5e7eb;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border: rgba(148, 163, 184, 0.16);
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-soft: rgba(59, 130, 246, 0.12);
    --accent-2: #38bdf8;
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.12);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.12);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.12);
    --header-bg: rgba(10, 14, 23, 0.92);
    --sidebar-bg: #0a0e17;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
    --accent-light: rgba(59, 130, 246, 0.4);
    --accent-subtle: rgba(59, 130, 246, 0.14);
    --footer-bg: #060a12;
    --footer-text: #94a3b8;
  }
}

/* ===== RESET / BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; }
body {
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body::before, body::after {
  content: ''; position: fixed; pointer-events: none; z-index: -1;
  width: 600px; height: 600px; border-radius: 50%;
  background: radial-gradient(circle, var(--accent-subtle), transparent 70%);
  opacity: .5;
}
body::before { top: -240px; right: -160px; }
body::after { bottom: -240px; left: -160px; }

::selection { background: var(--accent); color: #fff; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
input, button { font-family: inherit; }

h1, h2, h3, h4 {
  font-family: 'Space Grotesk', sans-serif;
  line-height: 1.2;
  text-wrap: balance;
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(1.7rem, 4vw, 2.5rem); font-weight: 700; }
h2 { font-size: clamp(1.3rem, 3vw, 1.7rem); font-weight: 600; margin: 2rem 0 .8rem; }
h3 { font-size: 1.15rem; font-weight: 600; margin: 1.6rem 0 .6rem; }
p { color: var(--text-secondary); line-height: 1.7; }
ul, ol { padding-left: 1.4rem; color: var(--text-secondary); }
li { margin: .3rem 0; }
strong { color: var(--text-primary); }

/* ===== HEADER ===== */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.app-header::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-subtle), transparent);
  opacity: .6;
}
.header-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; gap: 20px;
  padding: 0 24px; height: 64px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700; font-size: 1.05rem; color: var(--text-primary);
  white-space: nowrap;
}
.brand-icon {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; flex-shrink: 0;
}
.brand-icon svg { width: 20px; height: 20px; }
.brand-accent { color: var(--accent); }

.search-box { position: relative; margin-left: auto; width: min(340px, 38vw); }
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-muted); pointer-events: none;
}
#search-input {
  width: 100%; height: 40px; padding: 0 14px 0 36px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-secondary); color: var(--text-primary);
  font-size: .92rem; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
#search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-results {
  position: absolute; top: 46px; left: 0; right: 0; z-index: 120;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-lg);
  max-height: 380px; overflow-y: auto; padding: 6px;
}
.search-results a {
  display: block; padding: 9px 12px; border-radius: 8px;
  font-size: .88rem; color: var(--text-primary);
}
.search-results a:hover { background: var(--accent-soft); }
.search-results .sr-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); padding: 8px 12px 2px; }

.burger {
  display: none; flex-direction: column; gap: 5px;
  background: none; border: none; cursor: pointer; padding: 8px;
}
.burger span { display: block; width: 22px; height: 2px; background: var(--text-primary); border-radius: 2px; transition: transform .25s, opacity .25s; }
.burger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger.open span:nth-child(2) { opacity: 0; }
.burger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ===== SIDEBAR ===== */
.page-wrap { display: flex; flex: 1; padding-top: 64px; }
.sidebar {
  width: 280px; flex-shrink: 0;
  position: sticky; top: 64px; height: calc(100vh - 64px);
  overflow-y: auto; padding: 16px 12px 40px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.sidebar-link {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 8px;
  font-size: .9rem; color: var(--text-secondary);
  border-left: 2px solid transparent;
  transition: background .15s, color .15s;
  line-height: 1.35;
}
.sidebar-link:hover { background: var(--accent-soft); color: var(--text-primary); }
.sidebar-link.active { background: var(--accent-soft); color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.sidebar-link .si { font-size: .85rem; flex-shrink: 0; }
.sidebar-sec {
  padding: 16px 12px 4px;
  font-size: .7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-muted);
}
.sidebar-overlay { display: none; }

/* ===== MAIN ===== */
.main {
  flex: 1; min-width: 0;
  padding: 40px 48px 80px;
  max-width: 960px;
  animation: fadeUp .28s ease-out;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== HOME HERO ===== */
.home-hero {
  position: relative;
  border-radius: 18px; overflow: hidden;
  padding: 48px 44px;
  background: linear-gradient(135deg, #111827 0%, #1e3a8a 60%, #0ea5e9 130%);
  color: #f8fafc;
  box-shadow: var(--shadow-lg);
  margin-bottom: 40px;
}
.home-hero::before {
  content: ''; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 44px 44px;
  opacity: .5;
}
.home-hero > * { position: relative; }
.home-hero .hero-label {
  display: inline-block; font-size: .72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .14em;
  color: #7dd3fc; margin-bottom: 14px;
}
.home-hero h1 { font-size: clamp(1.9rem, 4.5vw, 2.7rem); color: #fff; margin-bottom: 14px; }
.home-hero p { color: #cbd5e1; font-size: 1.05rem; max-width: 620px; }
.home-hero .hero-stats {
  display: flex; gap: 32px; margin-top: 28px; flex-wrap: wrap;
}
.home-hero .hero-stat .num { font-family: 'Space Grotesk', sans-serif; font-size: 1.6rem; font-weight: 700; color: #38bdf8; }
.home-hero .hero-stat .lbl { font-size: .8rem; color: #94a3b8; }

/* ===== HOME SECTIONS & CARDS ===== */
.home-section { margin-bottom: 44px; }
.home-section-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.25rem; font-weight: 600;
  margin-bottom: 6px; display: flex; align-items: center; gap: 10px;
}
.home-section-title::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(90deg, var(--border), transparent);
}
.home-section-desc { font-size: .9rem; color: var(--text-muted); margin-bottom: 18px; }
.home-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 16px;
}
.home-card {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 20px 18px;
  transition: transform .2s ease-out, box-shadow .2s ease-out, border-color .2s;
}
.home-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--accent-subtle); }
.home-card .card-icon { font-size: 1.5rem; line-height: 1; }
.home-card h3 { font-size: .95rem; font-weight: 600; margin: 0; color: var(--text-primary); }
.home-card p { font-size: .85rem; color: var(--text-muted); line-height: 1.55; }
.home-card .card-link {
  margin-top: auto; font-size: .82rem; font-weight: 600; color: var(--accent);
  display: inline-flex; align-items: center; gap: 4px;
}
.home-card .card-link::after { content: '→'; transition: transform .2s; }
.home-card:hover .card-link::after { transform: translateX(3px); }

/* ===== ARTICLE ===== */
.article-header { margin-bottom: 28px; padding-bottom: 22px; border-bottom: 1px solid var(--border); }
.article-header .article-icon { font-size: 2.2rem; line-height: 1; margin-bottom: 12px; }
.article-header h1 { margin-bottom: 10px; }
.article-header .article-excerpt { font-size: 1.08rem; color: var(--text-secondary); max-width: 700px; }
.article-meta {
  display: flex; gap: 16px; margin-top: 14px;
  font-size: .8rem; color: var(--text-muted);
}
.article-meta span { display: inline-flex; align-items: center; gap: 5px; }

.info-box {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--accent-soft);
  border: 1px solid var(--accent-subtle);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 1.4rem 0;
  font-size: .95rem; color: var(--text-secondary);
}
.info-box .ib-icon { font-size: 1.15rem; line-height: 1.4; flex-shrink: 0; }

.warning-box {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--warning-bg);
  border: 1px solid rgba(180, 83, 9, 0.25);
  border-left: 4px solid var(--warning);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 1.4rem 0;
  font-size: .95rem; color: var(--text-secondary);
}
.warning-box .wb-icon { font-size: 1.15rem; line-height: 1.4; flex-shrink: 0; }

.success-box {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--success-bg);
  border: 1px solid rgba(4, 120, 87, 0.25);
  border-left: 4px solid var(--success);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 1.4rem 0;
  font-size: .95rem; color: var(--text-secondary);
}
.success-box .sb-icon { font-size: 1.15rem; line-height: 1.4; flex-shrink: 0; }

table {
  width: 100%; border-collapse: collapse;
  margin: 1.4rem 0; font-size: .92rem;
  background: var(--bg-card);
  border-radius: 10px; overflow: hidden;
  border: 1px solid var(--border);
}
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--bg-secondary); font-family: 'Space Grotesk', sans-serif; font-size: .85rem; font-weight: 600; color: var(--text-primary); }
tr:last-child td { border-bottom: none; }
td { color: var(--text-secondary); }
.table-responsive { overflow-x: auto; }

.error-table th { background: var(--danger-bg); color: var(--danger); }
.error-table td:first-child { font-weight: 600; color: var(--danger); font-family: 'Space Grotesk', sans-serif; }

.faq-item { margin: 1.2rem 0; padding: 18px 20px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; }
.faq-item h3 { margin: 0 0 8px; font-size: 1.02rem; }
.faq-item p { margin: 0; }

dl { margin: 1.2rem 0; }
dt { font-family: 'Space Grotesk', sans-serif; font-weight: 600; color: var(--accent); margin-top: 1.1rem; font-size: 1rem; }
dd { color: var(--text-secondary); margin: .2rem 0 0; padding-left: 0; }

code {
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: .88em;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 6px;
  color: var(--text-primary);
}

.content-article { max-width: 760px; }
.content-article h2:first-child { margin-top: 0; }

/* ===== TOC ===== */
.toc {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  margin: 0 0 1.6rem;
  font-size: .9rem;
}
.toc-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: .78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-muted); margin-bottom: 8px;
}
.toc a {
  display: block; padding: 4px 0; color: var(--text-secondary);
  border-left: 2px solid transparent; padding-left: 10px;
  transition: color .15s, border-color .15s;
}
.toc a:hover { color: var(--accent); border-left-color: var(--accent); }

/* ===== 404 ===== */
.notfound { text-align: center; padding: 80px 20px; }
.notfound .nf-icon { font-size: 3rem; margin-bottom: 16px; }
.notfound h1 { margin-bottom: 10px; }
.notfound p { margin-bottom: 20px; }
.btn {
  display: inline-block; padding: 10px 22px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 600; font-size: .9rem;
  border-radius: 10px; transition: opacity .2s, transform .2s;
}
.btn:hover { opacity: .9; transform: translateY(-1px); }

/* ===== FOOTER ===== */
.app-footer {
  background: var(--footer-bg); color: var(--footer-text);
  padding: 40px 24px; margin-top: auto;
}
.footer-inner { max-width: 1200px; margin: 0 auto; }
.footer-brand { font-family: 'Space Grotesk', sans-serif; font-weight: 700; color: #e5e7eb; font-size: 1rem; margin-bottom: 8px; }
.footer-desc { font-size: .85rem; max-width: 640px; line-height: 1.6; }
.footer-copy { font-size: .78rem; margin-top: 16px; color: #6b7280; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: -300px; top: 64px; bottom: 0;
    width: 290px; z-index: 90;
    transition: left .3s ease-out;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { left: 0; }
  .sidebar-overlay {
    display: block; position: fixed; inset: 64px 0 0 0; z-index: 80;
    background: rgba(0,0,0,.45); opacity: 0; pointer-events: none;
    transition: opacity .3s;
  }
  .sidebar-overlay.show { opacity: 1; pointer-events: auto; }
  .burger { display: flex; }
  .search-box { width: auto; flex: 1; max-width: none; }
  .main { padding: 28px 24px 60px; }
}
@media (max-width: 600px) {
  body { font-size: 16.5px; }
  .header-inner { padding: 0 16px; gap: 12px; }
  .brand-text { font-size: .95rem; }
  .brand-accent { display: none; }
  .main { padding: 22px 16px 50px; }
  .home-hero { padding: 34px 24px; }
  .home-hero .hero-stats { gap: 20px; }
  .home-grid { grid-template-columns: 1fr; }
  .search-results { max-height: 320px; }
}

/* ===== FOCUS VISIBLE (WCAG) ===== */
a:focus-visible, input:focus-visible, button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
