/* survey.css - アンケートツール */

.survey-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}

.survey-title {
  text-align: left;
  font-size: 1.8rem;
  margin-bottom: 0.25rem;
}

/* ── カード ── */
.survey-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.survey-card h2 {
  font-size: 1.05rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

/* ── 接続・ステータス ── */
.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-weight: 600;
}

.connection-status.connected { background: #d1fae5; color: #065f46; }
.connection-status.disconnected { background: #fee2e2; color: #991b1b; }
.connection-status .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

.status-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}
.status-badge.draft { background: #f3f4f6; color: #6b7280; }
.status-badge.open  { background: #d1fae5; color: #065f46; }
.status-badge.closed { background: #dbeafe; color: #1e40af; }

/* ── フォーム ── */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 0.3rem;
  color: var(--text-muted);
}

.form-group input[type="text"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

/* ── 質問ビルダー ── */
.question-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.question-item {
  background: var(--bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  position: relative;
}

.question-item-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.question-number {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 1.5rem;
}

.question-type-select {
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background: var(--card-bg);
  color: var(--text);
}

.btn-remove-question {
  margin-left: auto;
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 1rem;
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius-sm);
}

.btn-remove-question:hover { background: #fee2e2; }

.question-text-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  background: var(--card-bg);
  color: var(--text);
  box-sizing: border-box;
  margin-bottom: 0.5rem;
}

.options-area {
  margin-top: 0.5rem;
}

.options-area label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
  display: block;
  margin-bottom: 0.3rem;
}

.option-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
}

.option-row input {
  flex: 1;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: var(--card-bg);
  color: var(--text);
}

.btn-remove-option {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.2rem;
}
.btn-remove-option:hover { color: #ef4444; }

.btn-add-option {
  font-size: 0.82rem;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-weight: 600;
}

.rating-config {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.rating-config input[type="number"] {
  width: 60px;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  text-align: center;
  background: var(--card-bg);
  color: var(--text);
}

/* ── ボタン ── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.7rem 1.4rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1.2rem;
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary:hover { background: var(--bg); }

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1.2rem;
  background: #fee2e2;
  color: #991b1b;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-danger:hover { background: #fecaca; }

.btn-success {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1.2rem;
  background: #10b981;
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-success:hover { opacity: 0.85; }

.btn-guide {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 0.2rem 0.75rem;
  background: var(--card-bg);
  margin-bottom: 0.5rem;
  transition: border-color 0.15s;
}
.btn-guide:hover { border-color: var(--primary); color: var(--primary); }

/* ── 共有URL ── */
.share-url-block { flex: 1; }
.share-url-label { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 0.4rem; }
.share-url-copy {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.share-url-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  background: var(--bg);
  color: var(--text);
}
.btn-copy-url {
  padding: 0.5rem 0.9rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 600;
}

/* ── 結果グラフ ── */
.result-question {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}
.result-question:last-child { border-bottom: none; }

.result-question-text {
  font-weight: 700;
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.result-bar-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.45rem;
  font-size: 0.9rem;
}

.result-bar-label {
  min-width: 120px;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.result-bar-wrap {
  flex: 1;
  background: var(--bg);
  border-radius: 999px;
  height: 14px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.result-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.6s ease;
  min-width: 0;
}

.result-bar-count {
  min-width: 3rem;
  text-align: right;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.result-text-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.result-text-list li {
  padding: 0.4rem 0.6rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
  border-left: 3px solid var(--primary);
}

.rating-avg {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.5rem;
}
.rating-avg span {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* ── 参加者ページ ── */
.participant-container {
  max-width: 640px;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}

.participant-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.question-block {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}
.question-block:last-child { border-bottom: none; margin-bottom: 0; }

.question-block .q-label {
  font-weight: 700;
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

.q-required {
  color: #ef4444;
  font-size: 0.75rem;
  font-weight: 700;
  margin-left: 0.3rem;
}

.radio-list, .checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.radio-list label, .checkbox-list label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.92rem;
  transition: border-color 0.15s, background 0.15s;
}
.radio-list label:hover, .checkbox-list label:hover {
  border-color: var(--primary);
  background: var(--bg);
}
.radio-list input[type="radio"],
.checkbox-list input[type="checkbox"] { accent-color: var(--primary); }

.text-answer-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
  min-height: 80px;
  resize: vertical;
}

.rating-stars {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.rating-stars label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  cursor: pointer;
}

.rating-stars input[type="radio"] { display: none; }

.star-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--border-color);
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.15s;
}
.rating-stars input[type="radio"]:checked + .star-btn {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.success-message {
  text-align: center;
  padding: 2rem;
}
.success-message .success-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.success-message h2 { font-size: 1.4rem; margin-bottom: 0.5rem; }
.success-message p { color: var(--text-muted); }

/* ── 共有カード ── */
.share-info-row {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

/* ── コントロールバー ── */
.control-bar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

/* ── アンケート一覧 ── */
.survey-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.survey-list-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s;
  flex-wrap: wrap;
}

.survey-list-item:hover { border-color: var(--primary); }
.survey-list-item .survey-list-title { font-weight: 700; flex: 1; }
.survey-list-item .survey-list-meta { font-size: 0.82rem; color: var(--text-muted); }
.btn-delete-survey {
  background: none;
  border: none;
  font-size: 1rem;
  padding: 0.25rem 0.4rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}
.survey-list-item:hover .btn-delete-survey { opacity: 1; }
.btn-delete-survey:hover { color: var(--danger, #ef4444); }

@media (max-width: 600px) {
  .share-info-row { flex-direction: column; }
  .result-bar-label { min-width: 80px; max-width: 120px; }
}
