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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  color: #1a1a2e;
  background: #f0f2f5;
  min-height: 100vh;
}

/* ---- Layout ---- */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 40px 20px;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 8px;
}

h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.subtitle {
  color: #6b7280;
  margin-bottom: 32px;
}

/* ---- Cards ---- */
.card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* ---- Form Elements ---- */
label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 6px;
}

input[type='text'] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.9375rem;
  transition: border-color 0.15s;
}

input[type='text']:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

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

.btn-primary {
  background: #6366f1;
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #4f46e5;
}

.btn-secondary {
  background: #e5e7eb;
  color: #374151;
}

.btn-secondary:hover:not(:disabled) {
  background: #d1d5db;
}

.btn-small {
  padding: 6px 12px;
  font-size: 0.8125rem;
}

.btn-danger {
  background: #fee2e2;
  color: #dc2626;
}

.btn-danger:hover:not(:disabled) {
  background: #fecaca;
}

/* ---- Question Block (Creator) ---- */
.question-block {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
  position: relative;
}

.question-block .question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.question-number {
  font-weight: 600;
  color: #6366f1;
  font-size: 0.875rem;
}

.option-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.option-row input {
  flex: 1;
}

/* ---- Links Display (Creator) ---- */
.links-section {
  display: none;
}

.links-section.visible {
  display: block;
}

.link-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.link-box input {
  flex: 1;
  border: none;
  background: none;
  font-size: 0.875rem;
  color: #374151;
  outline: none;
}

.link-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

/* ---- Survey View (Respondent) ---- */
.progress-bar {
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  margin-bottom: 32px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: #6366f1;
  border-radius: 2px;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.8125rem;
  color: #6b7280;
  margin-bottom: 8px;
}

.option-btn {
  display: block;
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 10px;
  background: #fff;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  font-size: 0.9375rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.option-btn:hover {
  border-color: #6366f1;
  background: #f5f3ff;
}

.option-btn.selected {
  border-color: #6366f1;
  background: #ede9fe;
  font-weight: 500;
}

.response-count {
  text-align: center;
  font-size: 0.875rem;
  color: #6b7280;
  margin-bottom: 24px;
}

/* ---- Thank You Screen ---- */
.thank-you {
  text-align: center;
  padding: 40px 20px;
}

.thank-you h2 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.thank-you p {
  color: #6b7280;
}

/* ---- Results Dashboard ---- */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.connection-status {
  font-size: 0.8125rem;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 500;
}

.connection-status.connected {
  background: #d1fae5;
  color: #065f46;
}

.connection-status.disconnected {
  background: #fee2e2;
  color: #dc2626;
}

.connection-status.connecting {
  background: #fef3c7;
  color: #92400e;
}

.result-question {
  margin-bottom: 24px;
}

.result-question h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.bar-label {
  width: 120px;
  font-size: 0.8125rem;
  color: #374151;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  flex: 1;
  height: 28px;
  background: #f3f4f6;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  background: #6366f1;
  border-radius: 6px;
  transition: width 0.4s ease;
  min-width: 0;
}

.bar-count {
  width: 36px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #374151;
  text-align: right;
  flex-shrink: 0;
}

.total-responses {
  font-size: 0.875rem;
  color: #6b7280;
  text-align: center;
  margin-top: 16px;
}

/* ---- Loading & Error ---- */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: #6b7280;
}

.error {
  text-align: center;
  padding: 60px 20px;
  color: #dc2626;
}

/* ---- Utility ---- */
.hidden {
  display: none !important;
}

.mb-8 {
  margin-bottom: 8px;
}

.mb-16 {
  margin-bottom: 16px;
}

.mb-24 {
  margin-bottom: 24px;
}

.text-center {
  text-align: center;
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
