:root {
  --blue: #0033cc;
  --blue-dark: #00227a;
  --blue-light: #e8edfc;
  --white: #ffffff;
  --gray-text: #333333;
  --green: #1e9e50;
  --yellow: #d6a400;
  --red: #d6362f;
  --bg-gradient: linear-gradient(115deg, #0a1668 0%, #0047d6 32%, #0d8fe0 62%, #16ddb8 100%);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Sora", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: url("../assets/background.png") center center / cover no-repeat fixed, var(--bg-gradient);
  color: var(--gray-text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  width: 100%;
}

/* Progress bar */
.progress-wrap {
  width: 100%;
  max-width: 720px;
  margin-bottom: 28px;
}

.progress-steps {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.progress-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.progress-step::before {
  content: "";
  position: absolute;
  top: 15px;
  left: -50%;
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.35);
  z-index: 0;
}

.progress-step:first-child::before {
  content: none;
}

.progress-step.done::before,
.progress-step.active::before {
  background: var(--white);
}

.dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  border: 2px solid rgba(255, 255, 255, 0.6);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  z-index: 1;
  transition: background 0.2s, color 0.2s;
}

.progress-step.active .dot {
  background: var(--white);
  color: var(--blue);
  border-color: var(--white);
}

.progress-step.done .dot {
  background: var(--white);
  color: var(--blue);
  border-color: var(--white);
}

.progress-label {
  margin-top: 6px;
  font-size: 12px;
  color: var(--white);
  text-align: center;
  opacity: 0.9;
  max-width: 90px;
}

/* Card / page container */
.card {
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  padding: 32px 36px;
  width: 100%;
  max-width: 720px;
  margin-bottom: 24px;
}

.page {
  display: none;
  animation: fadeIn 0.25s ease;
}

.page.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

h1,
h2 {
  color: var(--blue);
  margin-top: 0;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 22px;
}

p.lead {
  font-size: 16px;
  line-height: 1.5;
}

textarea,
input[type="text"] {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  padding: 12px 14px;
  border: 2px solid var(--blue-light);
  border-radius: 10px;
  resize: vertical;
  color: var(--gray-text);
  transition: border-color 0.2s;
}

textarea:focus,
input[type="text"]:focus {
  outline: none;
  border-color: var(--blue);
}

textarea.large {
  min-height: 220px;
}

textarea.medium {
  min-height: 100px;
  margin-bottom: 16px;
}

.field-label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  color: var(--blue);
  margin-bottom: 6px;
}

.field-hint {
  font-size: 13px;
  color: var(--red);
  min-height: 18px;
  margin: 6px 0 0;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  font-size: 14px;
  color: #555;
}

.actions {
  display: flex;
  justify-content: space-between;
  margin-top: 24px;
  gap: 12px;
}

.actions.single {
  justify-content: flex-end;
}

button {
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  border-radius: 999px;
  padding: 12px 26px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn-primary {
  background: var(--blue);
  color: var(--white);
}

.btn-primary:hover:not(:disabled) {
  background: var(--blue-dark);
}

.btn-primary:disabled {
  background: #9aa8d8;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--white);
  color: var(--blue);
  border-color: var(--blue);
}

.btn-secondary:hover {
  background: var(--blue-light);
}

/* Page 5 - evaluation */
.loading {
  text-align: center;
  padding: 40px 0;
  color: var(--blue);
  font-size: 16px;
}

.spinner {
  margin: 0 auto 16px;
  width: 42px;
  height: 42px;
  border: 5px solid var(--blue-light);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.error-box {
  text-align: center;
  padding: 20px 0;
}

.error-box p {
  color: var(--red);
  font-weight: 600;
}

.score-block {
  margin-bottom: 22px;
}

.score-title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.score-title-row .score-value {
  font-weight: 700;
  font-size: 18px;
}

.bar-track {
  width: 100%;
  height: 14px;
  background: #eee;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s ease;
}

.score-explanation {
  margin-top: 8px;
  font-size: 14px;
  color: #444;
  line-height: 1.45;
}

.score-good {
  background: var(--green);
  color: var(--green);
}

.score-mid {
  background: var(--yellow);
  color: var(--yellow);
}

.score-bad {
  background: var(--red);
  color: var(--red);
}

.ai-story-box {
  margin-top: 28px;
  padding: 20px 22px;
  border: 2px solid var(--blue-light);
  border-left: 6px solid var(--blue);
  border-radius: 10px;
  background: #f7f9ff;
}

.ai-story-box h3 {
  margin-top: 0;
  color: var(--blue);
  font-size: 17px;
}

.ai-story-text {
  white-space: pre-wrap;
  line-height: 1.5;
}

/* Footer */
footer {
  text-align: center;
  padding: 16px;
}

footer button {
  background: transparent;
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.5);
  font-size: 13px;
  padding: 8px 18px;
}

footer button:hover {
  background: rgba(255, 255, 255, 0.15);
}

@media (max-width: 560px) {
  .card {
    padding: 24px 20px;
  }

  .progress-label {
    display: none;
  }
}

/* Print styles (usati anche come riferimento visivo, il PDF vero è generato via jsPDF) */
@media print {
  body {
    background: white;
  }
}
