/* QR Social Profile Platform — single stylesheet, mobile first. */

:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #16191d;
  --muted: #5b636e;
  --line: #e2e5ea;
  --accent: #234076;
  --accent-ink: #ffffff;
  /* Tinted surface for the link tiles, derived from the brand colour. */
  --accent-soft: #eaeff8;
  --accent-strong: #1a3059;
  /* Plaque behind the logo. The mark is a reversed (white) wordmark, so it
     needs a solid dark backdrop in both themes. */
  --logo-bg: #264a90;
  --danger: #a11a1a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 20, 26, .06), 0 8px 24px rgba(16, 20, 26, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #171a20;
    --ink: #eef1f5;
    --muted: #a2abb8;
    --line: #272c35;
    /* #234076 is too dark to read on a dark background, so the dark theme
       uses a lighter tint of the same hue. */
    --accent: #8ba7dc;
    --accent-ink: #101a2e;
    --accent-soft: #1c2740;
    --accent-strong: #a8bee8;
    --logo-bg: #264a90;
    --danger: #ff6b6b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- public profile ---------- */

body.public { display: flex; justify-content: center; padding: 24px 16px 48px; }

.card {
  width: 100%;
  max-width: 520px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 20px 24px;
}

.profile-head { text-align: center; margin-bottom: 22px; }

/* A wordmark lockup is wider than it is tall, so the logo gets a contained
   rectangle rather than a cropped circle. The brand plaque behind it keeps a
   white/reversed logo visible on the light theme. */
.logo {
  display: block; margin: 0 auto 16px;
  max-width: 100%; width: auto; height: 76px;
  object-fit: contain;
  background: var(--logo-bg);
  border-radius: 14px;
  padding: 12px 18px;
}

/* Profiles with no uploaded logo fall back to a monogram disc. */
.logo-fallback {
  width: 96px; height: 96px; border-radius: 50%; padding: 0;
  display: grid; place-items: center;
  font-size: 40px; font-weight: 600;
  color: var(--accent-ink); background: var(--accent);
}

.profile-head h1 { font-size: 24px; margin: 0 0 6px; line-height: 1.25; }
.subtitle { margin: 0 0 8px; color: var(--muted); font-size: 15px; }
.description { margin: 8px 0 0; color: var(--muted); font-size: 14px; }

/* Link tiles: an app-launcher grid — big icon, small caption. auto-fit keeps
   three across on a phone and widens gracefully on a tablet. */
.links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(94px, 1fr));
  gap: 12px;
}

/* Each tile carries its platform's own colour in --brand; anything without one
   falls back to the Traveldoor navy. */
.link {
  --brand: var(--accent);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  min-height: 104px; padding: 16px 8px;
  border: 2px solid color-mix(in srgb, var(--brand) 35%, transparent);
  border-radius: 16px;
  background: var(--card); color: var(--ink);
  text-decoration: none; text-align: center;
  transition: transform .08s ease, border-color .15s ease,
              background-color .15s ease, box-shadow .15s ease;
}

.link:hover {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 7%, var(--card));
  box-shadow: var(--shadow);
}
.link:active { transform: scale(.97); }
.link:focus-visible { outline-color: var(--brand); }

/* The icon size is set here rather than on the svg width/height attributes so
   one rule controls every tile. */
.link .icon {
  width: 40px; height: 40px;
  flex: 0 0 auto;
  color: var(--brand);
}

/* Platform brand colours. */
.link-facebook  { --brand: #0866FF; }
.link-instagram { --brand: #E4405F; }
.link-tiktok    { --brand: #000000; }
.link-youtube   { --brand: #FF0000; }
.link-linkedin  { --brand: #0A66C2; }
.link-x         { --brand: #000000; }
.link-whatsapp  { --brand: #25D366; }
/* website, map, email, phone and generic keep the Traveldoor navy. */

@media (prefers-color-scheme: dark) {
  /* TikTok and X are near-black marks; invert them so they stay visible. */
  .link-tiktok, .link-x { --brand: #f2f5fa; }
}

.link-label {
  font-size: 12px; line-height: 1.25; font-weight: 600;
  letter-spacing: .01em;
  color: var(--muted);
  /* Two lines maximum, so "X (Twitter)" wraps instead of stretching a tile. */
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

.link:hover .link-label { color: var(--ink); }

/* The index page reuses .link without an icon. */
.links .link:not(:has(.icon)) { min-height: 64px; }
.links .link:not(:has(.icon)) .link-label { font-size: 15px; color: var(--ink); }

.profile-foot { margin-top: 22px; text-align: center; }

.foot-actions {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
}

.secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; min-height: 44px;
  border: 2px solid var(--accent); border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  text-decoration: none; font-weight: 600; line-height: 24px;
  font-family: inherit; font-size: inherit; cursor: pointer;
}

/* The share control is the secondary of the two actions. */
.secondary.outline {
  background: transparent; color: var(--accent);
}
.secondary.outline:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }

.secondary .icon { width: 18px; height: 18px; }

/* Brief confirmation after the link is copied on browsers with no share
   sheet. */
.share-status { margin: 10px 0 0; font-size: 13px; color: var(--accent); min-height: 18px; }

.address { margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); text-align: center; grid-column: 1 / -1; }

/* ---------- admin ---------- */

body.admin { padding: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 20px;
  background: var(--card); border-bottom: 1px solid var(--line);
}

.brand { font-weight: 700; text-decoration: none; color: var(--ink); }
.who { color: var(--muted); font-size: 14px; margin-right: 8px; }

.wrap { max-width: 980px; margin: 0 auto; padding: 20px 16px 60px; }

.page-head {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center; justify-content: space-between; margin-bottom: 16px;
}
.page-head h1 { font-size: 22px; margin: 0; }
.actions { display: flex; gap: 8px; }

.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 18px;
}
.panel.narrow { max-width: 560px; }
.panel h2 { font-size: 17px; margin: 0 0 12px; }
.panel h3 { font-size: 15px; margin: 20px 0 8px; }

.field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 5px; }
.field.grow { flex: 1 1 220px; }
label { font-size: 14px; font-weight: 500; }
.hint { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

input, select, textarea {
  font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; min-height: 42px; max-width: 100%;
}
textarea { min-height: 80px; }

button, .button {
  font: inherit; font-weight: 600; cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
  border: 1px solid transparent; border-radius: 8px;
  padding: 10px 16px; min-height: 42px;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
.button.ghost, .icon-button {
  background: transparent; color: var(--ink); border-color: var(--line);
}
.icon-button { padding: 6px 10px; min-height: 34px; }
button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.link-button { background: none; border: none; color: var(--accent); padding: 4px; min-height: 32px; }

.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; }

.links-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.links-table th, .links-table td {
  text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.links-table th { color: var(--muted); font-weight: 600; }
.nowrap { white-space: nowrap; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; }

.link-admin { overflow-x: auto; }
.link-add { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line); font-size: 12px; color: var(--muted);
}
.badge.live { border-color: var(--accent); color: var(--accent); }

.error {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1px solid var(--danger); color: var(--danger);
  border-radius: 8px; padding: 10px 14px; margin: 0 0 14px;
}
.error li { margin-left: 6px; }
.notice {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid var(--accent); border-radius: 8px;
  padding: 10px 14px; margin: 0 0 14px;
}

.qr-row { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.qr { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.downloads { margin: 0; padding-left: 18px; }
.downloads li { margin-bottom: 6px; }

.danger-zone { border-color: var(--danger); }

@media (max-width: 640px) {
  .links-table, .links-table tbody, .links-table tr, .links-table td { display: block; width: 100%; }
  .links-table thead { display: none; }
  .links-table tr { border-bottom: 1px solid var(--line); padding: 10px 0; }
  .links-table td { border: 0; padding: 4px 0; }
  .links-table input, .links-table select { width: 100%; }
}

.logo-preview { border-radius: 8px; object-fit: cover; border: 1px solid var(--line); }

/* Admin QR panel */
.qr-target { margin: 0 0 14px; font-size: 14px; word-break: break-all; }
.qr-target code { background: var(--bg); padding: 1px 5px; border-radius: 4px; }
.qr-downloads { flex: 1 1 300px; }
.qr-downloads h3 { margin: 16px 0 6px; font-size: 14px; color: var(--muted); }
.qr-downloads h3:first-of-type { margin-top: 0; }
.qr-downloads p:first-child { margin-top: 0; }
