/* ===========================================================
   Icon QR Generator — styles
   =========================================================== */

:root {
  --bg-start: #6a5cff;
  --bg-end: #35c8e0;
  --card-bg: #ffffff;
  --text-main: #1c1d2b;
  --text-muted: #656b83;
  --accent: #5a4bff;
  --accent-hover: #4738e0;
  --accent-contrast: #ffffff;
  --border: #dfe2ec;
  --dropzone-bg: #f6f7fb;
  --dropzone-bg-active: #eef0ff;
  --error: #d13c3c;
  --error-bg: #fdecec;
  --live: #2ec27e;
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow: 0 20px 45px -15px rgba(30, 20, 90, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-start: #211f38;
    --bg-end: #17222b;
    --card-bg: #1c1b2e;
    --text-main: #f1f1f7;
    --text-muted: #a6a9c2;
    --accent: #7c6cff;
    --accent-hover: #9184ff;
    --accent-contrast: #ffffff;
    --border: #34324f;
    --dropzone-bg: #242237;
    --dropzone-bg-active: #2c2a49;
    --error: #ff8686;
    --error-bg: #3a2029;
    --live: #3ddc97;
    --shadow: 0 20px 45px -15px rgba(0, 0, 0, 0.6);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text-main);
  background: linear-gradient(135deg, var(--bg-start), var(--bg-end));
  background-attachment: fixed;
  padding: 24px 16px 16px;
}

/* ---------- dashboard shell ---------- */

.app {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.topbar {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px 28px;
}

.topbar h1 {
  margin: 0 0 6px;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 20px;
  align-items: start;
}

.panel {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
  min-width: 0;
}

.panel--preview {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 0 rgba(46, 194, 126, 0.55);
  animation: live-pulse 2s ease-out infinite;
}

@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(46, 194, 126, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(46, 194, 126, 0); }
  100% { box-shadow: 0 0 0 0 rgba(46, 194, 126, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot {
    animation: none;
  }
}

.app-footer {
  text-align: center;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.85);
  padding: 4px 0 8px;
}

.app-footer a {
  color: #ffffff;
  font-weight: 600;
  text-decoration: underline;
}

/* ---------- form ---------- */

form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field__label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
}

.required {
  color: var(--error);
  font-weight: 500;
}

.optional {
  color: var(--text-muted);
  font-weight: 500;
}

.text-input {
  width: 100%;
  resize: vertical;
  min-height: 64px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-main);
  background: var(--dropzone-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(90, 75, 255, 0.15);
}

.text-input.input-error {
  border-color: var(--error);
}

.error-msg {
  margin: 0;
  font-size: 0.82rem;
  color: var(--error);
  background: var(--error-bg);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

/* ---------- dropzone ---------- */

.dropzone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  background: var(--dropzone-bg);
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 96px;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: var(--accent);
  background: var(--dropzone-bg-active);
  outline: none;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: var(--dropzone-bg-active);
  box-shadow: 0 0 0 3px rgba(90, 75, 255, 0.15);
}

.dropzone__content {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  text-align: center;
}

.dropzone__placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.dropzone__icon {
  width: 26px;
  height: 26px;
  color: var(--accent);
}

.dropzone__placeholder p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.4;
}

.link-text {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
}

.image-preview {
  max-width: 100%;
  max-height: 120px;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

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

.clear-image-btn {
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--error);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 0;
  text-decoration: underline;
}

.clear-image-btn:hover {
  opacity: 0.8;
}

/* ---------- customize panel ---------- */

.customize {
  background: var(--dropzone-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.customize summary {
  cursor: pointer;
  padding: 12px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  user-select: none;
}

.customize summary:hover {
  background: var(--dropzone-bg-active);
}

.customize__hint {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.8rem;
}

.customize__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 4px 14px 12px;
}

.cgroup {
  margin: 0;
  padding: 10px 12px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.cgroup:disabled {
  opacity: 0.45;
}

.cgroup legend {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
  padding: 0 4px;
}

.crow {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.crow label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.crow--inline {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.crow--inline label {
  flex: 1;
}

.cval {
  font-weight: 500;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.crow select {
  width: 100%;
  padding: 7px 8px;
  font-family: inherit;
  font-size: 0.82rem;
  color: var(--text-main);
  background: var(--dropzone-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
}

.crow select:focus {
  outline: none;
  border-color: var(--accent);
}

.crow input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.crow input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.crow input[type="color"] {
  width: 40px;
  height: 26px;
  padding: 2px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--dropzone-bg);
  cursor: pointer;
  flex-shrink: 0;
}

#dots-gradient-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 2px;
  border-top: 1px dashed var(--border);
}

#dots-gradient-controls[hidden] {
  display: none;
}

.reset-btn {
  display: block;
  margin: 0 14px 14px;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 0;
  text-decoration: underline;
}

.reset-btn:hover {
  opacity: 0.8;
}

/* ---------- button ---------- */

.generate-btn {
  width: 100%;
  padding: 13px 20px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-contrast);
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  box-shadow: 0 8px 20px -8px rgba(90, 75, 255, 0.6);
}

.generate-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px -8px rgba(90, 75, 255, 0.7);
}

.generate-btn:active {
  transform: translateY(0);
}

/* ---------- result / live preview ---------- */

.result-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.qr-placeholder {
  margin: 0;
  padding: 28px 16px;
  font-size: 0.88rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  width: 100%;
}

.qr-container {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 12px;
  background: var(--dropzone-bg);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  transition: box-shadow 0.15s ease, transform 0.1s ease;
  max-width: 100%;
  overflow: hidden;
}

.qr-container:hover {
  box-shadow: 0 10px 24px -10px rgba(30, 20, 90, 0.35);
  transform: translateY(-1px);
}

.qr-container canvas,
.qr-container img,
.qr-container svg {
  max-width: 100%;
  height: auto;
  display: block;
}

.qr-hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* ---------- responsive ---------- */

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .panel--preview {
    position: static;
    order: -1; /* preview on top on small screens so typing shows feedback */
  }
}

@media (max-width: 640px) {
  .customize__grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 400px) {
  body {
    padding: 16px 10px 10px;
  }

  .panel,
  .topbar {
    padding: 20px 16px;
    border-radius: var(--radius-md);
  }

  .topbar h1 {
    font-size: 1.3rem;
  }
}
