/* ==========================================================================
   NaviAble - fundament stylów (landing + panel)
   Zasady: kontrast >= 4.5:1 dla tekstu, widoczny focus 4px/2px,
   brak animacji przy prefers-reduced-motion, skala typografii płynna.
   ========================================================================== */

:root {
  --ink: #0b1220;
  --ink-soft: #1e293b;
  --muted: #475569;
  --muted-light: #64748b;
  --line: #d9e1ee;
  --line-strong: #b8c4d8;
  --surface: #ffffff;
  --surface-2: #f5f8fc;
  --surface-3: #eaf0f9;

  --brand: #1d4ed8;
  --brand-dark: #173ea5;
  --brand-soft: #e8efff;
  --accent: #0e7490;
  --accent-soft: #e0f5fa;

  --ok: #116b33;
  --ok-soft: #e7f6ec;
  --warn: #92400e;
  --warn-soft: #fdf1de;
  --danger: #b91c1c;
  --danger-soft: #fdeaea;
  --info: #1d4ed8;
  --info-soft: #e8efff;

  --focus: #1d4ed8;
  --focus-on-dark: #93c5fd;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgb(15 23 42 / 6%);
  --shadow: 0 10px 30px -12px rgb(15 23 42 / 22%);
  --shadow-lg: 0 30px 60px -30px rgb(15 23 42 / 35%);

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --container: 1140px;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4.5rem;
}

/* --- Reset ---------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--ink);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
}

img,
svg {
  max-width: 100%;
  height: auto;
  display: block;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0 0 0.5em;
  line-height: 1.18;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.1rem, 1.2rem + 3.6vw, 3.75rem);
}

h2 {
  font-size: clamp(1.6rem, 1.2rem + 1.7vw, 2.5rem);
}

h3 {
  font-size: clamp(1.15rem, 1rem + 0.6vw, 1.4rem);
}

p {
  margin: 0 0 1em;
  text-wrap: pretty;
}

a {
  color: var(--brand-dark);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1.5px;
}

a:hover {
  color: var(--brand);
}

ul,
ol {
  margin: 0 0 1em;
  padding-left: 1.35em;
}

li + li {
  margin-top: 0.35em;
}

strong {
  color: var(--ink);
  font-weight: 700;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: var(--space-5) 0;
}

/* --- Widoczny focus (WCAG 2.4.11/2.4.13) --------------------------------- */
:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 2px;
  border-radius: 3px;
}

.on-dark :focus-visible,
.on-dark:focus-visible {
  outline-color: var(--focus-on-dark);
}

/* --- Skip link ------------------------------------------------------------ */
.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -100px;
  z-index: 1000;
  padding: 0.75rem 1.1rem;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  border-radius: var(--radius-sm);
  text-decoration: none;
  box-shadow: var(--shadow);
}

.skip-link:focus {
  top: var(--space-4);
  color: #fff;
}

/* --- Marka ---------------------------------------------------------------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 800;
  font-size: 1.08rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.brand:hover {
  color: var(--ink);
  text-decoration: none;
}

.brand img {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 9px;
}

.brand__able {
  color: var(--brand);
}

.on-dark .brand,
.app-sidebar .brand {
  color: #fff;
}

.on-dark .brand:hover,
.app-sidebar .brand:hover {
  color: #fff;
}

.on-dark .brand__able,
.app-sidebar .brand__able {
  color: #7dd3fc;
}

/* --- Układ ----------------------------------------------------------------- */
.container {
  width: min(100% - 2.5rem, var(--container));
  margin-inline: auto;
}

.section {
  padding-block: var(--space-8);
}

.section--tint {
  background: var(--surface-2);
  border-block: 1px solid var(--line);
}

.section__head {
  max-width: 62ch;
  margin-bottom: var(--space-6);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 var(--space-3);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand-dark);
}

.eyebrow::before {
  content: "";
  width: 26px;
  height: 3px;
  border-radius: 2px;
  background: currentColor;
}

.lead {
  font-size: clamp(1.05rem, 0.98rem + 0.35vw, 1.25rem);
  color: var(--muted);
  max-width: 65ch;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.875rem;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --- Przyciski ------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.65rem 1.15rem;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease,
    color 120ms ease, transform 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn--primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.btn--primary:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  color: #fff;
}

.btn--secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
}

.btn--secondary:hover {
  border-color: var(--ink-soft);
  color: var(--ink);
  background: var(--surface-2);
}

.btn--ghost {
  background: transparent;
  color: var(--ink);
  border-color: transparent;
}

.btn--ghost:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.btn--danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn--danger:hover {
  background: #991b1b;
  border-color: #991b1b;
  color: #fff;
}

.btn--on-dark {
  background: #fff;
  color: var(--ink);
  border-color: #fff;
}

.btn--on-dark:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.btn--sm {
  min-height: 36px;
  padding: 0.4rem 0.75rem;
  font-size: 0.875rem;
}

.btn--block {
  width: 100%;
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

/* --- Formularze ------------------------------------------------------------ */
.field {
  margin-bottom: var(--space-5);
}

.field > label,
.field-label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 700;
  color: var(--ink);
}

.field input[type="text"],
.field input[type="url"],
.field input[type="email"],
.field input[type="password"],
.field input[type="search"],
.field input[type="number"],
.field select,
.field textarea {
  width: 100%;
  min-height: 46px;
  padding: 0.6rem 0.8rem;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: var(--muted-light);
}

.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 2px;
  border-color: var(--focus);
}

.field input[aria-invalid="true"],
.field textarea[aria-invalid="true"],
.field select[aria-invalid="true"] {
  border-color: var(--danger);
  background: #fffafa;
}

.field-help {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.field-error {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--danger);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  padding-top: var(--space-2);
}

.checkbox {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
}

.checkbox input {
  width: 20px;
  height: 20px;
  margin-top: 0.25rem;
  accent-color: var(--brand);
  flex: none;
}

.checkbox label {
  font-weight: 600;
}

/* --- Alerty / komunikaty --------------------------------------------------- */
.alert {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.85rem 1rem;
  margin-bottom: var(--space-4);
  border: 1.5px solid var(--line);
  border-left-width: 6px;
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.alert p {
  margin: 0;
}

.alert--success {
  border-color: var(--ok);
  background: var(--ok-soft);
}

.alert--error {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.alert--warning {
  border-color: var(--warn);
  background: var(--warn-soft);
}

.alert--info {
  border-color: var(--info);
  background: var(--info-soft);
}

/* --- Odznaki --------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.badge--ok {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: #b7e2c6;
}

.badge--warn {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: #f0d3a2;
}

.badge--danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #f3c2c2;
}

.badge--info {
  color: var(--info);
  background: var(--info-soft);
  border-color: #c4d4fb;
}

.badge--neutral {
  color: var(--muted);
  background: var(--surface-3);
  border-color: var(--line);
}

.badge--plain::before {
  display: none;
}

/* --- Tabele --------------------------------------------------------------- */
.table-wrap {
  position: relative;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.table-wrap:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 2px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.945rem;
}

.data-table caption {
  padding: 0.9rem 1rem;
  text-align: left;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.data-table th,
.data-table td {
  padding: 0.8rem 1rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
}

.data-table thead th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  background: var(--surface-2);
  white-space: nowrap;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover {
  background: #fafcff;
}

.data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table code {
  white-space: nowrap;
}

.nowrap {
  white-space: nowrap;
}

.text-danger {
  color: var(--danger);
  font-weight: 600;
}

.data-table .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
}

/* --- Kod ------------------------------------------------------------------ */
code,
kbd,
samp {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

:not(pre) > code {
  padding: 0.15em 0.4em;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

pre {
  margin: 0;
  padding: var(--space-4);
  overflow: auto;
  background: #0b1220;
  color: #e2e8f0;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  tab-size: 2;
}

pre:focus-visible {
  outline: 4px solid var(--focus-on-dark);
  outline-offset: 2px;
}

pre code {
  color: inherit;
  font-size: inherit;
}

/* --- Karty ---------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.card__title {
  margin-bottom: var(--space-2);
  font-size: 1.2rem;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.card__head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
}

.card__head h2,
.card__head h3 {
  margin: 0;
}

/* --- Os czasu -------------------------------------------------------------- */
.timeline {
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline__item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 0.35rem 0.75rem;
  align-items: start;
  padding: 0.7rem 0;
  margin: 0;
  border-bottom: 1px solid var(--line);
}

.timeline__item:last-child {
  border-bottom: 0;
}

.timeline__dot {
  position: relative;
  display: block;
  width: 11px;
  height: 11px;
  margin: 0.42rem auto 0;
  border-radius: 50%;
  background: var(--muted-light);
  box-shadow: 0 0 0 4px var(--surface-3);
}

.timeline__item--ready .timeline__dot { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.timeline__item--failed .timeline__dot { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.timeline__item--queued .timeline__dot,
.timeline__item--processing .timeline__dot { background: var(--info); box-shadow: 0 0 0 4px var(--info-soft); }
.timeline__item--manual_edit .timeline__dot,
.timeline__item--activated .timeline__dot { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }

.timeline__text {
  margin: 0;
  font-size: 0.92rem;
}

.timeline__text strong {
  font-weight: 700;
}

.timeline__message {
  margin: 0.15rem 0 0;
  font-size: 0.84rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.timeline__time {
  grid-column: 2;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

/* --- Hasło z podglądem ----------------------------------------------------- */
.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 5.2rem;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.45rem;
  transform: translateY(-50%);
  min-height: 34px;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.password-toggle:hover {
  border-color: var(--ink-soft);
  background: var(--surface-3);
}

/* --- Ruch ----------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* --- Druk ----------------------------------------------------------------- */
@media print {
  .skip-link,
  .btn,
  .app-sidebar,
  .app-topbar {
    display: none !important;
  }
}
