/* ==========================================================================
   Tracement — Shipment Label Generator
   Modern, clean startup UI. The app chrome is colorful & soft; the LABEL
   preview stays strictly black-on-white so it matches the printed PDF.
   Shared by index.html (numbered labels) and awb.html (AWB labels).
   ========================================================================== */

:root {
  --bg: #0b0b12;
  --surface: #ffffff;
  --surface-2: #f7f7fb;
  --ink: #14141b;
  --ink-soft: #5b5b6b;
  --ink-faint: #9a9aae;
  --line: #ececf2;
  --brand: #6366f1;
  --brand-2: #a855f7;
  --brand-ink: #4f46e5;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --radius: 18px;
  --radius-sm: 11px;
  --shadow-sm: 0 1px 2px rgba(17,17,27,.06), 0 1px 3px rgba(17,17,27,.05);
  --shadow-lg: 0 10px 30px -12px rgba(40,30,90,.22), 0 4px 12px -6px rgba(40,30,90,.12);
  --ring: 0 0 0 4px rgba(99,102,241,.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 50% -10%, #f1f0ff 0%, rgba(241,240,255,0) 60%),
    linear-gradient(180deg, #fbfbfe 0%, #f4f4f9 100%);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.bg-glow {
  position: fixed;
  inset: -20% 0 auto 0;
  height: 480px;
  pointer-events: none;
  background:
    radial-gradient(420px 240px at 22% 30%, rgba(99,102,241,.18), transparent 70%),
    radial-gradient(420px 240px at 80% 10%, rgba(168,85,247,.16), transparent 70%);
  filter: blur(8px);
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px 22px 56px;
}

/* -------------------- Top bar / brand / nav -------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 30px;
}
.brand { display: flex; align-items: center; gap: 10px; }

/* Official Tracement wordmark (SVG) */
.logo {
  height: 34px;
  width: auto;
  display: block;
  user-select: none;
}

/* Header navigation between the two tools */
.nav {
  display: flex;
  gap: 6px;
  background: rgba(99,102,241,.06);
  border: 1px solid rgba(99,102,241,.14);
  padding: 4px;
  border-radius: 999px;
}
.nav-link {
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 7px 16px;
  border-radius: 999px;
  transition: background .15s ease, color .15s ease;
}
.nav-link:hover { color: var(--ink); background: rgba(99,102,241,.08); }
.nav-link.active {
  color: #fff;
  background: linear-gradient(120deg, var(--brand) 0%, var(--brand-2) 100%);
  box-shadow: 0 6px 14px -7px rgba(99,102,241,.7);
}

/* -------------------- Hero -------------------- */
.hero { margin-bottom: 26px; max-width: 60ch; }
.hero h1 {
  font-size: clamp(1.7rem, 3.2vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0 0 10px;
}
.subtitle { margin: 0; color: var(--ink-soft); font-size: 1.02rem; }

/* -------------------- Layout -------------------- */
.layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 22px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-lg);
}
.panel h2 {
  font-size: 0.82rem;
  font-weight: 700;
  margin: 0 0 18px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
}

/* -------------------- Form -------------------- */
.field { margin-bottom: 16px; }
.field label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 7px;
  color: var(--ink);
}
.req { color: var(--brand); font-weight: 700; }
.opt {
  color: var(--ink-faint);
  font-weight: 500;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid var(--line);
  padding: 1px 7px;
  border-radius: 999px;
}
.hint { display: block; color: var(--ink-faint); margin-top: 5px; font-size: 0.82rem; }

input[type="text"],
input[type="number"],
input[type="date"] {
  width: 100%;
  padding: 11px 13px;
  font-size: 0.98rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input::placeholder { color: var(--ink-faint); }
input:focus {
  outline: none;
  background: #fff;
  border-color: var(--brand);
  box-shadow: var(--ring);
}
input.invalid {
  border-color: var(--error);
  background: var(--error-bg);
  box-shadow: 0 0 0 4px rgba(220,38,38,.12);
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0 16px;
  color: var(--ink-faint);
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* -------------------- Errors -------------------- */
.errors {
  color: var(--error);
  font-weight: 600;
  font-size: 0.9rem;
  margin: 4px 0;
}
.errors:not(:empty) {
  background: var(--error-bg);
  border: 1px solid rgba(220,38,38,.22);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 8px 0 4px;
}
.errors ul { margin: 0; padding-left: 18px; }
.errors li { margin: 2px 0; }

/* -------------------- Buttons -------------------- */
.buttons { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.97rem;
  font-weight: 600;
  font-family: inherit;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform .08s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  color: #fff;
  background: linear-gradient(120deg, var(--brand) 0%, var(--brand-2) 100%);
  box-shadow: 0 8px 20px -8px rgba(99,102,241,.6);
}
.btn-primary:hover { box-shadow: 0 12px 26px -8px rgba(99,102,241,.7); }
.btn-secondary {
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
}
.btn-secondary:hover { background: var(--surface-2); border-color: #dcdce6; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* -------------------- Label preview (mimics 4x6 = 2:3) ----------------- */
.preview-note { color: var(--ink-faint); font-size: 0.84rem; margin: -10px 0 18px; }
.label-stage {
  display: flex;
  justify-content: center;
  padding: 22px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #f6f6fb 0%, #eeeef5 100%);
  border: 1px solid var(--line);
}

.label-preview {
  width: 264px;        /* 4 in */
  height: 396px;       /* 6 in -> 2:3 ratio */
  background: #fff;
  border: 1px solid #111;
  border-radius: 4px;
  box-shadow: 0 14px 34px -14px rgba(20,20,40,.4);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: #000;
}
.lp-brand {
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 0.06em;
  word-break: break-word;
}
.lp-rule { width: 100%; border-top: 2px solid #000; margin: 8px 0 14px; }
.lp-rule-thin { border-top-width: 1px; margin: 8px 0; }

.lp-section-label {
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  margin-top: 8px;
}
.lp-awb {
  font-weight: 700;
  font-size: 1.15rem;
  margin: 4px 0 6px;
  word-break: break-all;
}
.lp-piece-box {
  flex: 1;
  width: 100%;
  margin: 10px 0;
  border: 3px solid #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lp-piece { font-weight: 800; font-size: 6rem; line-height: 1; }

/* AWB-only label: the AirWay Bill number is the dominant element */
.lp-awb-box {
  flex: 1;
  width: 100%;
  margin: 10px 0 0;
  border: 3px solid #000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}
.lp-awb-big {
  font-weight: 800;
  font-size: 2rem;
  line-height: 1.1;
  white-space: nowrap;   /* keep the AWB on one line; JS shrinks it to fit */
}

.lp-footer { width: 100%; font-size: 0.72rem; color: #000; }
.lp-footer:empty { display: none; }
#lpFooterText { white-space: pre-line; text-align: left; }

/* -------------------- App footer -------------------- */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 34px;
  color: var(--ink-faint);
  font-size: 0.84rem;
}
.app-footer .dot {
  width: 8px; height: 8px; border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34,197,94,.16);
}

/* -------------------- Responsive -------------------- */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .preview-panel { order: -1; }
}
