/* === Indeksy — warstwa wizualna === */

:root {
  --bg-0: #0b1020;
  --bg-1: #131a35;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --text: #e7ebff;
  --muted: #9aa3c7;
  --card: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.12);
  /* Stan wypełnienia pól — stałe, niezależne od motywu i palety akcentu */
  --ok: #10b981;                       /* zieleń — pole wypełnione */
  --ok-soft: rgba(16, 185, 129, 0.14);
  --no: #f43f5e;                       /* czerwień — wymagane, puste */
  --no-soft: rgba(244, 63, 94, 0.16);
  --info: #3b82f6;                     /* niebieski — pole opcjonalne */
  --info-soft: rgba(59, 130, 246, 0.16);
}

/* === Motyw „Onyks" — elegancki, nowoczesny: głęboka czerń, wyraziste cienkie obramowania, jaśniejszy tekst === */
html[data-theme="onyks"] {
  --bg-0: #07080c;
  --bg-1: #14161f;
  --text: #f4f6fc;
  --muted: #9aa1b6;
  --card: rgba(255, 255, 255, 0.035);
  --card-border: rgba(255, 255, 255, 0.18);
}
html[data-theme="onyks"] .bg-aurora { opacity: 0.42; filter: saturate(0.72); }
html[data-theme="onyks"] .glass { box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 18px 50px rgba(0, 0, 0, 0.45); }

/* Kolumna wyboru w tabeli indeksów */
.chk-cell { text-align: center; }
.chk-cell input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }

/* Objaśnienia pól (ⓘ) — klikalny dymek z opisem */
.info-wrap { position: relative; display: inline-block; }
.info-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; line-height: 1; padding: 0 3px; }
.info-btn:hover { color: var(--accent-2); }
.info-pop {
  display: none; position: absolute; left: 0; top: calc(100% + 6px); z-index: 50;
  width: max-content; max-width: 280px; white-space: normal;
  background: var(--bg-1); border: 1px solid var(--card-border); border-radius: 10px;
  padding: 10px 12px; font-size: 12px; font-weight: 400; line-height: 1.5; color: var(--text);
  font-family: "Inter", system-ui, sans-serif; text-transform: none; letter-spacing: 0;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}
.info-wrap.open .info-pop { display: block; }

/* Własny dropdown dozwolonych wartości (stepper) */
.combo { position: relative; }
.combo.has-list .pinput { padding-right: 34px; }
.combo-arrow {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 13px; line-height: 1; padding: 6px;
}
.combo-arrow:hover { color: var(--text); }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40;
  max-height: 200px; overflow-y: auto; padding: 4px;
  background: var(--bg-1); border: 1px solid var(--card-border);
  border-radius: 10px; box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
  scrollbar-width: thin; scrollbar-color: var(--card-border) transparent;
}
.combo-list::-webkit-scrollbar { width: 8px; }
.combo-list::-webkit-scrollbar-track { background: transparent; }
.combo-list::-webkit-scrollbar-thumb { background: var(--card-border); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
.combo-opt { padding: 7px 12px; border-radius: 7px; cursor: pointer; font-size: 14px; line-height: 1.25; color: var(--text); }
.combo-opt:hover { background: rgba(255, 255, 255, 0.08); }
.combo-opt[hidden] { display: none; }

/* Karty wyboru motywu (strona Wygląd) */
.theme-card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px; min-width: 200px; flex: 1 1 200px; text-align: left;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 14px; color: var(--text); cursor: pointer;
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}
.theme-card:hover { transform: translateY(-2px); }
.theme-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.theme-prev { height: 54px; border-radius: 10px; }
.theme-card .check { opacity: 0; color: var(--accent-2); font-weight: 800; transition: opacity .2s ease; }
.theme-card.active .check { opacity: 1; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg-0);
  overflow-x: hidden;
}

/* Animowane, ruchome tło z gradientowymi plamami */
.bg-aurora {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(40rem 40rem at 15% 20%, rgba(124, 92, 255, 0.35), transparent 60%),
    radial-gradient(35rem 35rem at 85% 30%, rgba(34, 211, 238, 0.25), transparent 60%),
    radial-gradient(45rem 45rem at 50% 95%, rgba(236, 72, 153, 0.22), transparent 60%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1));
  animation: auroraShift 18s ease-in-out infinite alternate;
}

@keyframes auroraShift {
  0%   { filter: hue-rotate(0deg)   saturate(1);   transform: scale(1); }
  100% { filter: hue-rotate(25deg)  saturate(1.15); transform: scale(1.08); }
}

/* Delikatna siatka na wierzchu */
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 50% 40%, #000 30%, transparent 80%);
}

/* Karta-szkło */
.glass {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 22px;
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.brand {
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Pola formularza */
.field {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}
.field::placeholder { color: var(--muted); }
.field:focus {
  border-color: var(--accent);
  background: rgba(124, 92, 255, 0.08);
  box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.18);
}

.label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 6px 2px;
  letter-spacing: 0.01em;
}

/* Przycisk z efektem */
.btn {
  position: relative;
  width: 100%;
  padding: 14px 18px;
  border: none;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  color: #0b1020;
  cursor: pointer;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 30px rgba(124, 92, 255, 0.4);
  transition: transform 0.15s ease, box-shadow 0.25s ease, filter 0.2s ease;
  overflow: hidden;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 16px 40px rgba(124, 92, 255, 0.55); }
.btn:active { transform: translateY(0) scale(0.99); }

/* Komunikat błędu */
.alert {
  border: 1px solid rgba(255, 99, 132, 0.45);
  background: rgba(255, 99, 132, 0.12);
  color: #ffd5dd;
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 14px;
}

.muted { color: var(--muted); }
a { color: var(--accent-2); }

/* Przyciski dodatkowe */
.btn-sm { width: auto; padding: 9px 16px; font-size: 13px; display: inline-block; text-decoration: none; }
.btn-ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--card-border);
  box-shadow: none;
}
.btn-ghost:hover { box-shadow: none; background: rgba(255, 255, 255, 0.1); }
.btn-danger {
  background: rgba(255, 99, 132, 0.16);
  color: #ffd5dd;
  border: 1px solid rgba(255, 99, 132, 0.4);
  box-shadow: none;
}
.btn-danger:hover { box-shadow: none; background: rgba(255, 99, 132, 0.26); }

/* Chip / etykieta typu */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}
.chip-on  { color: #b9f6ca; border-color: rgba(34, 211, 238, 0.4); background: rgba(34, 211, 238, 0.12); }
.chip-off { color: var(--muted); }

/* Tabela parametrów */
.ptable { width: 100%; border-collapse: collapse; font-size: 14px; }
.ptable th {
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  padding: 8px 10px;
  border-bottom: 1px solid var(--card-border);
}
.ptable td { padding: 10px; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.ptable tr:last-child td { border-bottom: none; }

/* Karta-kafel indeksu (klikalna) */
.tile {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 22px 24px;
  transition: transform 0.18s ease, box-shadow 0.25s ease, border-color 0.25s;
}
.tile:hover { transform: translateY(-3px); border-color: rgba(124, 92, 255, 0.5); }

select.field option { color: #0b1020; }

/* Stepper (kreator indeksu) */
.step { display: grid; grid-template-columns: auto 1fr; gap: 16px; }
.step.hidden { display: none; }
.step-rail { display: flex; flex-direction: column; align-items: center; }
.step-circle {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  border: 2px solid var(--card-border); color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  transition: border-color 0.3s, color 0.3s, background 0.3s, box-shadow 0.3s;
  flex-shrink: 0;
}
.step-line { flex: 1; width: 2px; background: var(--card-border); margin: 6px 0; min-height: 14px; }
.step:last-child .step-line { display: none; }
/* Pole WYPEŁNIONE → zieleń, NIEWYPEŁNIONE → czerwień (te same kolory w każdym motywie/palecie) */
.step.done .step-circle { border-color: var(--ok); color: var(--ok); background: var(--ok-soft); }
.step.done .step-line { background: rgba(16, 185, 129, 0.4); }
.step.current .step-circle { border-color: var(--no); color: #fff; background: rgba(244, 63, 94, 0.26); box-shadow: 0 0 0 4px var(--no-soft); }
.step.done .field:not(:focus)    { border-color: rgba(16, 185, 129, 0.55); }
.step.current .field:not(:focus) { border-color: rgba(244, 63, 94, 0.5); }
/* Pole OPCJONALNE → niebieski (nadrzędne wobec zieleni/czerwieni — brak wartości to nie błąd) */
.step.opt .step-circle { border-color: var(--info); color: var(--info); background: var(--info-soft); box-shadow: none; }
.step.opt .step-line { background: rgba(59, 130, 246, 0.35); }
.step.opt .field:not(:focus) { border-color: rgba(59, 130, 246, 0.5); }
.step-body { padding-bottom: 16px; min-width: 0; }

/* Plakietka z wersją — zawsze widoczna w rogu */
.version-badge {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.version-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 10px var(--accent-2);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.35); opacity: 0.6; }
}

/* Wejście elementów (uzupełniane przez GSAP, fallback gdy brak JS) */
.reveal { opacity: 1; }

/* Wyszukiwarka w stylu Google (zaokrąglony pasek z lupką i czyszczeniem) */
.search { position: relative; width: 100%; }
.search .search-ico {
  position: absolute; left: 18px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--muted); pointer-events: none;
}
.search input {
  width: 100%;
  padding: 14px 46px 14px 48px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.search input::placeholder { color: var(--muted); }
.search input:hover { box-shadow: 0 6px 22px rgba(0, 0, 0, 0.35); }
.search input:focus {
  border-color: var(--accent);
  background: rgba(124, 92, 255, 0.08);
  box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.18), 0 10px 30px rgba(0, 0, 0, 0.4);
}
.search .search-clear {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  border: none; background: transparent; color: var(--muted);
  cursor: pointer; font-size: 14px; line-height: 1;
  width: 28px; height: 28px; border-radius: 50%; display: none;
}
.search .search-clear:hover { color: var(--text); background: rgba(255, 255, 255, 0.08); }
.search.has-text .search-clear { display: flex; align-items: center; justify-content: center; }

/* Ustawienia wyglądu — tryby tła i animacji */
html.no-aurora .bg-aurora { animation: none; }
html.reduce-motion *, html.reduce-motion *::before, html.reduce-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}

/* Próbki kolorów (palety akcentu) */
.swatch-row { display: flex; gap: 14px; flex-wrap: wrap; }
.swatch {
  width: 72px; height: 64px; border-radius: 16px; cursor: pointer;
  border: 2px solid transparent; position: relative;
  transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.swatch:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0,0,0,0.4); }
.swatch.active { border-color: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,0.18); }
.swatch.active::after {
  content: "✓"; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #0b1020; font-weight: 800; font-size: 22px;
}

/* Przełącznik segmentowy */
.seg { display: inline-flex; border: 1px solid var(--card-border); border-radius: 12px; overflow: hidden; }
.seg button {
  padding: 10px 20px; background: transparent; border: none;
  color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.seg button + button { border-left: 1px solid var(--card-border); }
.seg button.active { background: linear-gradient(90deg, var(--accent), var(--accent-2)); color: #0b1020; }

/* Parametry warunkowe (kaskada) — informacja w formularzu */
.cascade-note {
  display: block;
  margin: 0 0 20px;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background: rgba(124, 92, 255, 0.1);
  border: 1px solid rgba(124, 92, 255, 0.35);
  border-left: 3px solid var(--accent);
}
.dep-badge {
  display: inline-block;
  margin: 6px 0 2px;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
}
.dep-parent { color: #b9f6ca; background: rgba(34, 211, 238, 0.12); border: 1px solid rgba(34, 211, 238, 0.4); }
.dep-child  { color: var(--accent); background: rgba(124, 92, 255, 0.12); border: 1px solid rgba(124, 92, 255, 0.4); }

/* Podświetlenie wyszukiwanej frazy */
mark.hl {
  background: linear-gradient(90deg, rgba(124, 92, 255, 0.55), rgba(34, 211, 238, 0.5));
  color: #0b1020;
  font-weight: 700;
  border-radius: 4px;
  padding: 0 3px;
}

/* Powłoka aplikacji: boczna nawigacja + treść */
.app-shell { display: flex; min-height: 100vh; align-items: stretch; }
.sidebar {
  width: 232px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 26px 16px;
  border-right: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.02);
}
.sidebar .brand { font-size: 21px; padding: 0 10px; margin-bottom: 22px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 13px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.06); transform: translateX(2px); }
.nav-link.active {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #0b1020;
  box-shadow: 0 8px 22px rgba(124, 92, 255, 0.35);
}
.sidebar-user {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--card-border);
  margin-bottom: 14px;
}
.nav-group-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
  padding: 16px 14px 6px;
}
.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--card-border); }
.app-main { flex: 1; min-width: 0; padding: 26px 32px 70px; max-width: 1320px; }

/* Ekran powitalny asystenta */
.hero { display:flex; flex-direction:column; align-items:center; text-align:center; padding:60px 20px 40px; gap:14px; }
.hero-avatar {
  width: 68px; height: 68px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0b1020;
  box-shadow: 0 12px 32px rgba(124,92,255,0.45);
}
.hero h1 { margin: 4px 0 0; font-size: 30px; letter-spacing: -0.03em; }
.hero .hero-sub { margin: 0; font-size: 14px; }
.hero-chips { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }
.hero-chip {
  cursor: pointer; border: none;
  padding: 8px 18px; border-radius: 999px;
  background: rgba(255,255,255,0.06); border: 1px solid var(--card-border);
  color: var(--text); font-size: 14px; font-weight: 600;
  transition: background 0.2s, transform 0.15s, border-color 0.2s;
}
.hero-chip:hover { background: rgba(124,92,255,0.18); border-color: var(--accent); transform: translateY(-2px); }
.hero-input-row { display:flex; gap:10px; margin-top:20px; width:100%; max-width:660px; }

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--card-border);
    padding: 14px 16px;
  }
  .sidebar .brand { margin-bottom: 0; }
  .sidebar-footer { margin-top: 0; margin-left: auto; padding-top: 0; border-top: none; display: flex; align-items: center; gap: 10px; }
  .app-main { padding: 20px 18px 50px; }
}
