/* ── Reset & Base ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --accent: #a938eb;
  --accent-hover: #9225d1;
  --accent-light: #f3e8fd;
  --text: #2e4a58;
  --text-light: #6b8293;
  --bg: #ffffff;
  --bg-alt: #f7f8fa;
  --border: #e2e6ea;
  --error: #e53e3e;
  --success: #38a169;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.10);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ── */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 24px;
}

.container-wide {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Header ── */
.header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.header-logo span {
  color: var(--text);
  font-weight: 400;
}

.header-subtitle {
  font-size: 0.85rem;
  color: var(--text-light);
}

/* ── Progress Bar ── */
.progress-bar {
  background: var(--bg-alt);
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.progress-steps {
  display: flex;
  gap: 8px;
  list-style: none;
}

.progress-step {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  transition: background 0.3s;
}

.progress-step.active {
  background: var(--accent);
}

.progress-step.completed {
  background: var(--success);
}

.progress-labels {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  list-style: none;
}

.progress-label {
  flex: 1;
  font-size: 0.7rem;
  color: var(--text-light);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.progress-label.active {
  color: var(--accent);
  font-weight: 600;
}

/* ── Form Sections ── */
.form-page {
  padding: 40px 0 80px;
}

.section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.section-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

.section-tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.section-tag.required {
  background: var(--accent-light);
  color: var(--accent);
}

.section-tag.optional {
  background: var(--bg-alt);
  color: var(--text-light);
}

.section-toggle {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  transition: transform 0.2s;
}

.section.collapsed .section-toggle {
  transform: rotate(-90deg);
}

.section-body {
  margin-top: 24px;
}

.section.collapsed .section-body {
  display: none;
}

/* ── Form Fields ── */
.field {
  margin-bottom: 20px;
}

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

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

label .required-mark {
  color: var(--error);
  margin-left: 2px;
}

input[type="text"],
input[type="email"],
input[type="url"],
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(169, 56, 235, 0.12);
}

input::placeholder, textarea::placeholder {
  color: #b0bfc9;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

.field-hint {
  font-size: 0.78rem;
  color: var(--text-light);
  margin-top: 4px;
}

.field-error {
  font-size: 0.78rem;
  color: var(--error);
  margin-top: 4px;
  display: none;
}

.field.has-error input,
.field.has-error textarea {
  border-color: var(--error);
}

.field.has-error .field-error {
  display: block;
}

/* ── Repeatable links ── */
.repeatable-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.repeatable-row {
  display: flex;
  gap: 8px;
}

.repeatable-row input {
  flex: 1;
}

.btn-remove-row {
  padding: 8px 12px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-light);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.btn-remove-row:hover {
  background: #fee;
  border-color: var(--error);
  color: var(--error);
}

.btn-add-row {
  align-self: flex-start;
  padding: 6px 14px;
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-light);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.btn-add-row:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Drag & Drop Zone ── */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-alt);
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.dropzone-icon {
  font-size: 2rem;
  margin-bottom: 8px;
  color: var(--text-light);
}

.dropzone-text {
  font-size: 0.9rem;
  color: var(--text-light);
}

.dropzone-text strong {
  color: var(--accent);
}

.dropzone-hint {
  font-size: 0.75rem;
  color: #b0bfc9;
  margin-top: 4px;
}

.dropzone input[type="file"] {
  display: none;
}

/* ── File Preview List ── */
.file-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
}

.file-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 12px;
}

.file-item-size {
  color: var(--text-light);
  font-size: 0.78rem;
  margin-right: 12px;
  white-space: nowrap;
}

.file-item-remove {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 2px 6px;
  border-radius: 4px;
}

.file-item-remove:hover {
  background: #fee;
  color: var(--error);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

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

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

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-alt);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 32px;
}

/* ── Upload Progress ── */
.upload-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.92);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.upload-overlay.visible {
  display: flex;
}

.upload-modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 48px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 420px;
  width: 90%;
}

.upload-modal h3 {
  font-size: 1.15rem;
  margin-bottom: 8px;
}

.upload-modal p {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 24px;
}

.upload-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s;
  width: 0%;
}

.upload-progress-text {
  font-size: 0.78rem;
  color: var(--text-light);
  margin-top: 8px;
}

/* ── Spinner ── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ── Success Page ── */
.success-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 80px);
  text-align: center;
  padding: 40px 24px;
}

.success-icon {
  width: 72px;
  height: 72px;
  background: #e6ffed;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  font-size: 2rem;
}

.success-page h1 {
  font-size: 1.5rem;
  margin-bottom: 12px;
}

.success-page p {
  color: var(--text-light);
  max-width: 480px;
  margin: 0 auto;
}

/* ── Admin Page ── */
.admin-page {
  padding: 40px 0;
}

.admin-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.admin-section h2 {
  font-size: 1.15rem;
  margin-bottom: 20px;
}

.admin-form {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.admin-form .field {
  flex: 1;
  margin-bottom: 0;
}

.client-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.client-table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
}

.client-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-badge.pending { background: #fef3c7; color: #92400e; }
.status-badge.submitted { background: #dbeafe; color: #1e40af; }
.status-badge.complete { background: #d1fae5; color: #065f46; }

.copy-link {
  padding: 4px 10px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--accent);
  font-weight: 500;
}

.copy-link:hover {
  background: var(--accent-light);
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background: var(--text);
  color: #fff;
  border-radius: var(--radius);
  font-size: 0.85rem;
  box-shadow: var(--shadow-lg);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s;
  z-index: 2000;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

/* ── Error Page ── */
.error-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 80px);
  text-align: center;
  padding: 40px 24px;
}

.error-page h1 {
  font-size: 1.5rem;
  margin-bottom: 12px;
}

.error-page p {
  color: var(--text-light);
}

/* ── Loading State ── */
.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 80px);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .section { padding: 20px; }
  .container { padding: 0 16px; }
  .admin-form { flex-direction: column; }
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; }
  .progress-labels { display: none; }
}
