/* Pronto Ristrutturare — Generatore Capitolato */

:root {
  --bg: #0b0b10;
  --bg-subtle: #0f0f16;
  --surface: #151520;
  --surface2: #1e1e2d;
  --surface3: #282840;
  --border: #2a2a3e;
  --border-hover: #3a3a54;

  --text: #ededef;
  --text-secondary: #b0aeb8;
  --text-muted: #7a7888;
  --text-dim: #55536a;

  --accent: #c9a227;
  --accent-hover: #ddb82e;
  --accent-glow: rgba(201, 162, 39, 0.15);
  --accent-subtle: rgba(201, 162, 39, 0.08);

  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.1);
  --error: #f87171;
  --error-bg: rgba(248, 113, 113, 0.1);

  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 20px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 40px var(--accent-glow);

  --font-sans: "DM Sans", system-ui, -apple-system, sans-serif;
  --font-serif: "Libre Baskerville", Georgia, serif;

  --transition-fast: 0.15s ease;
  --transition: 0.25s ease;
  --transition-slow: 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.hidden { display: none !important; }

/* ===== APP LAYOUT ===== */
.app {
  max-width: 780px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== HEADER ===== */
.header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.logo {
  font-family: var(--font-serif);
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0;
  letter-spacing: 0.01em;
}

.logo-badge {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  background: var(--accent-subtle);
  border: 1px solid rgba(201, 162, 39, 0.2);
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
}

.tagline {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ===== STATE CARDS (loading, success, error, generating) ===== */
.state-card {
  text-align: center;
  padding: 4rem 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  animation: fadeUp 0.4s var(--transition-slow);
}

.state-label {
  margin: 1.25rem 0 0;
  font-size: 1rem;
  color: var(--text-secondary);
}

.state-hint {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.state-title {
  margin: 1rem 0 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
}

/* Spinner */
.spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto;
  border: 3px solid var(--surface3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-lg {
  width: 48px;
  height: 48px;
  border-width: 4px;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Success state */
.state-success .success-icon {
  color: var(--success);
  background: var(--success-bg);
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.success-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1.5rem;
}

/* Error state */
.state-error .error-icon {
  color: var(--error);
  background: var(--error-bg);
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.state-error .state-label {
  color: var(--error);
}

.state-error .btn-ghost {
  margin-top: 1rem;
}

/* ===== STEPPER ===== */
.stepper {
  display: flex;
  gap: 0;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  margin-bottom: 1.25rem;
  scrollbar-width: none;
}

.stepper::-webkit-scrollbar { display: none; }

.stepper-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
  border: none;
  background: none;
  font-family: inherit;
  color: var(--text-dim);
}

.stepper-item:hover {
  color: var(--text-secondary);
  background: var(--surface);
}

.stepper-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  transition: all var(--transition);
  flex-shrink: 0;
}

.stepper-label {
  font-size: 0.78rem;
  font-weight: 500;
  transition: color var(--transition);
}

.stepper-item.active .stepper-num {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

.stepper-item.active .stepper-label {
  color: var(--text);
}

.stepper-item.completed .stepper-num {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent);
}

.stepper-item.completed .stepper-label {
  color: var(--text-secondary);
}

/* ===== PROGRESS ===== */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.progress-bar {
  flex: 1;
  height: 4px;
  background: var(--surface2);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 2px;
  width: 0%;
  transition: width 0.5s var(--transition-slow);
}

.progress-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 500;
}

/* ===== WIZARD ===== */
.wizard {
  display: flex;
  flex-direction: column;
  animation: fadeUp 0.3s ease;
}

.steps {
  position: relative;
}

/* ===== STEP PANEL ===== */
.step-panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  border: 1px solid var(--border);
  animation: fadeUp 0.3s ease;
}

.step-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

/* ===== FORM FIELDS ===== */
.field {
  margin-bottom: 1.5rem;
}

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

.field > label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.field input[type="text"],
.field input[type="number"],
.field textarea,
.field select {
  width: 100%;
  padding: 0.75rem 1rem;
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: all var(--transition);
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--text-dim);
}

.field textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.6;
}

.field .hint {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

/* ===== RADIO & CHECKBOX — CARD STYLE ===== */
.radio-group,
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.radio-group label,
.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg-subtle);
  transition: all var(--transition);
  margin: 0;
  font-weight: 400;
  font-size: 0.92rem;
}

.radio-group label:hover,
.checkbox-group label:hover {
  border-color: var(--border-hover);
  background: var(--surface2);
}

.radio-group label:has(input:checked),
.checkbox-group label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.radio-group input,
.checkbox-group input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

/* Validation error highlight */
.field-error input,
.field-error textarea,
.field-error select {
  border-color: var(--error) !important;
}

.field-error .radio-group label,
.field-error .checkbox-group label {
  border-color: rgba(248, 113, 113, 0.3);
}

.field-error-msg {
  font-size: 0.78rem;
  color: var(--error);
  margin-top: 0.35rem;
}

/* ===== WIZARD OPTIONS (AI toggle) ===== */
.wizard-options {
  padding: 1.25rem 0;
  margin-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.toggle-switch {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
}

.toggle-switch input { display: none; }

.toggle-track {
  width: 44px;
  height: 24px;
  background: var(--surface3);
  border-radius: 12px;
  position: relative;
  transition: background var(--transition);
  flex-shrink: 0;
}

.toggle-thumb {
  width: 18px;
  height: 18px;
  background: var(--text-muted);
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: all var(--transition);
}

.toggle-switch input:checked ~ .toggle-track {
  background: var(--accent);
}

.toggle-switch input:checked ~ .toggle-track .toggle-thumb {
  background: #fff;
  transform: translateX(20px);
}

.toggle-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.toggle-hint {
  margin: 0.5rem 0 0 0;
  font-size: 0.78rem;
  color: var(--text-dim);
  padding-left: calc(44px + 0.75rem);
}

/* ===== REVIEW PANEL ===== */
.review-panel {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 2rem;
  animation: fadeUp 0.3s ease;
}

.review-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.review-section {
  margin-bottom: 1.5rem;
}

.review-section:last-child { margin-bottom: 0; }

.review-section-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 0.75rem;
}

.review-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.review-item {
  padding: 0.75rem 1rem;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.review-item-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.review-item-value {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  word-break: break-word;
}

.review-item.full-width {
  grid-column: 1 / -1;
}

/* ===== NAVIGATION ===== */
.wizard-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-top: 1.25rem;
  margin-top: 0.25rem;
}

.nav-right {
  display: flex;
  gap: 0.75rem;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.3rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

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

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: var(--shadow-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface2);
  border-color: var(--border-hover);
  color: var(--text);
}

.btn-accent {
  background: var(--surface2);
  color: var(--accent);
  border: 1.5px solid var(--accent);
}

.btn-accent:hover:not(:disabled) {
  background: var(--accent-subtle);
}

.btn-success {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: var(--bg);
  box-shadow: var(--shadow-glow);
}

.btn-success:hover:not(:disabled) {
  filter: brightness(1.1);
  box-shadow: 0 0 50px var(--accent-glow);
}

/* ===== FOOTER ===== */
.footer {
  margin-top: auto;
  padding-top: 2rem;
}

.footer-inner {
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
  text-align: center;
}

.footer-brand {
  font-family: var(--font-serif);
  font-size: 0.9rem;
  color: var(--accent);
  margin: 0 0 0.25rem;
}

.footer-address,
.footer-contacts {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.7;
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1.25rem;
  color: var(--text);
  font-size: 0.88rem;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease;
  max-width: 360px;
}

.toast.toast-error {
  border-color: rgba(248, 113, 113, 0.3);
  background: var(--error-bg);
  color: var(--error);
}

.toast.toast-success {
  border-color: rgba(52, 211, 153, 0.3);
  background: var(--success-bg);
  color: var(--success);
}

.toast.toast-out {
  animation: toastOut 0.3s ease forwards;
}

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

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

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .app {
    padding: 1.25rem 1rem;
  }

  .header-brand {
    flex-wrap: wrap;
  }

  .logo {
    font-size: 1.35rem;
  }

  .step-panel {
    padding: 1.25rem;
  }

  .review-grid {
    grid-template-columns: 1fr;
  }

  .stepper {
    gap: 0;
  }

  .stepper-label {
    display: none;
  }

  .wizard-nav {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .nav-right {
    flex: 1;
    justify-content: flex-end;
  }

  .btn {
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
  }

  .toast-container {
    left: 1rem;
    right: 1rem;
  }

  .toast {
    max-width: 100%;
  }
}

@media (max-width: 420px) {
  .stepper-item {
    padding: 0.4rem 0.5rem;
  }

  .stepper-num {
    width: 24px;
    height: 24px;
    font-size: 0.7rem;
  }

  .success-actions {
    flex-direction: column;
  }
}
