/* ---- Tokens (light defaults) ---- */
:root {
  --primary: #2563EB;
  --primary-hover: #1D4FD7;
  --primary-soft: #DBEAFE;
  --on-primary: #FFFFFF;
  --accent: #D97706;
  --accent-soft: #FEF3C7;

  --bg: #F8FAFC;
  --bg-grad-1: #F8FAFC;
  --bg-grad-2: #EEF2FB;

  --surface: #FFFFFF;
  --surface-2: #F1F5FD;
  --muted: #F1F5FD;

  --fg: #0F172A;
  --fg-muted: #475569;
  --fg-subtle: #64748B;

  --border: #E4ECFC;
  --border-strong: #CBD5E1;

  --destructive: #DC2626;
  --destructive-soft: #FEE2E2;
  --success: #15803D;
  --success-soft: #DCFCE7;
  --warning: #B45309;
  --warning-soft: #FEF3C7;

  --ring: #2563EB;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px -8px rgba(15, 23, 42, 0.10), 0 4px 12px -4px rgba(15, 23, 42, 0.05);

  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --gap: 16px;

  --qr-fg: #0F172A;
  --qr-bg: #FFFFFF;

  color-scheme: light;
}

/* ---- Tokens (dark - os tema'ya gore) ---- */
@media (prefers-color-scheme: dark) {
  :root {
    --primary: #60A5FA;
    --primary-hover: #93BBFC;
    --primary-soft: #1E2A4A;
    --on-primary: #0B1220;
    --accent: #FBBF24;
    --accent-soft: #3A2F0F;

    --bg: #0B0F17;
    --bg-grad-1: #0B0F17;
    --bg-grad-2: #131A28;

    --surface: #131A28;
    --surface-2: #1A2233;
    --muted: #1A2233;

    --fg: #E6EAF2;
    --fg-muted: #97A3BC;
    --fg-subtle: #6B7689;

    --border: #232D44;
    --border-strong: #354160;

    --destructive: #F87171;
    --destructive-soft: #3B1414;
    --success: #4ADE80;
    --success-soft: #14361F;
    --warning: #FBBF24;
    --warning-soft: #3A2F0F;

    --ring: #93BBFC;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.45), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 40px -12px rgba(0, 0, 0, 0.6), 0 6px 16px -6px rgba(0, 0, 0, 0.4);

    --qr-fg: #E6EAF2;
    --qr-bg: #131A28;

    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { height: 100%; }
body {
  margin: 0; padding: 0;
  background:
    radial-gradient(1200px 600px at 50% -100px, var(--primary-soft), transparent 60%),
    linear-gradient(180deg, var(--bg-grad-1), var(--bg-grad-2));
  background-attachment: fixed;
  color: var(--fg);
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color 0.25s ease, color 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

main {
  width: 100%;
  max-width: 580px;
  margin: auto; /* flex center'da hem dikey hem yatay merkez, icerik tasarsa otomatik scroll */
  padding: 48px 20px 56px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* ---- Hero ---- */
.hero { text-align: center; margin-bottom: 8px; }
.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(28px, 5vw, 36px);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.1;
  color: var(--fg);
  background: linear-gradient(135deg, var(--fg) 0%, var(--primary) 130%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero .sub {
  margin: 0 auto 14px;
  max-width: 440px;
  color: var(--fg-muted);
  font-size: 16px;
  line-height: 1.5;
}
.hero .meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--fg-muted);
  background: var(--surface);
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.meta-icon { width: 13px; height: 13px; color: var(--primary); flex-shrink: 0; }

/* ---- Card ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-md);
}
.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}
.card-head h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
  flex: 1;
}
.hidden { display: none !important; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  min-height: 44px;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease,
              box-shadow .15s ease, transform .08s ease;
  user-select: none;
  touch-action: manipulation;
  letter-spacing: -0.005em;
}
.btn:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
.btn:active:not(:disabled) { transform: scale(0.975); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.primary {
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.12);
}
.btn.primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.15);
}

.btn.outline {
  background: var(--surface);
  color: var(--fg);
  border-color: var(--border-strong);
}
.btn.outline:hover:not(:disabled) {
  background: var(--muted);
  border-color: var(--primary);
  color: var(--primary);
}

.btn.ghost { padding: 8px; min-height: 36px; color: var(--fg-muted); }
.btn.ghost:hover:not(:disabled) { background: var(--muted); color: var(--fg); }

.btn.big {
  width: 100%;
  padding: 18px;
  font-size: 16px;
  border-radius: 12px;
}
.btn.full { width: 100%; }
.btn-icon { width: 18px; height: 18px; flex-shrink: 0; }
.btn.big .btn-icon { width: 20px; height: 20px; }
.icon-btn { padding: 10px 14px; }
.icon-btn .btn-label { font-size: 14px; }
.back { width: 36px; height: 36px; padding: 0; }

.landing { display: flex; flex-direction: column; gap: 10px; }

/* Spinner */
.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Labels ---- */
.label {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-subtle);
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---- Link / code box ---- */
.code-box {
  display: flex;
  gap: 6px;
  align-items: stretch;
  background: var(--surface-2);
  padding: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}
.code-box code {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;
  font-size: 12.5px;
  word-break: break-all;
  user-select: all;
  color: var(--fg);
  min-width: 0;
}

/* ---- QR ---- */
.qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px;
  background: var(--qr-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.qr-box canvas {
  display: block;
  width: 180px;
  height: 180px;
  image-rendering: pixelated;
  border-radius: 4px;
}
.qr-hint {
  margin: 0;
  font-size: 12px;
  color: var(--fg-muted);
  text-align: center;
}

/* Raw code fallback */
.code-details {
  margin-bottom: 18px;
  font-size: 13px;
}
.code-details summary {
  cursor: pointer;
  color: var(--fg-muted);
  font-weight: 500;
  user-select: none;
  padding: 4px 0;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.code-details summary::-webkit-details-marker { display: none; }
.code-details summary::before {
  content: "›";
  display: inline-block;
  transition: transform 0.15s ease;
  font-size: 16px;
  line-height: 1;
}
.code-details[open] summary::before { transform: rotate(90deg); }
.code-details summary:hover { color: var(--primary); }
.raw-code {
  display: block;
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;
  font-size: 12px;
  word-break: break-all;
  user-select: all;
  color: var(--fg);
}

/* ---- Stats ---- */
.stats-group {
  display: inline-flex;
  gap: 14px;
  align-items: baseline;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.stat-pair {
  display: inline-flex;
  gap: 5px;
  align-items: baseline;
}
.stat-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-subtle);
}

/* ---- Status pill ---- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface-2);
  color: var(--fg-muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.pill::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 18%, transparent);
}
.pill.connecting { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.pill.connecting::before { animation: pulse 1.4s ease-in-out infinite; }
.pill.connected,
.pill.done { background: var(--success-soft); color: var(--success); border-color: transparent; }
.pill.disconnected { background: var(--destructive-soft); color: var(--destructive); border-color: transparent; }
.pill.transferring { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.pill.transferring::before { animation: pulse 1.2s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ---- Dropzone ---- */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  background: var(--surface);
  transition: border-color .15s ease, background-color .15s ease;
}
.dropzone.hover { border-color: var(--primary); background: var(--primary-soft); }
.dropzone.disabled { opacity: 0.55; pointer-events: none; }
.dz-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.dz-icon svg { width: 28px; height: 28px; }
.dz-title { margin: 0; font-size: 16px; font-weight: 600; color: var(--fg); }
.dz-sub { margin: 4px 0 14px; font-size: 13px; color: var(--fg-muted); }
.file-label { cursor: pointer; }
.dropzone input[type=file] {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ---- Input ---- */
input[type=text] {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--fg);
  font: inherit;
  font-size: 15px;
  margin-bottom: 14px;
  min-height: 44px;
  transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}
input[type=text]:hover { border-color: var(--primary); }
input[type=text]:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}
input[type=text]::placeholder { color: var(--fg-subtle); }

/* ---- Progress ---- */
.progress-wrap { margin-top: 24px; }
.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.file-icon {
  width: 20px; height: 20px;
  color: var(--primary);
  flex-shrink: 0;
}
.filename {
  font-size: 14px;
  font-weight: 500;
  color: var(--fg);
  word-break: break-all;
  flex: 1;
}
.progress {
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 70%, white));
  transition: width 0.1s linear;
  border-radius: 999px;
  box-shadow: 0 0 8px color-mix(in srgb, var(--primary) 40%, transparent);
}
.stats {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--fg-muted);
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---- Footer ---- */
.foot {
  text-align: center;
  color: var(--fg-subtle);
  font-size: 12px;
  margin-top: 12px;
}
.foot p { margin: 0; }

/* ---- Responsive ---- */
@media (max-width: 480px) {
  main { padding: 28px 16px 32px; }
  .card { padding: 22px; }
  .hero h1 { font-size: 26px; }
  .hero .sub { font-size: 15px; }
  .btn.big { padding: 16px; font-size: 15.5px; }
  .icon-btn .btn-label { display: none; }
  .qr-box canvas { width: 160px; height: 160px; }
}

/* ---- Animations ---- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
@keyframes fadeScale {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: none; }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: none; }
}
@keyframes pop {
  0%   { transform: scale(0.92); opacity: 0; }
  60%  { transform: scale(1.02); opacity: 1; }
  100% { transform: scale(1); }
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* page-load entry */
.hero { animation: fadeUp 0.55s cubic-bezier(0.22, 1, 0.36, 1) both; }
.foot { animation: fadeUp 0.6s 0.15s cubic-bezier(0.22, 1, 0.36, 1) both; }

/* view enter - app.js her go() cagrisinda .view-enter class'ini toggle ediyor */
.view-enter {
  animation: fadeUp 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* landing buttons stagger */
.landing .btn { animation: fadeUp 0.4s cubic-bezier(0.22, 1, 0.36, 1) both; }
.landing .btn:nth-child(1) { animation-delay: 60ms; }
.landing .btn:nth-child(2) { animation-delay: 130ms; }

/* hover lift (sadece pointer destekleyen cihazlarda) */
@media (hover: hover) {
  .btn.primary:hover:not(:disabled),
  .btn.outline:hover:not(:disabled) { transform: translateY(-1px); }
}

/* QR ve progress reveal */
.qr-box:not(.hidden) { animation: fadeScale 0.32s cubic-bezier(0.22, 1, 0.36, 1) both; }
.progress-wrap:not(.hidden) { animation: fadeUp 0.32s cubic-bezier(0.22, 1, 0.36, 1) both; }

/* status pill geldiginde ufak pop */
.pill:not(:empty) { animation: pop 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both; }

/* progress bar shimmer (sadece transferring sirasinda parent .progress'a anim ekleyince) */
.progress { position: relative; }
.bar { position: relative; overflow: hidden; }
.bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    transparent 20%,
    rgba(255, 255, 255, 0.35) 50%,
    transparent 80%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.progress.live .bar::after { opacity: 1; }

/* drop zone hover scale */
.dropzone { transition: border-color .15s ease, background-color .15s ease, transform .15s ease; }
.dropzone.hover { transform: scale(1.01); }

/* card head pill slide */
.card-head .pill { animation: slideInRight 0.3s cubic-bezier(0.22, 1, 0.36, 1) both; }

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .bar { transition: none; }
}

/* ---- QR scanner (receive) ---- */
.scan-sep {
  display: flex; align-items: center; gap: .75rem;
  margin: 1rem 0; color: var(--muted, #64748B); font-size: .8rem;
}
.scan-sep::before, .scan-sep::after {
  content: ''; flex: 1; height: 1px; background: var(--border, #E2E8F0);
}
.scan-box {
  margin-top: 1rem; border-radius: 14px; overflow: hidden;
  border: 1px solid var(--border, #E2E8F0); background: #000;
}
#qrReader { width: 100%; }
#qrReader video { width: 100% !important; height: auto !important; display: block; }
.scan-hint {
  text-align: center; font-size: .8rem; padding: .6rem;
  color: var(--muted, #64748B); background: var(--card, #fff);
}

/* ---- send pending hint (file chosen before receiver connects) ---- */
.send-hint {
  margin-top: .85rem; padding: .65rem .85rem;
  border-radius: 12px; font-size: .85rem; font-weight: 500;
  text-align: center;
  color: var(--accent-fg, #1E3A8A);
  background: var(--accent-soft, #EFF6FF);
  border: 1px solid var(--accent-border, #BFDBFE);
}
