/* ============================================================================
   QR Generator — styles.css
   Workshop vibe: dark sidebar, light preview, restrained chrome.
   ============================================================================ */

/* ---------- Reset / base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: #1a1a1a;
  background: #f5f5f7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- App shell (two-pane flex) ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  flex: 0 0 360px;
  width: 360px;
  /* Sticky full-height column so the long control stack scrolls inside the
     sidebar instead of dragging the preview off-screen. */
  position: sticky;
  top: 0;
  height: 100vh;
  background: #1c1f24;
  color: #e6e8eb;
  padding: 22px 20px 40px;
  overflow-y: auto;
  border-right: 1px solid #0d0f12;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.03);
}

.preview {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background:
    radial-gradient(circle at 50% 30%, #ffffff 0%, #ececef 70%, #dadcdf 100%);
  min-height: 100vh;
}

/* ---------- Brand ---------- */
.brand {
  margin: 0 0 22px 0;
  padding-bottom: 18px;
  border-bottom: 1px solid #2a2e35;
}

.brand-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #ffffff;
}

.brand-version {
  margin-left: 6px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: #8a93a0;
  vertical-align: middle;
}

.brand-tagline {
  margin: 4px 0 0 0;
  font-size: 12px;
  color: #8a93a0;
  letter-spacing: 0.02em;
}

/* ---------- Panels ---------- */
.panel {
  margin-bottom: 22px;
  padding-bottom: 22px;
  border-bottom: 1px solid #2a2e35;
}
.panel:last-of-type {
  border-bottom: none;
}

.panel-title {
  margin: 0 0 12px 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #8a93a0;
}

/* ---------- Tabs (input mode) ---------- */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 14px;
}

.tab {
  appearance: none;
  background: #2a2e35;
  color: #c8cdd4;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.tab:hover {
  background: #353a43;
  color: #ffffff;
}
.tab.is-active {
  background: #ff8800;
  color: #1c1f24;
  border-color: #ff8800;
}

/* ---------- Form fields ---------- */
.field {
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
}
.field label {
  font-size: 12px;
  color: #b8bec7;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
}

.field-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 12px;
}
.field-row .field {
  margin-bottom: 0;
  flex: 1 1 auto;
}

input[type="text"],
input[type="url"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="password"],
select,
textarea {
  background: #14171b;
  color: #e6e8eb;
  border: 1px solid #2a2e35;
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.12s ease;
}
input[type="text"]:focus,
input[type="url"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  border-color: #ff8800;
}

textarea {
  resize: vertical;
  min-height: 70px;
}

input[type="range"] {
  width: 100%;
  accent-color: #ff8800;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #c8cdd4;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.input-form-container {
  background: #14171b;
  border: 1px solid #2a2e35;
  border-radius: 8px;
  padding: 12px;
}
.placeholder-note {
  font-size: 12px;
  color: #6a727d;
  font-style: italic;
}

/* ---------- Color grid ---------- */
.color-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.color-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.color-cell label {
  font-size: 12px;
  color: #b8bec7;
}
.color-cell input[type="color"] {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 30px;
  background: #14171b;
  border: 1px solid #2a2e35;
  border-radius: 6px;
  padding: 2px;
  cursor: pointer;
}
.color-cell input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}
.color-cell input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

/* ---------- Drop zone ---------- */
.dropzone {
  border: 2px dashed #2f3540;
  border-radius: 8px;
  padding: 18px 14px;
  text-align: center;
  background: #14171b;
  margin-bottom: 12px;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.dropzone.is-hover {
  border-color: #ff8800;
  background: #1f2128;
}
.dropzone-text {
  margin: 0 0 4px 0;
  font-size: 13px;
  color: #c8cdd4;
}
.dropzone-sub {
  margin: 0 0 8px 0;
  font-size: 11px;
  color: #6a727d;
}

/* ---------- Caption image ---------- */
.caption-image-field {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #2a2e35;
}
.caption-image-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-bottom: 8px;
  padding: 6px;
  border: 1px solid #2a2e35;
  border-radius: 6px;
  background: #14171b;
}
.caption-image-thumb {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 4px;
  background: #1c1f24;
}
.caption-image-name {
  min-width: 0;
  font-size: 12px;
  color: #8a93a0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#caption-image-warning {
  color: #ff8800;
}

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  display: inline-block;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease,
    transform 0.06s ease;
  border: 1px solid transparent;
  user-select: none;
  line-height: 1.2;
}
.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: #ff8800;
  color: #1c1f24;
  border-color: #ff8800;
}
.btn-primary:hover {
  background: #ff9a26;
  border-color: #ff9a26;
}

.btn-secondary {
  background: transparent;
  color: #e6e8eb;
  border-color: #3a414d;
}
.btn-secondary:hover {
  background: #2a2e35;
  border-color: #4a525f;
}

.btn-ghost {
  background: transparent;
  color: #8a93a0;
  border-color: transparent;
  padding: 6px 0;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn-ghost:hover {
  color: #ffffff;
}

.export-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.is-hidden {
  display: none !important;
}

/* ---------- Preview pane ---------- */
.preview-canvas {
  width: 100%;
  max-width: 640px;
  aspect-ratio: 1 / 1;
  background: #ffffff;
  border-radius: 12px;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.06),
    0 18px 38px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 16px;
}

#qr-preview {
  width: 100%;
  height: 100%;
  display: block;
}

.preview-meta {
  margin-top: 16px;
  font-size: 12px;
  color: #5a6068;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* ---------- Responsive (single-column under 900px) ---------- */
@media (max-width: 900px) {
  .app-shell {
    flex-direction: column;
  }
  .sidebar {
    flex: 0 0 auto;
    width: 100%;
    position: static;
    height: auto;
    max-height: none;
    overflow-y: visible;
    border-right: none;
    border-bottom: 1px solid #0d0f12;
  }
  .preview {
    min-height: auto;
    padding: 24px;
  }
  .preview-canvas {
    max-width: 92vw;
  }
}

/* Touch targets. Pointer-coarse rather than a width breakpoint, because a
   small window on a desktop still has a mouse and doesn't need finger-sized
   controls. 44px is the accessibility floor for a touch target. */
@media (pointer: coarse) {
  .btn-icon,
  .tab,
  .chip,
  .dropzone .btn,
  #btn-remove-caption-image {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 44px;
  }
  input[type="color"] {
    height: 44px;
  }
  input[type="range"] {
    height: 44px;
  }
  .checkbox-label input[type="checkbox"],
  .checkbox input[type="checkbox"] {
    width: 22px;
    height: 22px;
  }
  select,
  input[type="text"],
  input[type="url"],
  input[type="email"],
  input[type="tel"],
  input[type="number"] {
    min-height: 44px;
    /* iOS zooms the page when a focused field is under 16px. */
    font-size: 16px;
  }
}

@media (max-width: 560px) {
  .sidebar {
    padding: 18px 14px 32px;
  }
  .color-grid {
    grid-template-columns: 1fr;
  }
  .field-row {
    flex-wrap: wrap;
  }
  .field-row .field {
    flex: 1 1 140px;
  }
  .field-row > .checkbox {
    flex: 1 0 100%;
  }
  .degrade-panel {
    flex-direction: column;
    align-items: flex-start;
  }
  .degrade-note {
    max-width: none;
  }
}

/* ---------- Brand row / history buttons ---------- */
.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.history-buttons {
  display: flex;
  gap: 4px;
  flex: 0 0 auto;
}

.btn-icon {
  appearance: none;
  background: #2a2e35;
  color: #c8cdd4;
  border: 1px solid transparent;
  border-radius: 6px;
  width: 26px;
  height: 26px;
  font-size: 14px;
  line-height: 1;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.btn-icon:hover:not(:disabled) {
  background: #353a43;
  color: #ffffff;
}
.btn-icon:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ---------- Shared hint text ---------- */
.field-hint {
  display: block;
  margin: 4px 0 0 0;
  font-size: 11px;
  line-height: 1.4;
  color: #8a93a0;
}

.checkbox-label {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  justify-content: flex-start !important;
  font-size: 12px;
  color: #c8cdd4;
  cursor: pointer;
  user-select: none;
}

input[type="checkbox"] {
  accent-color: #ff8800;
  cursor: pointer;
}

/* ---------- Preset chips ---------- */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.chip {
  appearance: none;
  background: #2a2e35;
  color: #c8cdd4;
  border: 1px solid #343a43;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.chip:hover {
  background: #353a43;
  color: #ffffff;
  border-color: #4a525f;
}
.chip.is-active {
  background: #ff8800;
  color: #1c1f24;
  border-color: #ff8800;
}

.btn-block {
  display: block;
  width: 100%;
}

/* ---------- Numeric readouts (physical size, contrast) ---------- */
.readout {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  background: #14171b;
  border: 1px solid #2a2e35;
  border-left-width: 3px;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.readout-value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: #e6e8eb;
}
.readout-sm .readout-value {
  font-size: 19px;
}

.readout-unit {
  font-size: 12px;
  color: #8a93a0;
}

.readout-detail {
  flex: 1 0 100%;
  font-size: 11px;
  line-height: 1.4;
  color: #8a93a0;
}

.readout[data-tier="good"] { border-left-color: #35c46a; }
.readout[data-tier="warn"] { border-left-color: #ffb020; }
.readout[data-tier="fail"] { border-left-color: #e5533d; }
.readout[data-tier="good"] .readout-value { color: #4fd784; }
.readout[data-tier="warn"] .readout-value { color: #ffb020; }
.readout[data-tier="fail"] .readout-value { color: #ff7059; }

/* ---------- Scannability check list ---------- */
.check-list {
  list-style: none;
  margin: 0 0 10px 0;
  padding: 0;
}

.check-item {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #23272e;
}
.check-item:last-child {
  border-bottom: none;
}

.check-icon {
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}
.check-item[data-status="pass"] .check-icon { color: #4fd784; }
.check-item[data-status="warn"] .check-icon { color: #ffb020; }
.check-item[data-status="fail"] .check-icon { color: #ff7059; }

.check-label {
  font-size: 12px;
  color: #c8cdd4;
}

.check-detail {
  grid-column: 2;
  font-size: 11px;
  line-height: 1.4;
  color: #8a93a0;
}

.check-empty {
  font-size: 12px;
  color: #6a727d;
  font-style: italic;
  padding: 4px 0;
}

/* ---------- Degradation preview ---------- */
.preview-tools {
  margin-top: 14px;
}
.preview-tools .checkbox {
  color: #5a6068;
}

.degrade-panel {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #ffffff;
  border: 1px solid #dadcdf;
  border-radius: 10px;
  padding: 12px 14px;
  max-width: 100%;
}

#degrade-canvas {
  flex: 0 0 auto;
  width: 96px;
  height: 96px;
  image-rendering: auto;
  background: #ffffff;
  border: 1px solid #dadcdf;
  border-radius: 4px;
}

.degrade-note {
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
  color: #5a6068;
  max-width: 220px;
}

/* ---------- Focus visibility ---------- */
a:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid #ff8800;
  outline-offset: 2px;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Scrollbar polish (sidebar) ---------- */
.sidebar::-webkit-scrollbar {
  width: 8px;
}
.sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
  background: #2a2e35;
  border-radius: 4px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
  background: #3a414d;
}
