/*
 * iTransfer — design system implementation.
 * Hand-rolled utility CSS (no Tailwind build step) so this file can be
 * served directly under a strict CSP without `unsafe-inline`.
 *
 * Tokens come from docs/design/DESIGN_SYSTEM.md.
 */

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --fg: #0f172a;
  --fg-muted: #475569;
  --fg-subtle: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --muted: #f1f5f9;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-fg: #ffffff;
  --success: #16a34a;
  --warn-bg: #fffbeb;
  --warn-border: #fde68a;
  --warn-text: #92400e;
  --warn-icon: #d97706;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --danger-text: #991b1b;
  --ring: rgba(37, 99, 235, 0.18);

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

html {
  -webkit-text-size-adjust: 100%;
  font-size: 16px;
}

body {
  font-family: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  font-size: 16px;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  color: inherit;
}

input,
textarea,
select {
  font: inherit;
  color: inherit;
}

/* ── utility classes ──────────────────────────────────────────────────── */

.font-heading { font-family: 'Lexend', system-ui, sans-serif; letter-spacing: -0.01em; }
.font-body    { font-family: 'Source Sans 3', system-ui, sans-serif; }
.font-mono    { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.bg-bg       { background: var(--bg); }
.bg-surface  { background: var(--surface); }
.bg-muted    { background: var(--muted); }
.bg-primary  { background: var(--primary); }

.text-fg         { color: var(--fg); }
.text-fg-muted   { color: var(--fg-muted); }
.text-fg-subtle  { color: var(--fg-subtle); }
.text-primary    { color: var(--primary); }
.text-danger     { color: var(--danger); }
.text-success    { color: var(--success); }
.text-white      { color: #fff; }

.text-xs   { font-size: 12px; }
.text-sm   { font-size: 14px; }
.text-base { font-size: 16px; }
.text-lg   { font-size: 18px; }
.text-xl   { font-size: 20px; }
.text-2xl  { font-size: 24px; line-height: 1.25; }
.text-3xl  { font-size: 30px; line-height: 1.2; }
.text-4xl  { font-size: 36px; line-height: 1.15; }

.font-medium    { font-weight: 500; }
.font-semibold  { font-weight: 600; }
.font-bold      { font-weight: 700; }

.tracking-tight { letter-spacing: -0.015em; }

.antialiased { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

.min-h-dvh { min-height: 100dvh; }
.min-h-screen { min-height: 100vh; }

.block { display: block; }
.inline-flex { display: inline-flex; }
.flex { display: flex; }
.grid { display: grid; }
.hidden { display: none !important; }

.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }

.gap-1  { gap: 4px; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.gap-6  { gap: 24px; }
.gap-y-1 { row-gap: 4px; }

.grid-cols-2 { grid-template-columns: 1fr 1fr; }
.place-items-center { place-items: center; }

.w-full { width: 100%; }
.w-7    { width: 28px; }
.h-7    { height: 28px; }
.w-6    { width: 24px; }
.h-6    { height: 24px; }
.w-5    { width: 20px; }
.h-5    { height: 20px; }
.w-12   { width: 48px; }
.h-12   { height: 48px; }
.w-11   { width: 44px; }
.h-11   { height: 44px; }
.max-w-md  { max-width: 28rem; }
.max-w-4xl { max-width: 56rem; }
.max-w-prose { max-width: 65ch; }
.flex-1 { flex: 1 1 0%; }
.shrink-0 { flex-shrink: 0; }

.mx-auto { margin-left: auto; margin-right: auto; }
.mt-1  { margin-top: 4px; }
.mt-2  { margin-top: 8px; }
.mt-3  { margin-top: 12px; }
.mt-4  { margin-top: 16px; }
.mt-5  { margin-top: 20px; }
.mt-6  { margin-top: 24px; }
.mt-8  { margin-top: 32px; }
.mt-10 { margin-top: 40px; }
.mb-1  { margin-bottom: 4px; }
.mb-2  { margin-bottom: 8px; }
.mb-5  { margin-bottom: 20px; }
.mb-6  { margin-bottom: 24px; }
.mb-8  { margin-bottom: 32px; }

.p-2  { padding: 8px; }
.p-3  { padding: 12px; }
.p-4  { padding: 16px; }
.p-5  { padding: 20px; }
.p-6  { padding: 24px; }
.p-8  { padding: 32px; }
.px-3 { padding-left: 12px; padding-right: 12px; }
.px-4 { padding-left: 16px; padding-right: 16px; }
.px-5 { padding-left: 20px; padding-right: 20px; }
.px-6 { padding-left: 24px; padding-right: 24px; }
.py-1 { padding-top: 4px; padding-bottom: 4px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }
.py-3 { padding-top: 12px; padding-bottom: 12px; }
.py-4 { padding-top: 16px; padding-bottom: 16px; }
.py-10 { padding-top: 40px; padding-bottom: 40px; }
.py-12 { padding-top: 48px; padding-bottom: 48px; }

.rounded-sm  { border-radius: var(--radius-sm); }
.rounded-lg  { border-radius: var(--radius-md); }
.rounded-xl  { border-radius: var(--radius-lg); }
.rounded-full { border-radius: 9999px; }

.border        { border: 1px solid var(--border); }
.border-b      { border-bottom: 1px solid var(--border); }
.border-border { border-color: var(--border); }
.last\:border-b-0:last-child { border-bottom: 0; }

.text-center   { text-align: center; }
.text-right    { text-align: right; }
.text-left     { text-align: left; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.relative { position: relative; }
.sticky { position: sticky; top: 0; }

.text-warn-700 { color: var(--warn-text); }

/* ── components ───────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
}

@media (max-width: 640px) {
  .card { padding: 24px; }
}

.btn-primary,
.btn-secondary,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 16px;
  transition: background-color 150ms ease-out, color 150ms ease-out, border-color 150ms ease-out;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-primary:active:not(:disabled) { background: #1e40af; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--border-strong); background: var(--muted); }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
}

.btn-label { display: inline-block; }

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--fg-muted);
  margin-bottom: 6px;
}

.form-input {
  display: block;
  width: 100%;
  height: 44px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 16px;
  color: var(--fg);
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
}
.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--ring);
  outline: none;
}
.form-input[readonly] {
  background: var(--muted);
  color: var(--fg-muted);
  cursor: text;
}

.alert {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid;
}

.alert-warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn-text);
}
.alert-warn .alert-icon { color: var(--warn-icon); }

.alert-danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-text);
}
.alert-danger .alert-icon { color: var(--danger); }

.alert-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

.alert-title {
  font-weight: 600;
  margin-bottom: 2px;
  color: inherit;
}

.alert-body {
  font-size: 14px;
  line-height: 1.45;
  color: inherit;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--fg);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  z-index: 100;
  opacity: 0;
  transition: opacity 200ms ease-out;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
}

.copy-btn-success {
  background: var(--success) !important;
  color: #fff !important;
  border-color: transparent !important;
}

/* ── Uppy overrides ───────────────────────────────────────────────────── */
/* Uppy's default styles are reasonable. Override the accent color and a
   few details so it sits cleanly inside our card design. */

.uppy-Dashboard-inner {
  border: 0 !important;
  background: transparent !important;
  font-family: 'Source Sans 3', system-ui, sans-serif !important;
}
.uppy-Dashboard-AddFiles {
  border: 2px dashed var(--border-strong) !important;
  border-radius: var(--radius-lg) !important;
  background: var(--bg) !important;
}
.uppy-Dashboard-AddFiles:hover {
  border-color: var(--primary) !important;
}
.uppy-c-btn-primary,
.uppy-StatusBar-actionBtn--upload {
  background: var(--primary) !important;
}
.uppy-c-btn-primary:hover,
.uppy-StatusBar-actionBtn--upload:hover {
  background: var(--primary-hover) !important;
}
.uppy-StatusBar-progress {
  background: var(--primary) !important;
}

/* Reduced motion — disable transitions and the toast fade. */
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
  }
}
