/* ==========================================================================
   VARIABLES & GLOBAL RESET
   ========================================================================== */
:root {
  --bg: #ffffff;
  --card-bg: #f9f9f9;
  --text: #000000;
  --subtext: #555555;
  --accent: #008080;
  --border: #dddddd;
  --error: #c00;
  --success: #16a34a;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Prevent any horizontal scroll ever */
html, body {
  overflow-x: hidden;
  overscroll-behavior-x: contain;
}

/* Center container vertically & horizontally */
body {
  background: var(--bg);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

/* ==========================================================================
   CONTAINER & PROGRESS BAR
   ========================================================================== */
.container {
  width: 100%;
  max-width: 480px;
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  overflow: hidden;
}

.progress-wrapper {
  position: sticky;
  top: 0;
  background: var(--card-bg);
  z-index: 20;
}
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
#progress {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .4s ease;
}

/* ==========================================================================
   STEPS NAVIGATION (1–4)
   ========================================================================== */
.steps {
  position: sticky;
  top: 6px;          /* sits just below the progress bar */
  z-index: 15;
  display: flex;
  justify-content: space-around;
  padding: .75rem 1rem;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}
.step {
  font-size: .85rem;
  color: var(--subtext);
  position: relative;
}
.step.active {
  color: var(--accent);
  font-weight: 600;
}
.step.active::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 0; right: 0;
  height: 4px;
  background: var(--accent);
  border-radius: 2px;
}

/* ==========================================================================
   CARD STACK & ANIMATION
   ========================================================================== */
.cards {
  position: relative;
  min-height: 600px;  /* ensures adequate space for steps 1–4 */
  height: auto;       /* allows cards (including success) to size to content */
}
.card {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: auto;
  padding: 2rem 1.5rem;
  background: var(--card-bg);
  display: none;
  flex-direction: column;
  overflow-y: auto;
  transition: transform .5s ease, opacity .3s ease;
}
.card.active { display: flex; transform: translateX(0); opacity: 1; }
.card.prev   { transform: translateX(-100%); opacity: 0; }
.card.next   { transform: translateX(100%);  opacity: 0; }

/* ==========================================================================
   HEADERS & TEXT
   ========================================================================== */
.card-header {
  text-align: center;
  margin-bottom: 2rem;
}
.card-header h2 {
  font-size: 1.6rem;
  margin-bottom: .5rem;
}
.card-header p {
  font-size: .95rem;
  color: var(--subtext);
}

/* ==========================================================================
   FORM ELEMENTS
   ========================================================================== */
.form-group {
  margin-bottom: 1.5rem;
  position: relative;
}
label {
  display: block;
  margin-bottom: .5rem;
  font-weight: 500;
}
input,
textarea {
  width: 100%;
  padding: .75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f0f0f0;
  font-size: .95rem;
  transition: border-color .2s;
}
textarea {
  min-height: 140px;
  resize: vertical;
}
input:focus,
textarea:focus {
  border-color: var(--accent);
  outline: none;
}
.error-msg {
  color: var(--error);
  font-size: .8rem;
  position: absolute;
  bottom: -18px;
  left: 0;
}
.char-count {
  font-size: .8rem;
  color: var(--subtext);
  text-align: right;
  margin-top: .25rem;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
  background: var(--accent);
  color: #fff;
  padding: .75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: background .2s;
}
.btn:hover:not(:disabled) {
  background: #006666;
}
.btn:disabled {
  background: #ddd;
  color: #888;
  cursor: not-allowed;
}
.btn-secondary {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: .75rem 1.5rem;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: background .2s;
}
.btn-secondary:hover {
  background: var(--accent);
  color: #fff;
}

/* ==========================================================================
   NAVIGATION (Next/Back)
   ========================================================================== */
.navigation {
  display: flex;
  justify-content: space-between;
  margin-top: 2rem;
}
.nav-btn {
  background: none;
  color: var(--accent);
  padding: .75rem 1.5rem;
  border: none;
  font-weight: 500;
  cursor: pointer;
}

/* ==========================================================================
   MEDIA PREVIEW & SORTABLE
   ========================================================================== */
.media-preview {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: 1rem;
}
.preview-item {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 6px;
  overflow: hidden;
  cursor: grab;
}
.preview-item.grabbing {
  cursor: grabbing;
}
.preview-item img,
.preview-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.number-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: var(--accent);
  color: #fff;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
}
.remove-media {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(255,255,255,0.8);
  border: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}
.media-warning {
  margin-top: .5rem;
  font-size: .9rem;
  color: var(--error);
  display: flex;
  align-items: center;
}
.media-warning[hidden] {
  display: none !important;
}
.sortable-ghost {
  opacity: 0.5;
  border: 2px dashed var(--accent);
}
.sortable-chosen {
  opacity: 0.8;
}

/* ==========================================================================
   IMAGE/VIDEO MODAL
   ========================================================================== */
.modal-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.7);
  align-items: center;
  justify-content: center;
}
.modal-backdrop.active {
  display: flex;
}
.modal-content {
  position: relative;
}
.modal-content img,
.modal-content video {
  width: 200px;
  height: auto;
  border-radius: 8px;
}
.modal-close {
  position: absolute;
  top: 4px;
  right: 4px;
  background: #fff;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
}

/* ==========================================================================
   TERMS & CONDITIONS (native checkbox)
   ========================================================================== */
.form-group.terms {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: 1.5rem 0;
  font-size: .9rem;
}
.form-group.terms input[type="checkbox"] {
  appearance: auto;
  -webkit-appearance: auto;
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  margin-top: 2px; /* align to baseline */
  cursor: pointer;
}
.form-group.terms label {
  cursor: pointer;
  user-select: none;
}
.form-group.terms label a,
.form-group.terms label a:visited {
  color: var(--accent) !important;
  text-decoration: underline;
}

#err-terms {
  display: block;
  color: var(--error);
  font-size: .8rem;
  margin-left: 1.8rem;
  margin-top: .25rem;
}

/* ==========================================================================
   TERMS & CONDITIONS POPUP
   ========================================================================== */
.tc-modal-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.5);
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.tc-modal-backdrop.active {
  display: flex;
}
.tc-modal {
  width: 90%;
  max-width: 500px;
  height: 70vh;
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.tc-modal h3 {
  margin: 0;
  padding: 1rem;
  background: var(--accent);
  color: #fff;
  font-size: 1.25rem;
  text-align: center;
}
.tc-close {
  position: absolute;
  top: .75rem;
  right: .75rem;
  background: #ffffff95;
  color:var(--accent);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}
.tc-content {
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
  color: var(--text);
  font-size: .9rem;
  line-height: 1.5;
}

/* ==========================================================================
   SUCCESS CARD (Card 5)
   ========================================================================== */
#card5 {
  position: relative !important;
}
#card5 .success-message {
  margin: 3rem auto 0;
  background: #e6fffa;
  border-radius: 12px;
  padding: 2rem 1rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: calc(100% - 2rem);
  max-width: 100%;
}
.success-circle {
  width: 70px;
  height: 70px;
  background: var(--success);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.success-circle svg {
  width: 48px;
  height: 48px;
  stroke: #fff;
  stroke-width: 3;
}

/* ==========================================================================
   LOADING SPINNER
   ========================================================================== */
.spinner {
  border: 2px solid #f3f3f3;
  border-top: 2px solid var(--accent);
  border-radius: 50%;
  width: 16px;
  height: 16px;
  animation: spin 1s linear infinite;
  display: inline-block;
  margin-left: 8px;
  vertical-align: middle;
}
/* ==========================================================================
   FORCE T&C LINK INTO THEME ACCENT COLOR
   ========================================================================== */
.form-group.terms a#openTerms,
.form-group.terms a#openTerms:visited {
  color: var(--accent) !important;
  text-decoration: underline;
}

.form-group.terms a#openTerms:hover,
.form-group.terms a#openTerms:focus {
  color: var(--accent) !important;
  text-decoration: none;
}

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

/* ==========================================================================
   RESPONSIVE TWEAKS
   ========================================================================== */
@media (max-width: 480px) {
  .card { padding: 1rem; }
  .form-group.terms {
    font-size: .85rem;
    margin: 1rem 0;
  }
  .form-group.terms input[type="checkbox"] {
    width: 12px;
    height: 12px;
  }
  .tc-modal { height: 80vh; }
  .tc-modal h3 { font-size: 1.1rem; padding: .75rem; }
  .tc-close { width: 24px; height: 24px; top: .5rem; right: .5rem; }
  #card5 .success-message { margin-top: 4rem; }
}
