/* ============================================
   UTM Builder - Styles

   Design tokens, header, grid, field and button
   styles are taken 1:1 from the SERP Simulator
   (serp-simulator.xtraz-labs.com) so both tools
   stay visually identical. Anything added for
   this tool is marked "UTM Builder addition" and
   is derived from the existing tokens only.

   If a third tool joins, lift the ":root" block
   plus reset/header/field/button sections into a
   shared tokens.css -- they are unmodified.
   ============================================ */

/* --- Reset & Basis --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* The hidden attribute only sets display:none at low priority, so any
   element given display:flex below would ignore it. Several elements
   here are toggled that way, so make hidden win outright. */
[hidden] {
  display: none !important;
}

:root {
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;   /* 1.23:1 on white -- below the 3:1 WCAG 1.4.11
                                asks for on a control boundary. Inherited from
                                the SERP Simulator; changing it would make the
                                two tools diverge, so it is a shared decision. */
  --color-text: #1e293b;
  --color-text-secondary: #64748b;
  --color-success: #16a34a;
  --color-warning: #ea580c;
  --color-danger: #dc2626;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.1);

  /* UTM Builder additions -- all derived from the tokens above.
     The only genuinely new value is the monospace stack: a URL is
     read character by character, so it needs fixed-width digits and
     an unambiguous l/1/I. It is a system stack, not a new typeface. */
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  --tint-primary: rgba(37, 99, 235, 0.08);   /* --color-primary  @ 8% */
  --tint-warning: rgba(234, 88, 12, 0.08);   /* --color-warning  @ 8% */
  --tint-success: rgba(22, 163, 74, 0.10);   /* --color-success  @ 10% */
  --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  min-height: 100vh;
}

/* UTM Builder addition: visible focus for everything the SERP
   Simulator did not have (buttons, links, summary). Inputs keep
   their own focus style further down, unchanged. */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* UTM Builder addition: label text for screen readers only. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Header --- */
.header {
  display: flex;
  align-items: center;
  padding: 24px 32px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.header-logo-link,
.header-spacer {
  flex: 0 0 auto;
  width: 120px;
}

.header-text {
  flex: 1;
  text-align: center;
}

.header-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text);
}

.header-subtitle {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.header-logo {
  height: 32px;
  width: auto;
}

/* UTM Builder addition: the tool is useless without scripting, so say
   so rather than presenting a form that silently does nothing. */
.noscript-note {
  padding: 20px 32px 0;
  max-width: 1400px;
  margin: 0 auto;
}

/* --- Container / Layout --- */
.container {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 0;
  max-width: 1400px;
  margin: 0 auto;
  min-height: calc(100vh - 85px);
}

/* --- Linkes Panel: Eingabe --- */
.input-panel {
  padding: 24px;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
}

.field-group {
  margin-bottom: 20px;
}

.field-group label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.field-group input[type="text"],
.field-group input[type="url"],
.field-group textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.field-group input:focus,
.field-group textarea:focus {
  border-color: var(--color-primary);
  box-shadow: var(--focus-ring);
}

/* UTM Builder addition: required/optional marker. Sits in the label's
   right-hand slot -- where the SERP Simulator puts its counter. */
.field-flag {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.field-flag.required {
  color: var(--color-primary);
}

/* UTM Builder addition: help text below the field. */
.field-hint {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-top: 5px;
}

/* UTM Builder addition: shows the cleaned value whenever the raw input
   and the normalized value differ. */
.field-normalized {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
  margin-top: 5px;
  color: var(--color-text-secondary);
}

.field-normalized code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-primary);
  background: var(--tint-primary);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  word-break: break-all;
}

/* UTM Builder addition: collapsed "Weitere Parameter" section. */
.more-params {
  margin-bottom: 20px;
  border-top: 1px solid var(--color-border);
  padding-top: 16px;
}

.more-params > summary {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.more-params > summary::-webkit-details-marker {
  display: none;
}

.more-params > summary::before {
  content: '';
  width: 0;
  height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.15s;
}

.more-params[open] > summary::before {
  transform: rotate(90deg);
}

.more-params > summary:hover {
  color: var(--color-text);
}

.more-params[open] > summary {
  margin-bottom: 12px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn:disabled:active {
  transform: none;
}

.btn-small {
  padding: 5px 12px;
  font-size: 12px;
  background: var(--color-bg);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

.btn-small:hover:not(:disabled) {
  background: var(--color-border);
  color: var(--color-text);
}

.btn-outline {
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

.btn-outline:hover:not(:disabled) {
  background: var(--color-bg);
  color: var(--color-text);
}

/* UTM Builder addition: filled primary button. Colors are taken 1:1
   from the SERP Simulator's .toggle-btn.active (primary + #fff); the
   min-height gives it a comfortable touch target. */
.btn-primary {
  background: var(--color-primary);
  color: #fff;
  min-height: 40px;
  padding: 8px 20px;
  font-size: 14px;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

/* Action-Buttons */
.action-buttons {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
  margin-top: 8px;
}

/* --- Rechtes Panel: Ergebnis --- */
.preview-panel {
  padding: 24px 32px;
  background: var(--color-bg);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* UTM Builder addition: card. Uses surface, border, radius and shadow
   straight from the token set -- no new values. */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card[hidden] {
  display: none;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.card-note {
  font-size: 12px;
  color: var(--color-text-secondary);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

/* --- URL-Vorschau --- */
.url-preview {
  display: block;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.7;
  word-break: break-all;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-height: 76px;
}

/* break-all above is right for a URL but wrong for a sentence -- the
   placeholder must wrap on word boundaries. */
.url-placeholder {
  display: inline-block;
  color: var(--color-text-secondary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  word-break: normal;
  overflow-wrap: break-word;
}

/* The base URL keeps the normal text color; everything appended is
   colored, so it is immediately obvious what the tool added. */
.url-base {
  color: var(--color-text);
}

.url-sep {
  color: var(--color-text-secondary);
  font-weight: 600;
}

.url-key {
  color: var(--color-primary);
  font-weight: 600;
}

.url-value {
  color: var(--color-primary);
}

.url-fragment {
  color: var(--color-text-secondary);
}

/* --- Copy-Feedback --- */
/* The confirmation is text, so it needs 4.5:1. --color-success on white
   is only 3.30:1, which is fine for a glyph but not for words -- hence
   the tick in green and the label in the normal text colour. */
.copy-feedback {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  opacity: 0;
  transition: opacity 0.15s;
}

.copy-feedback::before {
  content: '\2713\00a0';
  color: var(--color-success);
}

.copy-feedback.visible {
  opacity: 1;
}

.copy-feedback.error {
  color: var(--color-danger);   /* 4.83:1 on white, passes */
}

.copy-feedback.error::before {
  content: '';
}

/* --- Hinweise --- */
.warnings {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.warnings:empty {
  display: none;
}

.warning {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  line-height: 1.5;
  padding: 12px 14px;
  border-radius: var(--radius);
  color: var(--color-text);
}

/* Three levels: something to look at, a heads-up, and a confirmation.
   None of them ever block the output. */
.warning-warning {
  background: var(--tint-warning);
  border: 1px solid var(--color-warning);
}

.warning-info {
  background: var(--tint-primary);
  border: 1px solid var(--color-border);
}

.warning-success {
  background: var(--tint-success);
  border: 1px solid var(--color-success);
}

.warning-icon {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  color: #fff;
}

.warning-warning .warning-icon {
  background: var(--color-warning);
}

.warning-info .warning-icon {
  background: var(--color-primary);
}

.warning-success .warning-icon {
  background: var(--color-success);
}

.warning-body strong {
  font-weight: 600;
}

.warning-action {
  margin-top: 8px;
}

/* --- QR-Code --- */
.qr-body {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.qr-canvas-wrap {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px;
  line-height: 0;
}

.qr-canvas-wrap canvas {
  display: block;
  width: 180px;
  height: 180px;
  /* The canvas is drawn at download resolution and scaled down for
     display; nearest-neighbour keeps the module edges hard. */
  image-rendering: pixelated;
}

.qr-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  max-width: 260px;
}

/* --- Historie --- */
.history-note {
  margin-top: -6px;
  margin-bottom: 12px;
}

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.history-url {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Footer --- */
.footer {
  padding: 20px 32px 32px;
  text-align: center;
  font-size: 12px;
  color: var(--color-text-secondary);
}

.footer a {
  color: var(--color-text-secondary);
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .container {
    grid-template-columns: 1fr;
    /* Stacked, the container's min-height would hand the leftover space
       to the input panel and push the result a screen further down. */
    min-height: 0;
  }

  .input-panel {
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }

  .preview-panel {
    padding: 24px 16px;
  }
}

@media (max-width: 500px) {
  /* Deliberate deviation from the SERP Simulator: its header keeps two
     fixed 120px columns around a centered title, which collides with the
     logo below ~520px. Here the spacer is dropped and the block is
     left-aligned next to the logo instead. */
  .header {
    padding: 16px;
    gap: 12px;
  }

  .header-spacer {
    display: none;
  }

  .header-logo-link {
    width: auto;
  }

  .header-logo {
    height: 26px;
  }

  .header-text {
    text-align: left;
    min-width: 0;
  }

  .header-title {
    font-size: 18px;
  }

  .header-subtitle {
    font-size: 12px;
  }

  .input-panel {
    padding: 16px;
  }

  .more-params {
    margin-bottom: 8px;
  }

  .footer {
    padding: 16px 16px 24px;
  }

  /* Larger touch targets on phones. 44px is the size a thumb actually
     hits reliably; WCAG 2.2 only asks for 24px, but this tool gets used
     one-handed on the way to a meeting. */
  .btn {
    min-height: 44px;
  }

  .btn-small {
    padding: 8px 14px;
  }

  .card-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-primary {
    width: 100%;
    min-height: 48px;
    font-size: 15px;
  }

  .copy-feedback {
    text-align: center;
  }

  .history-item {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .history-url {
    white-space: normal;
    word-break: break-all;
  }
}
