/* Expeat Studio Design — styles.css
 * Light theme matching the exact white background of the exp/eat logo.
 * Optimized for iPad Safari (landscape & portrait) and desktop.
 */
:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --success: #16a34a;
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------- Topbar & Brand ---------- */
.topbar {
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.app-logo {
  max-height: 42px;
  max-width: 150px;
  object-fit: contain;
  background: #ffffff;
}

.brand h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--text);
}

.brand .sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.lang-picker select {
  padding: 7px 12px;
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  font-weight: 500;
}
.lang-picker select:focus { border-color: var(--accent); }

/* ---------- 3 Steps Banner ---------- */
.steps-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px 20px;
  background: #f1f5f9;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ffffff;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  flex: none;
}

.step-text {
  display: flex;
  flex-direction: column;
}

.step-text strong {
  font-size: 12.5px;
  color: var(--text);
  font-weight: 600;
}

.step-text span {
  font-size: 11px;
  color: var(--muted);
}

.step-arrow {
  color: var(--line-strong);
  font-size: 14px;
  user-select: none;
}

/* ---------- Main Layout ---------- */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: 0;
}

/* iPad Portrait & Mobile */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .steps-bar {
    gap: 8px;
    padding: 8px 12px;
    justify-content: flex-start;
    overflow-x: auto;
  }
  .step-arrow { display: none; }
}

/* ---------- Panel (Controls) ---------- */
.panel {
  background: #ffffff;
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 900px) {
  .panel {
    border-right: none;
    border-top: 1px solid var(--line);
    order: 2;
  }
}

.group {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}

.group h2 {
  margin: 0 0 10px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--muted);
  font-weight: 700;
}

.group[data-requires-img] {
  opacity: 0.45;
  pointer-events: none;
  transition: opacity 0.2s;
}

body.has-image .group[data-requires-img] {
  opacity: 1;
  pointer-events: auto;
}

.info {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

/* ---------- Dropzone ---------- */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  padding: 24px 14px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  cursor: pointer;
  background: #ffffff;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone.small { padding: 14px 10px; }
.dz-title { font-weight: 600; font-size: 13.5px; color: var(--text); }
.dz-sub { color: var(--muted); font-size: 12px; }

/* ---------- Controlli, Slider e Segmented ---------- */
.segmented {
  display: flex;
  gap: 4px;
  background: #e2e8f0;
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 12px;
}

.seg {
  flex: 1;
  min-height: 36px;
  padding: 8px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.seg.active {
  background: #ffffff;
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Colorbar & Inputs */
.colorbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.colorbar .preview {
  width: 44px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  flex: none;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.05);
}

.colorbar input[type=text] {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  padding: 7px 10px;
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--line-strong);
  font: 14px monospace;
}
.colorbar input[type=text]:focus { outline: none; border-color: var(--accent); }
.colorbar input[type=text].bad { border-color: #ef4444; }

.colorbar input[type=color] {
  width: 44px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  cursor: pointer;
  flex: none;
}

/* Sliders (Touch Friendly per iPad) */
.slider {
  display: block;
  margin-bottom: 12px;
}

.slider span {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.slider b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

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

input[type=range].scale {
  -webkit-appearance: none;
  appearance: none;
  height: 16px;
  margin: 4px 0;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--track, #e2e8f0);
  outline: none;
}

input[type=range].scale.hue {
  --track: linear-gradient(90deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
}

/* Touch thumb iPad: min 28px */
input[type=range].scale::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3), 0 0 0 1px rgba(0,0,0,0.1);
  cursor: grab;
}

input[type=range].scale::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3), 0 0 0 1px rgba(0,0,0,0.1);
  cursor: grab;
}

/* Presets */
.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.presets button {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s, box-shadow 0.1s;
}
.presets button:hover, .presets button:active {
  transform: scale(1.1);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* Selects */
.select {
  display: block;
  margin-bottom: 10px;
}
.select span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}
select {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--line-strong);
  font-size: 14px;
}

/* Buttons (Touch Targets min 44px) */
.btn {
  min-height: 42px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.btn:hover { border-color: var(--accent); background: #f8fafc; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(37,99,235,0.3);
}
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; color: var(--muted); border-color: transparent; }
.btn.ghost:hover { color: var(--text); background: rgba(0,0,0,0.03); }
.btn.full { width: 100%; margin-top: 8px; }
.btn.small { min-height: 32px; font-size: 12px; padding: 4px 10px; }
.btn[disabled] { opacity: 0.5; cursor: progress; }

/* ---------- Stage (Preview) ---------- */
.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

@media (max-width: 900px) {
  .stage {
    order: 1;
    min-height: 340px;
    height: 45vh;
  }
}

.canvas-wrap {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px;
  min-height: 0;
  overflow: auto;
  background-color: #cbd5e1;
  background-image:
    linear-gradient(45deg, #e2e8f0 25%, transparent 25%, transparent 75%, #e2e8f0 75%),
    linear-gradient(45deg, #e2e8f0 25%, transparent 25%, transparent 75%, #e2e8f0 75%);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
}

#preview {
  max-width: 100%;
  max-height: 100%;
  box-shadow: 0 12px 35px rgba(15, 23, 42, 0.2);
  border-radius: 6px;
  image-rendering: auto;
}

body:not(.has-image) #preview { display: none; }
.empty { text-align: center; color: #475569; padding: 24px; }
.empty .dz-title { font-size: 15px; font-weight: 600; color: #1e293b; }
.empty .hint { font-size: 12.5px; opacity: 0.85; margin-top: 4px; }
body.has-image .empty { display: none; }

.stagebar {
  border-top: 1px solid var(--line);
  background: #ffffff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #0f172a;
  border: 1px solid #1e293b;
  color: #ffffff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

/* ==========================================================================
   Pixabay Wallpaper Gallery & Attribution
   ========================================================================== */
.segmented-sub {
  margin-bottom: 12px;
}

.segmented-sub .seg {
  font-size: 12px;
  padding: 6px 10px;
}

.segmented-mini {
  padding: 2px;
  background: var(--bg);
}

.segmented-mini .seg {
  font-size: 11px;
  padding: 4px 8px;
}

.category-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.chip {
  appearance: none;
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip:hover {
  background: var(--bg);
  border-color: var(--line-strong);
}

.chip.active {
  background: var(--text);
  color: #ffffff;
  border-color: var(--text);
}

.wp-filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.wp-filter-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.wp-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  max-height: 250px;
  overflow-y: auto;
  padding: 2px;
  margin-bottom: 10px;
  border-radius: 8px;
  scrollbar-width: thin;
}

.wp-card {
  position: relative;
  appearance: none;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  padding: 0;
  background: #e2e8f0;
  cursor: pointer;
  outline: none;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  aspect-ratio: 4 / 3;
}

.wp-card:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.wp-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.15);
}

.wp-card-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.wp-card-author {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.75) 0%, rgba(0, 0, 0, 0) 100%);
  color: #ffffff;
  font-size: 10px;
  font-weight: 500;
  padding: 12px 6px 4px 6px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wp-card.active::after {
  content: '✓';
  position: absolute;
  top: 5px;
  right: 5px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wp-empty {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 20px 0;
}

/* Attribuzione e Licenza Pixabay */
.pixabay-attribution-bar {
  border-top: 1px solid var(--line);
  background: #f8fafc;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

.pixabay-badge {
  background: #0284c7;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: 4px;
  flex: none;
}

#pixabayCreditText {
  color: var(--text);
  font-size: 11.5px;
  flex: 1;
  min-width: 150px;
}

#pixabaySourceLink {
  color: var(--accent);
  text-decoration: underline;
  font-size: 11.5px;
  font-weight: 500;
  flex: none;
}

#pixabaySourceLink:hover {
  color: #000000;
}

