/* SGS QR Generator - Custom Styles */
/* Superdesign principles: 4px base, semantic variables, shadow scale */

:root {
  /* Brand colours */
  --sgs-dark: #1a1a2e;
  --sgs-accent: #e94560;
  --sgs-blue: #0f3460;
  --sgs-light: #f8f9fa;
  --sgs-white: #ffffff;
  --sgs-muted: #6b7280;
  --sgs-border: #e5e7eb;

  /* Semantic */
  --bg-primary: var(--sgs-white);
  --bg-secondary: var(--sgs-light);
  --bg-card: var(--sgs-white);
  --text-primary: var(--sgs-dark);
  --text-secondary: var(--sgs-muted);
  --border-colour: var(--sgs-border);
  --accent: var(--sgs-accent);
  --accent-hover: #d63851;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --shadow-xl: 0 16px 48px rgba(0,0,0,0.14);

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 24px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dark mode */
[data-theme="dark"] {
  --bg-primary: #0d0d1a;
  --bg-secondary: #141428;
  --bg-card: #1a1a33;
  --text-primary: #f0f0f5;
  --text-secondary: #8888a0;
  --border-colour: #2a2a44;
  --accent: #e94560;
  --accent-hover: #ff5a75;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
}

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

html {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  background: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background 300ms ease, color 300ms ease;
}

/* Header */
.header {
  background: rgba(26, 26, 46, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  position: sticky;
  top: 0;
  z-index: 100;
}

[data-theme="dark"] .header {
  background: rgba(13, 13, 26, 0.9);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--sgs-accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  color: white;
  letter-spacing: -0.02em;
}

.logo-text {
  color: white;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.logo-text span {
  color: var(--sgs-accent);
}

.logo-divider {
  width: 1px;
  height: 24px;
  background: rgba(255,255,255,0.2);
  margin: 0 4px;
}

.logo-subtitle {
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  font-weight: 400;
}

/* Dark mode toggle */
.theme-toggle {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  color: white;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 150ms var(--ease-out);
  min-height: 44px;
}

.theme-toggle:hover {
  background: rgba(255,255,255,0.18);
  transform: translateY(-1px);
}

/* Main layout */
.main-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

/* Tabs */
.tabs-container {
  margin-bottom: 32px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs-container::-webkit-scrollbar { display: none; }

.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  padding: 6px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-colour);
  width: fit-content;
  min-width: 100%;
}

.tab-btn {
  flex-shrink: 0;
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 200ms var(--ease-out);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  min-height: 44px;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.tab-btn.active {
  background: var(--sgs-dark);
  color: white;
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .tab-btn.active {
  background: var(--sgs-accent);
}

.tab-icon { font-size: 16px; }

/* Content grid */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: start;
}

@media (max-width: 768px) {
  .content-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-colour);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: box-shadow 200ms var(--ease-out);
}

.card-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-colour);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.card-body { padding: 24px; }

/* Form fields */
.field-group {
  margin-bottom: 20px;
}

.field-group:last-child { margin-bottom: 0; }

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.field-input,
.field-select,
.field-textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-colour);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  transition: border-color 200ms ease, box-shadow 200ms ease;
  min-height: 44px;
}

.field-input:focus,
.field-select:focus,
.field-textarea:focus {
  outline: none;
  border-color: var(--sgs-accent);
  box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.15);
}

.field-textarea {
  resize: vertical;
  min-height: 80px;
}

.field-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* Password toggle */
.password-wrapper {
  position: relative;
}

.password-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
}

/* Preview card */
.preview-card {
  position: sticky;
  top: 96px;
}

.qr-preview-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 24px;
  gap: 24px;
}

#qr-canvas {
  transition: opacity 300ms var(--ease-out);
  border-radius: var(--radius-md);
  max-width: 100%;
  overflow: auto;
}

#qr-canvas canvas,
#qr-canvas svg {
  display: block;
}

.qr-placeholder {
  width: 280px;
  height: 280px;
  border: 2px dashed var(--border-colour);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-secondary);
}

.qr-placeholder-icon { font-size: 48px; opacity: 0.4; }
.qr-placeholder-text { font-size: 14px; }

/* Action buttons */
.action-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 0 24px 24px;
}

.btn {
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 150ms var(--ease-out);
  min-height: 44px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(0) scale(0.97);
}

.btn-primary {
  background: var(--sgs-accent);
  color: white;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-colour);
}

.btn-secondary:hover {
  background: var(--border-colour);
}

/* Customisation panel */
.customisation-panel {
  margin-top: 32px;
}

.accordion-item {
  background: var(--bg-card);
  border: 1px solid var(--border-colour);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.accordion-trigger {
  width: 100%;
  padding: 16px 24px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  transition: background 150ms ease;
}

.accordion-trigger:hover {
  background: var(--bg-secondary);
}

.accordion-icon {
  transition: transform 250ms var(--ease-out);
  font-size: 12px;
  color: var(--text-secondary);
}

.accordion-item.open .accordion-icon {
  transform: rotate(180deg);
}

.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 250ms var(--ease-out);
}

.accordion-item.open .accordion-content {
  max-height: 800px;
}

.accordion-inner {
  padding: 0 24px 24px;
}

/* Colour picker */
.colour-picker-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.colour-swatch {
  width: 44px;
  height: 44px;
  border: 2px solid var(--border-colour);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
  overflow: hidden;
}

.colour-swatch::-webkit-color-swatch-wrapper { padding: 0; }
.colour-swatch::-webkit-color-swatch { border: none; }
.colour-swatch::-moz-color-swatch { border: none; }

.colour-hex {
  width: 100px;
  padding: 8px 12px;
  border: 1px solid var(--border-colour);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  min-height: 44px;
}

/* Range slider */
.range-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.range-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.range-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  padding: 2px 8px;
  border-radius: 4px;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border-colour);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--sgs-accent);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(233,69,96,0.3);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--sgs-accent);
  cursor: pointer;
  border: none;
}

/* Style selector */
.style-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.style-option {
  padding: 8px 16px;
  border: 1px solid var(--border-colour);
  border-radius: var(--radius-pill);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 150ms var(--ease-out);
  min-height: 36px;
  font-family: inherit;
}

.style-option:hover {
  border-color: var(--sgs-accent);
  color: var(--sgs-accent);
}

.style-option.active {
  background: var(--sgs-accent);
  color: white;
  border-color: var(--sgs-accent);
}

/* Gradient toggle */
.gradient-toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.toggle-switch input { display: none; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border-colour);
  border-radius: 13px;
  cursor: pointer;
  transition: background 200ms ease;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  top: 3px;
  left: 3px;
  transition: transform 200ms var(--ease-out);
  box-shadow: var(--shadow-sm);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--sgs-accent);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

.gradient-options {
  display: none;
  gap: 16px;
  margin-top: 16px;
}

.gradient-options.visible { display: flex; flex-wrap: wrap; }

/* Logo upload */
.logo-upload-area {
  border: 2px dashed var(--border-colour);
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 200ms ease, background 200ms ease;
}

.logo-upload-area:hover {
  border-color: var(--sgs-accent);
  background: rgba(233, 69, 96, 0.03);
}

.logo-upload-area.has-logo {
  border-style: solid;
  border-color: var(--sgs-accent);
}

.logo-preview {
  max-width: 80px;
  max-height: 80px;
  border-radius: 8px;
  margin-bottom: 8px;
}

.logo-upload-text {
  font-size: 13px;
  color: var(--text-secondary);
}

.logo-remove {
  margin-top: 8px;
  padding: 4px 12px;
  font-size: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-colour);
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-secondary);
  font-family: inherit;
}

/* Error correction info */
.ec-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.ec-option {
  padding: 10px 8px;
  border: 1px solid var(--border-colour);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  text-align: center;
  cursor: pointer;
  transition: all 150ms var(--ease-out);
  min-height: 44px;
  font-family: inherit;
}

.ec-option:hover {
  border-color: var(--sgs-accent);
}

.ec-option.active {
  background: var(--sgs-accent);
  color: white;
  border-color: var(--sgs-accent);
}

.ec-label {
  font-size: 16px;
  font-weight: 700;
  display: block;
}

.ec-desc {
  font-size: 10px;
  opacity: 0.7;
  display: block;
  margin-top: 2px;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--sgs-dark);
  color: white;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 300ms var(--ease-out);
  max-width: 320px;
}

[data-theme="dark"] .toast {
  background: var(--sgs-accent);
}

.toast.removing {
  animation: toastOut 200ms ease-in forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateY(8px) scale(0.95); }
}

/* Tooltip */
.tooltip-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--border-colour);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  cursor: help;
  position: relative;
}

.tooltip-trigger:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--sgs-dark);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
  z-index: 10;
  box-shadow: var(--shadow-md);
  max-width: 240px;
  white-space: normal;
  line-height: 1.4;
}

/* Footer */
.footer {
  text-align: center;
  padding: 32px 24px;
  color: var(--text-secondary);
  font-size: 13px;
  border-top: 1px solid var(--border-colour);
  margin-top: 48px;
}

.footer a {
  color: var(--sgs-accent);
  text-decoration: none;
  font-weight: 500;
}

.footer a:hover { text-decoration: underline; }

/* Share link section */
.share-section {
  padding: 0 24px 24px;
}

.share-url {
  display: flex;
  gap: 8px;
}

.share-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border-colour);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  min-height: 44px;
}

/* Responsive */
@media (max-width: 768px) {
  .header-inner { padding: 12px 16px; }
  .logo-divider, .logo-subtitle { display: none; }
  .main-container { padding: 16px; }
  .card-body { padding: 16px; }
  .accordion-inner { padding: 0 16px 16px; }
  .action-buttons { padding: 0 16px 16px; }
  .ec-options { grid-template-columns: repeat(2, 1fr); }

  .preview-card { position: static; }
}

@media (max-width: 480px) {
  .tabs { min-width: auto; }
  .tab-btn { padding: 8px 12px; font-size: 12px; }
  .tab-icon { display: none; }
}

/* Fade-in animation for QR */
.qr-fade-in {
  animation: fadeIn 300ms var(--ease-out);
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* Loading state */
.qr-loading {
  opacity: 0.5;
  transition: opacity 150ms ease;
}
