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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans TC", sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  min-height: 100vh;
}

/* ── Layout shell ──────────────────────────────────────── */
.page-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

/* ── Header ────────────────────────────────────────────── */
header {
  text-align: center;
  margin-bottom: 2.25rem;
}
header h1 {
  font-size: 2rem;
  font-weight: 800;
  color: #2563eb;
  letter-spacing: -0.5px;
}
header p {
  margin-top: 0.35rem;
  font-size: 1rem;
  color: #64748b;
  font-weight: 500;
}

/* ── Upload zone ───────────────────────────────────────── */
#drop-zone {
  border: 2.5px dashed #93c5fd;
  border-radius: 14px;
  background: #fff;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative;
  user-select: none;
}
#drop-zone:hover,
#drop-zone.drag-over {
  border-color: #2563eb;
  background: #eff6ff;
}
#drop-zone svg {
  display: block;
  margin: 0 auto 1rem;
  color: #93c5fd;
  transition: color .2s;
}
#drop-zone:hover svg,
#drop-zone.drag-over svg { color: #2563eb; }

#drop-zone .dz-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #334155;
}
#drop-zone .dz-sub {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: #94a3b8;
}
#file-input { display: none; }
.dz-sample {
  margin-top: .55rem;
  font-size: 0.8rem;
  color: #94a3b8;
}
.dz-sample a {
  color: #2563eb;
  text-decoration: none;
  font-weight: 600;
  margin-left: .35rem;
}
.dz-sample a:hover { text-decoration: underline; }

/* ── Spinner overlay ───────────────────────────────────── */
#spinner {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin: 1.25rem 0 0.5rem;
  font-size: 0.95rem;
  color: #2563eb;
  font-weight: 600;
}
#spinner.visible { display: flex; }
.spin-ring {
  width: 22px; height: 22px;
  border: 3px solid #bfdbfe;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Log area ──────────────────────────────────────────── */
#log-area {
  margin-top: 1.25rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1rem 1.25rem;
  max-height: 220px;
  overflow-y: auto;
  font-size: 0.82rem;
  line-height: 1.7;
  display: none;
}
#log-area.visible { display: block; }
.log-ok   { color: #16a34a; }
.log-err  { color: #dc2626; }
.log-info { color: #475569; }
.log-warn { color: #d97706; }

/* ── Toolbar (ZIP button + count) ──────────────────────── */
#toolbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  margin: 2rem 0 1rem;
}
#toolbar.visible { display: flex; }
#toolbar .count-label {
  font-size: 0.95rem;
  color: #475569;
  font-weight: 600;
}

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .55rem 1.25rem;
  border-radius: 8px;
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary   { background: #2563eb; color: #fff; }
.btn-primary:not(:disabled):hover { background: #1d4ed8; }
.btn-secondary { background: #e2e8f0; color: #334155; }
.btn-secondary:not(:disabled):hover { background: #cbd5e1; }
.btn-sm {
  padding: .4rem .85rem;
  font-size: 0.8rem;
  border-radius: 6px;
}

/* ── Results grid ──────────────────────────────────────── */
#results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.25rem;
}

/* ── QR Card ───────────────────────────────────────────── */
.qr-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
  transition: box-shadow .2s;
}
.qr-card:hover {
  box-shadow: 0 4px 12px rgba(37,99,235,.15), 0 8px 24px rgba(0,0,0,.1);
}
.qr-canvas-wrap {
  width: 160px; height: 160px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.qr-canvas-wrap canvas,
.qr-canvas-wrap img {
  max-width: 160px;
  max-height: 160px;
}
.qr-filename {
  font-size: 0.78rem;
  color: #475569;
  word-break: break-all;
  text-align: center;
  max-width: 160px;
}

/* ── OR divider ────────────────────────────────────────── */
.or-divider {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 1.5rem 0;
  color: #94a3b8;
  font-size: 0.85rem;
  font-weight: 600;
}
.or-divider::before,
.or-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e2e8f0;
}

/* ── Quick input ────────────────────────────────────────── */
#quick-input {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 1.5rem 1.75rem;
  margin-bottom: 1rem;
}
.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: #334155;
  margin-bottom: 1.25rem;
}
.qi-form {
  display: flex;
  flex-direction: column;
  gap: .9rem;
}
.qi-row {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.qi-row label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #475569;
}
.qi-row .optional {
  font-weight: 400;
  color: #94a3b8;
}
.qi-row input[type="text"],
.qi-row input[type="password"],
.qi-row textarea,
.qi-row select {
  padding: .5rem .75rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.92rem;
  color: #1e293b;
  background: #f8fafc;
  transition: border-color .15s, outline .15s, height .2s;
  font-family: inherit;
  width: 100%;
}
.qi-row input[type="text"]:focus,
.qi-row input[type="password"]:focus,
.qi-row textarea:focus,
.qi-row select:focus {
  outline: 2px solid #2563eb;
  border-color: transparent;
  background: #fff;
}
.qi-row textarea {
  resize: vertical;
  min-height: 2.4rem;
  line-height: 1.5;
  overflow: hidden;
}
.qi-row textarea.expanded {
  min-height: 7rem;
  overflow: auto;
  resize: vertical;
}
#qi-wifi-rows {
  display: none;
  flex-direction: column;
  gap: .9rem;
}
#qi-wifi-rows.visible { display: flex; }
.qi-error {
  font-size: 0.83rem;
  color: #dc2626;
  min-height: 1.2em;
}

/* ── Advanced options panel ────────────────────────────── */
#advanced-opts {
  margin-top: 1rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
}
#advanced-opts summary {
  padding: .7rem 1.25rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: .5rem;
}
#advanced-opts summary::before {
  content: "▸";
  font-size: .8rem;
  transition: transform .2s;
}
#advanced-opts[open] summary::before { transform: rotate(90deg); }
#advanced-opts summary:hover { background: #f8fafc; }
.opts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem 1.5rem;
  padding: .75rem 1.25rem 1.25rem;
  border-top: 1px solid #f1f5f9;
}
.opts-grid > label {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #475569;
}
.opts-grid select,
.opts-grid input[type="number"] {
  padding: .4rem .6rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.88rem;
  color: #1e293b;
  background: #f8fafc;
  width: 100%;
}
.opts-grid select:focus,
.opts-grid input[type="number"]:focus {
  outline: 2px solid #2563eb;
  border-color: transparent;
}
.radio-group {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  padding-top: .2rem;
}
.radio-group label {
  display: flex;
  align-items: center;
  gap: .3rem;
  font-weight: 500;
  font-size: 0.88rem;
  color: #334155;
  cursor: pointer;
}

/* ── Responsive tweaks ─────────────────────────────────── */
@media (max-width: 480px) {
  header h1 { font-size: 1.5rem; }
  #drop-zone { padding: 2rem 1rem; }
}
