/* ============================================================
   Pacjent - design system
   Paleta: granat (zaufanie) + teal (zdrowie) + krem (ciepło)
   Typografia: Spectral (display) + Karla (body)
   ============================================================ */

:root {
  /* Light */
  --bg: #f6f4ef;
  --bg-card: #ffffff;
  --bg-subtle: #edf3f1;
  --text: #1c2b33;
  --text-secondary: #54646d;
  --accent: #0f766e;
  --accent-strong: #0b5d57;
  --navy: #14324a;
  --amber: #b45309;
  --border: #e0ddd4;
  --accent-subtle: #dceeeb;
  --shadow-card: 0 1px 2px rgba(20, 50, 74, .06), 0 4px 16px rgba(20, 50, 74, .07);
  --shadow-card-hover: 0 2px 4px rgba(20, 50, 74, .08), 0 10px 28px rgba(20, 50, 74, .13);
  --header-bg: rgba(246, 244, 239, .92);
  --sidebar-bg: #f1efe9;
  --hero-grad: linear-gradient(135deg, #14324a 0%, #0f5c66 55%, #0f766e 100%);
  --radius: 12px;
  --transition: all .2s ease-out;
  --font-display: 'Spectral', Georgia, serif;
  --font-body: 'Karla', 'Segoe UI', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1519;
    --bg-card: #152128;
    --bg-subtle: #1a2a31;
    --text: #dbe6ea;
    --text-secondary: #9db0b8;
    --accent: #34d3c3;
    --accent-strong: #5fe3d6;
    --navy: #0b1a26;
    --amber: #f0a35e;
    --border: #24343d;
    --accent-subtle: #173a38;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --shadow-card-hover: 0 2px 4px rgba(0, 0, 0, .4), 0 10px 28px rgba(0, 0, 0, .4);
    --header-bg: rgba(13, 21, 25, .92);
    --sidebar-bg: #111c21;
    --hero-grad: linear-gradient(135deg, #0b1a26 0%, #0e3f47 55%, #11594f 100%);
  }
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 600px 400px at 100% 0%, rgba(15, 118, 110, .08), transparent 60%),
    radial-gradient(ellipse 700px 500px at 0% 100%, rgba(20, 50, 74, .07), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

/* Cursor-reactive orbs (subtle, pointer devices only) */
@media (pointer: fine) {
  body::before, body::after {
    content: '';
    position: fixed;
    width: 380px; height: 380px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    filter: blur(90px);
    background: rgba(15, 118, 110, .10);
    transition: opacity .6s ease-out;
  }
  body::before { top: -120px; left: -120px; }
  body::after { bottom: -120px; right: -120px; }
}

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: #fff;
  padding: 10px 18px; border-radius: 0 0 8px 0;
  z-index: 1000; font-weight: 600;
}
.skip-link:focus { left: 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.25;
  text-wrap: balance;
}

/* ---------- HEADER ---------- */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
.app-header::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(15, 118, 110, .35), transparent);
  opacity: .3;
  pointer-events: none;
}

.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand-mark { display: inline-flex; }
.brand-name { font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; }
.brand-name a { color: var(--text); }
.brand-accent { color: var(--accent); }

.header-search {
  position: relative;
  flex: 1;
  max-width: 460px;
  margin-left: auto;
}
.search-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  font-size: .9rem;
  opacity: .55;
  pointer-events: none;
}
#search-input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  font-family: var(--font-body);
  font-size: .95rem;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  outline: none;
  transition: var(--transition);
}
#search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}
#search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card-hover);
  overflow: hidden;
  display: none;
  z-index: 200;
}
.search-result {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}
.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--bg-subtle); }
.search-result div { display: flex; flex-direction: column; gap: 2px; }
.search-result span { color: var(--text-secondary); font-size: .8rem; }

.mobile-menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1.2rem;
  padding: 6px 10px;
  color: var(--text);
  cursor: pointer;
}

/* ---------- SIDEBAR ---------- */
.sidebar {
  position: fixed;
  top: 64px; bottom: 0; left: 0;
  width: 300px;
  overflow-y: auto;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 16px 0 40px;
  z-index: 90;
}
.sidebar-nav { list-style: none; }
.sidebar-nav > li > a {
  display: block;
  padding: 7px 18px;
  font-size: .9rem;
  font-weight: 500;
  color: var(--text);
  border-left: 3px solid transparent;
  transition: var(--transition);
}
.sidebar-nav > li > a:hover {
  background: var(--bg-card);
  color: var(--accent-strong);
}
.sidebar-nav > li > a.active {
  background: var(--accent-subtle);
  color: var(--accent-strong);
  border-left-color: var(--accent);
  font-weight: 600;
}
.nav-section {
  padding: 16px 18px 6px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--accent);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 85;
}

/* ---------- MAIN ---------- */
.main-content {
  margin-left: 300px;
  padding: 96px 32px 80px;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}
.content-article {
  max-width: 820px;
  margin: 0 auto;
  animation: fadeUp .25s ease-out;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- HERO ---------- */
.home-hero {
  background: var(--hero-grad);
  border-radius: var(--radius);
  padding: 44px 44px 36px;
  color: #fff;
  margin-bottom: 36px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card-hover);
}
.home-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 85% 20%, rgba(255, 255, 255, .12), transparent 40%),
    radial-gradient(circle at 15% 90%, rgba(255, 255, 255, .07), transparent 35%);
  pointer-events: none;
}
.hero-kicker {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(255, 255, 255, .75);
  margin-bottom: 10px;
}
.home-hero h1 {
  font-size: 2.4rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 12px;
}
.hero-lead {
  font-size: 1.05rem;
  color: rgba(255, 255, 255, .88);
  max-width: 620px;
  margin-bottom: 24px;
}
.quick-tasks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 26px;
}
.quick-task {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .25);
  color: #fff;
  font-size: .85rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  transition: var(--transition);
}
.quick-task:hover {
  background: rgba(255, 255, 255, .24);
  color: #fff;
  transform: translateY(-1px);
}
.stats-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.stat-card {
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 10px;
  padding: 10px 18px;
  display: flex;
  flex-direction: column;
}
.stat-card .num {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.1;
}
.stat-card .label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255, 255, 255, .72);
}

/* ---------- HOME GRID ---------- */
.home-section-label {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.35rem;
  margin: 34px 0 16px;
  color: var(--text);
}
.accent-bar {
  width: 26px;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--navy));
  flex-shrink: 0;
}
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.home-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--text);
  box-shadow: var(--shadow-card);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.home-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  color: var(--text);
}
.card-icon { font-size: 1.4rem; display: inline-block; margin-bottom: 8px; }
.home-card h3 {
  font-size: .9rem;
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.4;
}
.home-card p {
  font-size: .85rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* ---------- ARTICLE ---------- */
.content-article h1 {
  font-size: 2.1rem;
  margin-bottom: 8px;
}
.article-meta {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--accent);
  margin-bottom: 24px;
}
.content-article h2 {
  font-size: 1.5rem;
  margin: 32px 0 14px;
  padding-top: 8px;
}
.content-article h3 {
  font-size: 1.15rem;
  margin: 22px 0 10px;
}
.content-article p {
  margin-bottom: 14px;
}
.content-article ul, .content-article ol {
  margin: 0 0 16px 24px;
}
.content-article li {
  margin-bottom: 6px;
}
.content-article strong { font-weight: 700; }

/* TOC */
.article-toc {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 16px 20px;
  margin: 20px 0 26px;
}
.article-toc h3 {
  font-size: .95rem;
  font-family: var(--font-body);
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--text);
}
.article-toc a {
  display: block;
  font-size: .88rem;
  padding: 3px 0;
  color: var(--text-secondary);
}
.article-toc a:hover { color: var(--accent); }
.article-toc .toc-h3 { padding-left: 16px; font-size: .84rem; }

/* Info box */
.info-box {
  background: var(--accent-subtle);
  border: 1px solid rgba(15, 118, 110, .25);
  border-radius: 8px;
  padding: 14px 18px;
  margin: 18px 0;
  font-size: .95rem;
}
.info-box strong { color: var(--accent-strong); }

/* Warning box */
.warn-box {
  background: rgba(180, 83, 9, .08);
  border: 1px solid rgba(180, 83, 9, .3);
  border-radius: 8px;
  padding: 14px 18px;
  margin: 18px 0;
  font-size: .95rem;
}
.warn-box strong { color: var(--amber); }

/* Tables */
.table-responsive {
  overflow-x: auto;
  margin: 18px 0;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.error-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
  background: var(--bg-card);
}
.error-table th {
  background: var(--bg-subtle);
  color: var(--text);
  font-weight: 700;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 2px solid var(--accent);
  white-space: nowrap;
}
.error-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.error-table tr:last-child td { border-bottom: none; }
.error-table tr:hover td { background: var(--bg-subtle); }

/* FAQ */
.faq-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  margin-bottom: 12px;
  background: var(--bg-card);
}
.faq-item h3 {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 8px;
}
.faq-item .faq-a {
  margin: 0;
  color: var(--text-secondary);
  font-size: .95rem;
}

/* Glossary */
.glossary {
  margin: 18px 0;
}
.glossary dt {
  font-weight: 700;
  font-size: 1rem;
  margin-top: 16px;
  color: var(--accent-strong);
}
.glossary dd {
  margin: 4px 0 0;
  font-size: .95rem;
  color: var(--text-secondary);
}

/* Prev/next */
.article-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.article-nav a {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: .88rem;
  color: var(--text);
  transition: var(--transition);
}
.article-nav a:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-card);
}
.nav-label {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--accent);
  margin-bottom: 4px;
}

.content-foot {
  margin-top: 40px;
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-size: .82rem;
  color: var(--text-secondary);
}

/* 404 */
.page-404 { text-align: center; padding-top: 40px; }
.page-404 .code {
  font-family: var(--font-display);
  font-size: 5rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

/* Loading */
.loading {
  display: flex;
  justify-content: center;
  padding: 80px 0;
}
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 900px) {
  .mobile-menu-btn { display: block; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease-out;
    box-shadow: none;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .sidebar-overlay.show { display: block; }
  .main-content { margin-left: 0; padding: 84px 18px 60px; }
  .home-hero { padding: 32px 24px 28px; }
  .home-hero h1 { font-size: 1.8rem; }
  .content-article h1 { font-size: 1.7rem; }
}

@media (max-width: 600px) {
  body { font-size: 17px; }
  .header-search { max-width: 150px; }
  #search-input { font-size: .85rem; padding-left: 30px; }
  .home-grid { grid-template-columns: 1fr; }
  .article-nav { grid-template-columns: 1fr; }
  .brand-name { font-size: 1.15rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  html { scroll-behavior: auto; }
}

/* Focus visibility */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
