/* ============================================================
   ZMIENNE
   ============================================================ */
:root {
  --bg: #0f1115;
  --bg-2: #161a22;
  --bg-3: #1e2430;
  --border: #2a3242;
  --text: #e8ecf3;
  --text-dim: #8b95a7;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-glow: rgba(99, 102, 241, 0.4);
  --success: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background-image:
    radial-gradient(circle at 15% 10%, rgba(99, 102, 241, 0.15), transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(139, 92, 246, 0.12), transparent 40%);
  background-attachment: fixed;
}

/* ============================================================
   HEADER
   ============================================================ */
header {
  padding: 22px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  background: rgba(15, 17, 21, 0.7);
  position: sticky;
  top: 0;
  z-index: 50;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.logo-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  box-shadow: 0 0 20px var(--accent-glow);
  font-size: 20px;
}

.header-actions { display: flex; gap: 10px; align-items: center; }

/* ============================================================
   LAYOUT
   ============================================================ */
main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  padding: 32px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

main.with-panel { grid-template-columns: minmax(0, 1fr) 380px; }

.left-col {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

@media (max-width: 980px) {
  main.with-panel { grid-template-columns: 1fr; }
}

/* ============================================================
   KARTA WPROWADZANIA
   ============================================================ */
.input-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-row { display: flex; gap: 12px; flex-wrap: wrap; }

.input-wrapper { flex: 1; min-width: 240px; position: relative; }

.input-wrapper::before {
  content: "🔗";
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  opacity: 0.6;
  pointer-events: none;
}

#linkInput {
  width: 100%;
  padding: 16px 16px 16px 48px;
  font-size: 1.05rem;
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: all 0.2s;
  font-family: inherit;
}

#linkInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#linkInput::placeholder { color: var(--text-dim); }

/* ============================================================
   PRZYCISKI
   ============================================================ */
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  font-weight: 600;
}

.btn {
  padding: 14px 22px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px var(--accent-glow); }

.btn-ghost { background: var(--bg-3); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: #252c3a; border-color: #37415a; }

.btn-icon {
  padding: 10px 14px;
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.btn-icon:hover { background: #252c3a; }

.btn-danger { background: transparent; color: var(--danger); border: 1px solid #3a2226; }
.btn-danger:hover { background: rgba(239, 68, 68, 0.1); }

/* ============================================================
   PRESETY
   ============================================================ */
.presets { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.presets-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-right: 4px;
}

.preset-chip {
  padding: 8px 14px;
  font-size: 0.82rem;
  background: var(--bg-3);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
}

.preset-chip:hover {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
}

/* ============================================================
   PODGLĄD
   ============================================================ */
.preview-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 32px 24px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 400px;
  position: relative;
}

#qrStage {
  position: relative;
  display: none;
  padding: 24px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  max-width: 100%;
}

#qrStage.visible { display: block; }

#qrStage canvas,
#qrStage img {
  display: block;
  width: min(60vmin, 480px) !important;
  height: min(60vmin, 480px) !important;
  image-rendering: pixelated;
  border-radius: 8px;
}

.link-display {
  font-size: 0.9rem;
  color: var(--text-dim);
  word-break: break-all;
  text-align: center;
  max-width: 100%;
  padding: 10px 16px;
  background: var(--bg-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.placeholder {
  text-align: center;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 20px;
}

.placeholder-icon { font-size: 3.5rem; opacity: 0.4; }
.placeholder-hint { font-size: 0.8rem; }

/* ============================================================
   PASEK „ZASTOSUJ"
   ============================================================ */
.apply-bar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.15));
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: var(--radius);
  flex-wrap: wrap;
  justify-content: center;
  animation: slideUp 0.25s ease-out;
}

.apply-bar.show { display: flex; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.apply-bar-text {
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 600;
}

.btn-apply {
  padding: 10px 20px;
  background: var(--success);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
}

.btn-apply:hover { background: #0ea371; transform: translateY(-1px); }

.btn-cancel {
  padding: 10px 18px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
}

.btn-cancel:hover { color: var(--text); border-color: #3a4252; }

/* ============================================================
   PANEL ZAAWANSOWANY
   ============================================================ */
.panel {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  position: sticky;
  top: 100px;
  display: none;
}

.panel.open { display: block; }

.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.panel-section { border-bottom: 1px solid var(--border); padding: 20px 22px; }
.panel-section:last-child { border-bottom: none; }

.panel-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }

.field-label {
  font-size: 0.85rem;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.field-value {
  color: var(--accent-2);
  font-family: ui-monospace, monospace;
  font-size: 0.82rem;
  font-weight: 600;
}

.field-hint {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 12px;
  line-height: 1.5;
  padding: 10px 12px;
  background: rgba(99, 102, 241, 0.05);
  border-left: 2px solid var(--accent);
  border-radius: 4px;
}

/* ============================================================
   FORMULARZE
   ============================================================ */
select, input[type="number"], input[type="text"], input[type="email"], input[type="tel"], input[type="url"] {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  font-family: inherit;
  font-size: 0.9rem;
  transition: all 0.15s;
}

select:focus, input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  background: var(--bg-3);
  border-radius: 3px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 10px var(--accent-glow);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

/* ============================================================
   KOLORY
   ============================================================ */
.color-row { display: flex; align-items: center; gap: 12px; }

input[type="color"] {
  width: 48px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-3);
  cursor: pointer;
  padding: 4px;
}

input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 4px; }

.color-hex {
  flex: 1;
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
  color: var(--text-dim);
  padding: 8px 12px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* ============================================================
   TOGGLE
   ============================================================ */
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; }

.toggle-label { font-size: 0.85rem; }

.toggle {
  position: relative;
  width: 42px;
  height: 24px;
  background: var(--bg-3);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: all 0.2s;
}

.toggle.on {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
}

.toggle.on::after { left: 21px; background: #fff; }

/* ============================================================
   UPLOAD
   ============================================================ */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg-3);
}

.upload-zone:hover {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(99, 102, 241, 0.05);
}

.upload-zone.has-file { border-color: var(--success); color: var(--success); }

.upload-icon { font-size: 1.5rem; margin-bottom: 6px; }
.upload-hint { font-size: 0.75rem; margin-top: 4px; }

/* ============================================================
   EKSPORT
   ============================================================ */
.export-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.btn-export {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 16px 18px;
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: left;
  transition: all 0.15s;
}

.btn-export:hover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.08);
  transform: translateY(-1px);
}

.export-format {
  font-family: ui-monospace, monospace;
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent-2);
  letter-spacing: 0.05em;
}

.export-desc {
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.35;
  font-weight: 400;
}

.btn-export {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
}

.export-format {
  font-size: 0.95rem;
  flex-shrink: 0;
}

.export-desc {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-align: right;
  flex: 1;
  min-width: 0;
  line-height: 1.3;
}

/* ============================================================
   PEŁNY EKRAN
   ============================================================ */
body.fs-mode main,
body.fs-mode header,
body.fs-mode .hint-bar { display: none !important; }

#fsView {
  display: none;
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 20px;
  cursor: pointer;
}

#fsView.active { display: flex; }

#fsView .fs-stage {
  background: #fff;
  padding: 30px;
  border-radius: 20px;
  display: inline-block;
}

#fsView canvas, #fsView img {
  display: block;
  width: 85vmin !important;
  height: 85vmin !important;
  image-rendering: pixelated;
}

#fsView .fs-hint {
  position: fixed;
  bottom: 20px;
  color: #888;
  font-size: 0.85rem;
  background: rgba(255,255,255,0.9);
  padding: 8px 16px;
  border-radius: 8px;
}

/* ============================================================
   HINT BAR
   ============================================================ */
.hint-bar {
  text-align: center;
  padding: 16px;
  font-size: 0.82rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  background: rgba(15, 17, 21, 0.6);
}

kbd {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  color: var(--text);
}

/* ============================================================
   TOAST
   ============================================================ */
#toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-3);
  color: var(--text);
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  opacity: 0;
  transition: all 0.3s;
  z-index: 2000;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

.toast-icon { font-size: 1.1rem; }

/* ============================================================
   ZAKŁADKI
   ============================================================ */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg-3);
  position: sticky;
  top: 0;
  z-index: 5;
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
}

.tab {
  flex: 1;
  padding: 14px 8px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  background: transparent;
  border-radius: 0;
  font-weight: 600;
}

.tab:hover { color: var(--text); }

.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  background: rgba(99, 102, 241, 0.08);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============================================================
   ANIMACJE
   ============================================================ */
@keyframes popIn {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

#qrStage.visible { animation: popIn 0.3s ease-out; }

/* ============================================================
   RESPONSYWNOŚĆ
   ============================================================ */
@media (max-width: 720px) {
  header { padding: 14px 18px; }
  main { padding: 20px 16px; }
  .input-card { padding: 18px; }
  .preview-area { padding: 24px 16px; }
  .export-grid { grid-template-columns: 1fr; }
}