/* form.css – Asiakirjasto Dynamic Template Styling */

/* ------------------------------------------------------------
   1) Yleinen kontaineri
   ------------------------------------------------------------ */
.dynamic-template {
  max-width: 600px;
  margin: 0 auto;
  font-family: sans-serif;
  background: #fff;
  padding: 24px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* ------------------------------------------------------------
   2) Progress‐bar
   ------------------------------------------------------------ */
.progress-bar {
  background: #e5e5e5;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 24px;
  height: 8px;
  position: relative;
}
.progress-bar span {
  position: absolute;
  left: 50%;
  top: -24px;
  transform: translateX(-50%);
  font-size: 0.875rem;
  color: #333;
}

/* ------------------------------------------------------------
   3) Step‐container ja otsikot
   ------------------------------------------------------------ */
.step {
  margin-bottom: 32px;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.step-title {
  font-size: 1.25rem;
  margin-bottom: 16px;
  color: #0073aa;
  border-bottom: 2px solid #0073aa;
  padding-bottom: 4px;
}

/* ------------------------------------------------------------
   4) Field‐wrap ja virheilmoitukset
   ------------------------------------------------------------ */
/* Yksittäisen kentän kontaineri antaa tilaa virheilmoitukselle */
.field-wrap {
  margin-bottom: 1.5em;
  position: relative;
}

/* Virheilmoitukset oletuksena piilossa */
.field-wrap .error-message {
  display: none;
  position: absolute;
  bottom: -1.2em;
  left: 0;
  color: #dc3545;
  font-size: 0.875rem;
  line-height: 1.2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

/* Kun JS lisää .error-luokan, näytetään virheilmoitus ja korostetaan reunus */
.field-wrap.error input,
.field-wrap.error textarea {
  border-color: #dc3545;
}
.field-wrap.error .error-message {
  display: block;
  opacity: 1;
}

/* Label */
.field-wrap label {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
  color: #333;
}

/* Input ja textarea */
.field-wrap input,
.field-wrap textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
  transition: border-color 0.2s ease;
}
.field-wrap input:focus,
.field-wrap textarea:focus {
  border-color: #0073aa;
  outline: none;
  box-shadow: 0 0 0 2px rgba(0,115,170,0.2);
}

/* ------------------------------------------------------------
   5) Navigointipainikkeet
   ------------------------------------------------------------ */
.nav-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
}
.btn-back,
.btn-next,
.btn-submit {
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 0.2s ease, opacity 0.2s ease;
}
.btn-back {
  background: #f0f0f0;
  color: #555;
}
.btn-back:hover:not([disabled]) {
  background: #e0e0e0;
}
.btn-back[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-next {
  background: #0073aa;
  color: #fff;
}
.btn-next:hover:not([disabled]) {
  background: #005f8d;
}
.btn-next[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-submit {
  background: #28a745;
  color: #fff;
}
.btn-submit:hover {
  background: #1e7e34;
}

/* ------------------------------------------------------------
   6) Responsiivisuus
   ------------------------------------------------------------ */
@media (max-width: 480px) {
  .dynamic-template {
    padding: 16px;
  }
  .btn-back,
  .btn-next,
  .btn-submit {
    flex: 1;
    font-size: 0.85rem;
  }
  .nav-buttons {
    flex-direction: column-reverse;
  }
}

/* ------------------------------------------------------------
   7) Sidebar & layout
   ------------------------------------------------------------ */
.form-with-sidebar {
  display: flex;
  gap: 24px;
}
.step-sidebar {
  list-style: none;
  padding: 0;
  margin: 0;
  width: 200px;
}
.step-sidebar .sidebar-item {
  margin-bottom: 12px;
}
.step-sidebar .sidebar-item a {
  text-decoration: none;
  color: #555;
  font-weight: 500;
}
.step-sidebar .sidebar-item.active a {
  color: #0073aa;
  font-weight: 600;
}
.step-sidebar .sidebar-item.completed a {
  color: #28a745;
  opacity: 0.7;
}
.step-sidebar .sidebar-item[data-allow-skip] a {
  cursor: pointer;
}

/* Siirrä lomakesisältö viereen */
.form-content {
  flex: 1;
}
