/* ==========================================================================
   Linis Scraper — wspólny stylesheet dla wszystkich podstron.
   Pełny system motywów: light / dark / system.
   ========================================================================== */

/* ── Light palette (default) ──────────────────────────────────────────── */
:root {
  --bg:           #f0f4f8;
  --bg-accent:    #e2eaf3;
  --card:         #ffffff;
  --card-soft:    #f5f8ff;
  --line:         #c8d5e8;
  --text:         #0f2540;
  --muted:        #5a7492;
  --text-muted:   #5a7492;
  --accent:       #1a6fd4;
  --accent-hover: #1259bc;
  --accent-soft:  rgba(26,111,212,0.12);
  --primary:      #1a6fd4;
  --primary-hover:#1259bc;
  --secondary:    #e0e8f4;
  --success:      #0a9068;
  --danger:       #dc2626;
  --error:        #dc2626;
  --warning:      #b45309;
  --border:       #c8d5e8;
  /* Component tokens */
  --body-bg: linear-gradient(180deg, #f0f4f8 0%, #e6edf5 100%);
  --body-orbs: radial-gradient(circle at top left, rgba(26,111,212,0.07), transparent 34%),
               radial-gradient(circle at top right, rgba(10,144,104,0.05), transparent 28%);
  --card-bg-soft: linear-gradient(180deg, rgba(255,255,255,0.97) 0%, rgba(248,251,255,0.97) 100%);
  --card-shadow: 0 2px 12px rgba(15,37,64,0.07);
  --nav-link-clr: #2a4a6e;
  --label-clr:    #2a4a6e;
  --input-bg:     #f8faff;
  --th-clr:       #2a4a6e;
  --th-bg:        rgba(0,0,0,0.02);
  --tr-hover:     rgba(0,0,0,0.025);
  --code-bg:      rgba(100,130,180,0.10);
  --aside-bg:     linear-gradient(180deg,rgba(240,244,250,0.98) 0%,rgba(230,237,245,0.98) 100%);
  --panel-bg:     rgba(200,213,232,0.25);
  --panel-border: rgba(100,130,180,0.18);
  --btn-sec-bg:   rgba(0,0,0,0.04);
  --btn-sec-hover:rgba(0,0,0,0.08);
  --border-subtle:rgba(0,0,0,0.08);
  --link-clr:     #1a6fd4;
  --progress-track: rgba(0,0,0,0.08);
}

/* ── Forced light (wins over media query) ─────────────────────────────── */
html.light {
  --bg:           #f0f4f8;
  --bg-accent:    #e2eaf3;
  --card:         #ffffff;
  --card-soft:    #f5f8ff;
  --line:         #c8d5e8;
  --text:         #0f2540;
  --muted:        #5a7492;
  --text-muted:   #5a7492;
  --accent:       #1a6fd4;
  --accent-hover: #1259bc;
  --accent-soft:  rgba(26,111,212,0.12);
  --primary:      #1a6fd4;
  --primary-hover:#1259bc;
  --secondary:    #e0e8f4;
  --success:      #0a9068;
  --danger:       #dc2626;
  --error:        #dc2626;
  --warning:      #b45309;
  --border:       #c8d5e8;
  --body-bg: linear-gradient(180deg, #f0f4f8 0%, #e6edf5 100%);
  --body-orbs: radial-gradient(circle at top left, rgba(26,111,212,0.07), transparent 34%),
               radial-gradient(circle at top right, rgba(10,144,104,0.05), transparent 28%);
  --card-bg-soft: linear-gradient(180deg, rgba(255,255,255,0.97) 0%, rgba(248,251,255,0.97) 100%);
  --card-shadow: 0 2px 12px rgba(15,37,64,0.07);
  --nav-link-clr: #2a4a6e;
  --label-clr:    #2a4a6e;
  --input-bg:     #f8faff;
  --th-clr:       #2a4a6e;
  --th-bg:        rgba(0,0,0,0.02);
  --tr-hover:     rgba(0,0,0,0.025);
  --code-bg:      rgba(100,130,180,0.10);
  --aside-bg:     linear-gradient(180deg,rgba(240,244,250,0.98) 0%,rgba(230,237,245,0.98) 100%);
  --panel-bg:     rgba(200,213,232,0.25);
  --panel-border: rgba(100,130,180,0.18);
  --btn-sec-bg:   rgba(0,0,0,0.04);
  --btn-sec-hover:rgba(0,0,0,0.08);
  --border-subtle:rgba(0,0,0,0.08);
  --link-clr:     #1a6fd4;
  --progress-track: rgba(0,0,0,0.08);
}

/* ── Dark palette (system) ────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:           #07111f;
    --bg-accent:    #091626;
    --card:         #102038;
    --card-soft:    #152947;
    --line:         #2f4769;
    --text:         #edf4ff;
    --muted:        #9eb2d0;
    --text-muted:   #9eb2d0;
    --accent:       #2f88ff;
    --accent-hover: #1d6fe0;
    --accent-soft:  rgba(47,136,255,0.16);
    --primary:      #2f88ff;
    --primary-hover:#1d6fe0;
    --secondary:    #334a67;
    --success:      #0fb981;
    --danger:       #ef4444;
    --error:        #ef4444;
    --warning:      #f59e0b;
    --border:       #2f4769;
    --body-bg: linear-gradient(180deg,#07111f 0%,#091626 100%);
    --body-orbs: radial-gradient(circle at top left,rgba(47,136,255,0.18),transparent 34%),
                 radial-gradient(circle at top right,rgba(15,185,129,0.16),transparent 28%);
    --card-bg-soft: linear-gradient(180deg,rgba(16,32,56,0.96) 0%,rgba(12,24,42,0.96) 100%);
    --card-shadow: 0 16px 40px rgba(4,10,20,0.28);
    --nav-link-clr: #c7d8ee;
    --label-clr:    #d7e4f8;
    --input-bg:     #091524;
    --th-clr:       #dbeafe;
    --th-bg:        rgba(255,255,255,0.02);
    --tr-hover:     rgba(255,255,255,0.025);
    --code-bg:      rgba(148,163,184,0.12);
    --aside-bg:     linear-gradient(180deg,rgba(16,32,56,0.96) 0%,rgba(12,24,42,0.96) 100%);
    --panel-bg:     rgba(15,23,42,0.55);
    --panel-border: rgba(159,182,215,0.16);
    --btn-sec-bg:   rgba(255,255,255,0.04);
    --btn-sec-hover:rgba(255,255,255,0.08);
    --border-subtle:rgba(159,182,215,0.12);
    --link-clr:     #7db6ff;
    --progress-track: rgba(255,255,255,0.07);
  }
}

/* ── Forced dark ──────────────────────────────────────────────────────── */
html.dark {
  --bg:           #07111f;
  --bg-accent:    #091626;
  --card:         #102038;
  --card-soft:    #152947;
  --line:         #2f4769;
  --text:         #edf4ff;
  --muted:        #9eb2d0;
  --text-muted:   #9eb2d0;
  --accent:       #2f88ff;
  --accent-hover: #1d6fe0;
  --accent-soft:  rgba(47,136,255,0.16);
  --primary:      #2f88ff;
  --primary-hover:#1d6fe0;
  --secondary:    #334a67;
  --success:      #0fb981;
  --danger:       #ef4444;
  --error:        #ef4444;
  --warning:      #f59e0b;
  --border:       #2f4769;
  --body-bg: linear-gradient(180deg,#07111f 0%,#091626 100%);
  --body-orbs: radial-gradient(circle at top left,rgba(47,136,255,0.18),transparent 34%),
               radial-gradient(circle at top right,rgba(15,185,129,0.16),transparent 28%);
  --card-bg-soft: linear-gradient(180deg,rgba(16,32,56,0.96) 0%,rgba(12,24,42,0.96) 100%);
  --card-shadow: 0 16px 40px rgba(4,10,20,0.28);
  --nav-link-clr: #c7d8ee;
  --label-clr:    #d7e4f8;
  --input-bg:     #091524;
  --th-clr:       #dbeafe;
  --th-bg:        rgba(255,255,255,0.02);
  --tr-hover:     rgba(255,255,255,0.025);
  --code-bg:      rgba(148,163,184,0.12);
  --aside-bg:     linear-gradient(180deg,rgba(16,32,56,0.96) 0%,rgba(12,24,42,0.96) 100%);
  --panel-bg:     rgba(15,23,42,0.55);
  --panel-border: rgba(159,182,215,0.16);
  --btn-sec-bg:   rgba(255,255,255,0.04);
  --btn-sec-hover:rgba(255,255,255,0.08);
  --border-subtle:rgba(159,182,215,0.12);
  --link-clr:     #7db6ff;
  --progress-track: rgba(255,255,255,0.07);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  color: var(--text);
  line-height: 1.5;
  background: var(--body-orbs), var(--body-bg);
  background-attachment: fixed;
}

a { color: var(--link-clr); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin-top: 0; color: var(--text); }
h1 { margin-bottom: 4px; font-size: 1.5rem; }
h2 { font-size: 1.15rem; margin-bottom: 12px; }
h3 { font-size: 1rem; margin-bottom: 10px; }

.container { max-width: 1200px; margin: 0 auto; padding: 24px 20px; }
.container-wide { max-width: 1800px; }
.container-narrow { max-width: 880px; }

/* ── Header / nav ─────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.app-header h1 { font-size: 1.4rem; }
.nav-links { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.nav-links a {
  color: var(--nav-link-clr);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.92rem;
  padding: 4px 2px;
}
.nav-links a:hover { color: var(--accent); text-decoration: none; }

/* ── Cards ────────────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg-soft);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--card-shadow);
}
.card-tight { padding: 12px 16px; }

.muted, .text-muted { color: var(--muted); }
.subtitle { color: var(--muted); margin: 0 0 14px; max-width: 900px; line-height: 1.45; font-size: 0.9rem; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 14px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
button:hover, .btn:hover { background: var(--accent-hover); }
button:disabled, .btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }

button.secondary, .btn-secondary, .btn-outline {
  background: var(--btn-sec-bg);
  color: var(--text);
  border-color: var(--line);
}
button.secondary:hover, .btn-secondary:hover, .btn-outline:hover {
  background: var(--btn-sec-hover);
  border-color: var(--accent);
}

button.success, .btn-success { background: var(--success); }
button.success:hover, .btn-success:hover { filter: brightness(0.9); }

button.danger, .btn-danger {
  background: rgba(220, 38, 38, 0.12);
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.35);
}
html.dark button.danger, html.dark .btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.45);
}
@media (prefers-color-scheme: dark) {
  button.danger, .btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.45);
  }
}
html.light button.danger, html.light .btn-danger {
  background: rgba(220, 38, 38, 0.12);
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.35);
}
button.danger:hover, .btn-danger:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

/* ── Forms ────────────────────────────────────────────────────────────── */
label { font-size: 0.8rem; color: var(--label-clr); font-weight: 500; }
input[type="text"], input[type="email"], input[type="password"],
input[type="search"], input[type="number"], input[type="file"],
select, textarea {
  width: 100%;
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
  font-family: inherit;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
select { cursor: pointer; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }

/* ── Flash ────────────────────────────────────────────────────────────── */
.flash {
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 14px;
  border: 1px solid transparent;
  font-size: 0.9rem;
}
.flash.error, .flash.danger {
  background: rgba(220, 38, 38, 0.10);
  border-color: rgba(220, 38, 38, 0.35);
  color: #991b1b;
}
html.dark .flash.error, html.dark .flash.danger {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.42);
  color: #fecaca;
}
@media (prefers-color-scheme: dark) {
  .flash.error, .flash.danger {
    background: rgba(239, 68, 68, 0.16);
    border-color: rgba(239, 68, 68, 0.42);
    color: #fecaca;
  }
}
html.light .flash.error, html.light .flash.danger {
  background: rgba(220, 38, 38, 0.10);
  border-color: rgba(220, 38, 38, 0.35);
  color: #991b1b;
}

.flash.success {
  background: rgba(10, 144, 104, 0.10);
  border-color: rgba(10, 144, 104, 0.35);
  color: #065f46;
}
html.dark .flash.success {
  background: rgba(15, 185, 129, 0.16);
  border-color: rgba(15, 185, 129, 0.42);
  color: #bbf7d0;
}
@media (prefers-color-scheme: dark) {
  .flash.success {
    background: rgba(15, 185, 129, 0.16);
    border-color: rgba(15, 185, 129, 0.42);
    color: #bbf7d0;
  }
}
html.light .flash.success {
  background: rgba(10, 144, 104, 0.10);
  border-color: rgba(10, 144, 104, 0.35);
  color: #065f46;
}

.flash.info, .flash.message {
  background: rgba(26, 111, 212, 0.08);
  border-color: rgba(26, 111, 212, 0.30);
  color: #1e40af;
}
html.dark .flash.info, html.dark .flash.message {
  background: rgba(47, 136, 255, 0.12);
  border-color: rgba(47, 136, 255, 0.35);
  color: #c7d8ee;
}
@media (prefers-color-scheme: dark) {
  .flash.info, .flash.message {
    background: rgba(47, 136, 255, 0.12);
    border-color: rgba(47, 136, 255, 0.35);
    color: #c7d8ee;
  }
}
html.light .flash.info, html.light .flash.message {
  background: rgba(26, 111, 212, 0.08);
  border-color: rgba(26, 111, 212, 0.30);
  color: #1e40af;
}

.flash.warning {
  background: rgba(180, 83, 9, 0.08);
  border-color: rgba(180, 83, 9, 0.30);
  color: #92400e;
}
html.dark .flash.warning {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.35);
  color: #fcd34d;
}
@media (prefers-color-scheme: dark) {
  .flash.warning {
    background: rgba(245, 158, 11, 0.14);
    border-color: rgba(245, 158, 11, 0.35);
    color: #fcd34d;
  }
}
html.light .flash.warning {
  background: rgba(180, 83, 9, 0.08);
  border-color: rgba(180, 83, 9, 0.30);
  color: #92400e;
}

/* ── Tables ───────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  border-bottom: 1px solid var(--border-subtle);
  padding: 10px 9px;
  text-align: left;
  vertical-align: top;
  font-size: 0.85rem;
}
th {
  color: var(--th-clr);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  background: var(--th-bg);
  white-space: nowrap;
}
tbody tr:hover { background: var(--tr-hover); }

/* ── Badges & pills ──────────────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.74rem;
  white-space: nowrap;
}
html.dark .pill { color: #dbeafe; }
@media (prefers-color-scheme: dark) { .pill { color: #dbeafe; } }
html.light .pill { color: var(--accent); }

.badge {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.badge-running { background: rgba(26,111,212,0.15); color: #1a6fd4; }
.badge-queued  { background: rgba(90,116,139,0.15); color: #5a7292; }
.badge-done    { background: rgba(10,144,104,0.15); color: #0a9068; }
.badge-failed  { background: rgba(220,38,38,0.15);  color: #dc2626; }
.badge-cancelled   { background: rgba(180,83,9,0.14); color: #b45309; }
.badge-interrupted { background: rgba(180,83,9,0.14); color: #b45309; }

html.dark .badge-running { background: rgba(47,136,255,0.18); color: #7db6ff; }
html.dark .badge-queued  { background: rgba(100,116,139,0.22); color: #94a3b8; }
html.dark .badge-done    { background: rgba(15,185,129,0.18); color: #34d399; }
html.dark .badge-failed  { background: rgba(239,68,68,0.18);  color: #f87171; }
html.dark .badge-cancelled   { background: rgba(245,158,11,0.16); color: #fbbf24; }
html.dark .badge-interrupted { background: rgba(245,158,11,0.16); color: #fbbf24; }

@media (prefers-color-scheme: dark) {
  .badge-running { background: rgba(47,136,255,0.18); color: #7db6ff; }
  .badge-queued  { background: rgba(100,116,139,0.22); color: #94a3b8; }
  .badge-done    { background: rgba(15,185,129,0.18); color: #34d399; }
  .badge-failed  { background: rgba(239,68,68,0.18);  color: #f87171; }
  .badge-cancelled   { background: rgba(245,158,11,0.16); color: #fbbf24; }
  .badge-interrupted { background: rgba(245,158,11,0.16); color: #fbbf24; }
}

html.light .badge-running { background: rgba(26,111,212,0.15); color: #1a6fd4; }
html.light .badge-queued  { background: rgba(90,116,139,0.15); color: #5a7292; }
html.light .badge-done    { background: rgba(10,144,104,0.15); color: #0a9068; }
html.light .badge-failed  { background: rgba(220,38,38,0.15);  color: #dc2626; }
html.light .badge-cancelled   { background: rgba(180,83,9,0.14); color: #b45309; }
html.light .badge-interrupted { background: rgba(180,83,9,0.14); color: #b45309; }

/* ── Progress ─────────────────────────────────────────────────────────── */
.progress, .progress-mini {
  width: 100%;
  height: 14px;
  background: var(--progress-track);
  border-radius: 999px;
  overflow: hidden;
}
.progress-mini { width: 140px; height: 7px; }
.progress-bar, .progress-mini-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s ease;
  min-width: 3px;
}

/* ── Misc ─────────────────────────────────────────────────────────────── */
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.error-box {
  border-left: 3px solid var(--danger);
  background: rgba(220,38,38,0.08);
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
  margin-top: 10px;
  font-family: ui-monospace, SFMono-Regular, "Courier New", monospace;
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--danger);
}
html.dark .error-box {
  background: rgba(239,68,68,0.1);
  color: #fca5a5;
}
@media (prefers-color-scheme: dark) {
  .error-box { background: rgba(239,68,68,0.1); color: #fca5a5; }
}
html.light .error-box {
  background: rgba(220,38,38,0.08);
  color: var(--danger);
}

.meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem 1.5rem;
  margin-top: 1rem;
}
.meta div { font-size: 0.9rem; }
.meta strong {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
  font-weight: 600;
}
code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, "Courier New", monospace;
  font-size: 0.85em;
}

/* ── Auth split layout ────────────────────────────────────────────────── */
.auth-shell {
  min-height: calc(100vh - 48px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-grid {
  width: min(100%, 960px);
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 22px;
}
.auth-grid > .card,
.auth-grid > .aside { padding: 28px; margin-bottom: 0; }
.aside {
  background: var(--aside-bg);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--card-shadow);
}
.panel {
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  margin-bottom: 14px;
}
.panel h3 { margin: 0 0 8px; font-size: 0.95rem; }
.panel p, .panel ul {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}
.panel ul { padding-left: 18px; margin-top: 8px; }
.stack { display: grid; gap: 14px; }
.top-link { color: var(--link-clr); text-decoration: none; font-weight: 600; }
.top-link:hover { text-decoration: underline; }

/* ── Theme switcher widget ────────────────────────────────────────────── */
.theme-sw {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}
.theme-sw button {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 5px 8px;
  font-size: 14px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.theme-sw button:hover { color: var(--text); background: var(--btn-sec-hover); }
.theme-sw button.active { background: var(--accent); color: white; }
.theme-sw button + button { border-left: 1px solid var(--line); }

@media (max-width: 880px) {
  .auth-grid { grid-template-columns: 1fr; }
}
