/* ==========================================================================
   1. 基本設定 & 共通スタイル
   ========================================================================== */
body {
  margin: 0;
  font-family: sans-serif;
  background: #f1f1f1;
  scroll-padding-top: 50px; /* 💡 固定ヘッダーにコンテンツが被るのを防ぐ */
}

/* 💡 すべての画面のメインタイトルを24pxに統一 */
h1 {
  font-size: 24px !important;
}

input,
textarea,
select {
  width: 100%;
  margin-top: 10px;
  padding: 14px;
  border-radius: 6px;
  border: 1px solid #ccc;
  box-sizing: border-box;
  font-size: 16px;
}

textarea {
  height: 120px;
  resize: none;
}

button {
  margin-top: 10px;
  padding: 12px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.layout {
  max-width: 1200px;
  margin: auto;
  padding: 10px;
}

/* ==========================================================================
   2. ヘッダー & ナビゲーション（全画面一律でサイズ固定＆追従化）
   ========================================================================== */
header {
  background: #3a3a3a;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 10px;
  border-bottom: 1px solid #222;
  
  /* 固定追従設定 */
  position: sticky;
  top: 0;
  z-index: 999;
  
  /* 帯の大きさを40pxに完全固定 */
  height: 40px;
  box-sizing: border-box;
}

.logo {
  font-size: 18px;
  font-weight: bold;
  color: #fff;
  cursor: pointer;
  line-height: 40px;
}

.nav {
  display: flex;
  gap: 10px;
  align-items: center;
  height: 100%;
}

.nav input {
  height: 24px;
  font-size: 12px;
  padding: 2px 6px;
  width: 140px;
  margin-top: 0;
}

.nav button {
  background: #ddd;
  color: #222;
  border: 1px solid #999;
  padding: 4px 8px;
  border-radius: 0;
  font-size: 12px;
  cursor: pointer;
  margin-top: 0;
}

/* ==========================================================================
   3. カテゴリ・タグエリア
   ========================================================================== */
.categoryBox {
  background: white;
  padding: 6px 10px;
  border-radius: 8px;
  margin: 8px auto;
  max-width: 1200px;
}

.categoryHeader {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.categoryTitle {
  font-size: 16px;
  font-weight: bold;
  margin: 0;
  white-space: nowrap;
}

#tagArea {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.category {
  display: inline-block;
  padding: 3px 8px;
  margin: 2px;
  background: #f1f1f1;
  border: 1px solid #dcdcdc;
  border-radius: 16px;
  cursor: pointer;
  font-size: 12px;
  transition: 0.2s;
}

.category:hover {
  background: #2563eb;
  color: white;
  border-color: #2563eb;
}

.tag {
  background: #ddd;
  display: inline-block;
  padding: 5px 10px;
  margin: 5px;
  border-radius: 10px;
  cursor: pointer;
}

.hotTag {
  background: #ff6600;
  color: white;
  font-size: 10px;
  padding: 1px 4px;
  margin-right: 4px;
  font-weight: bold;
}

.moreBtn,
.closeBtn {
  all: unset;
  color: #2563eb;
  font-size: 12px;
  cursor: pointer;
  margin-left: 10px;
}

.moreBtn:hover,
.closeBtn:hover {
  text-decoration: underline;
}

/* ==========================================================================
   4. アンケート一覧（メイン画面）
   ========================================================================== */
.sortMenu {
  margin: 8px 0 12px;
  font-size: 13px;
}

.sortMenu span {
  cursor: pointer;
  color: black;
}

.sortMenu span.active {
  color: #007bff;
  font-weight: bold;
}

.thread {
  background: white;
  margin-bottom: 0;
  padding: 6px 10px;
  border-bottom: 1px solid #dcdcdc;
  font-size: 13px;
  cursor: pointer;
}

.thread:hover {
  background: #f7f7f7;
}

.threadRow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.leftTitle {
  font-size: 14px;
  font-weight: bold;
}

.rightMeta {
  display: flex;
  gap: 11px;
  color: #888;
  font-size: 14px;
}

.pager {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 20px;
}

/* ==========================================================================
   5. アンケート作成 & 詳細・パーツスタイル
   ========================================================================== */
.createContainer,
.detailContainer {
  max-width: 700px;
  margin: auto;
  padding: 30px;
}

.createCard,
.detailCard {
  background: #e9e9e9;
  padding: 30px;
  border-radius: 2px;
}

.optionRow {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.optionRow input {
  flex: 1;
}

.optionCard {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 10px;
  background: white;
  border: 2px solid #ddd;
  border-radius: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: 0.2s;
}

.optionCard:hover {
  border-color: #2563eb;
}

.optionCard input {
  width: 16px;
  height: 16px;
}

.optionText {
  font-size: 16px;
  font-weight: 500;
}

/* --- 年代・性別選択の横並びリッチデザイン --- */
.voteInfoRow {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 24px 0;
  background: #f9f9f9;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  box-sizing: border-box;
}

.voteInfoRow > div {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.voteLabel {
  font-weight: bold;
  font-size: 14px;
  color: #4b5563;
  white-space: nowrap;
}

.voteInfoRow select {
  width: 100%;
  margin-top: 0;
  padding: 10px 14px;
  font-size: 14px;
  background-color: white;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  cursor: pointer;
  color: #1f2937;
  transition: border-color 0.2s, box-shadow 0.2s;
  
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234b5563' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px;
}

.voteInfoRow select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* --- ボタンパーツ各種 --- */
.subBtn { background: #eee; }
.deleteBtn { width: 50px; background: #eee; }
.voteBtn { width: 100%; background: #f3f3f3; text-align: left; }
.submitBtn, .commentBtn { background: #666; color: white; }

.voteSubmitBtn {
  width: 220px;
  height: 45px;
  border: none;
  border-radius: 12px;
  background: #2563eb;
  color: white;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  display: block;
  margin: 0 auto;
}

.voteSubmitBtn:hover {
  background: #1d4ed8;
}

/* --- 投票エリア・通報ボタン右寄せ --- */
.voteArea {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.voteArea button[onclick^="reportQuestion"] {
  align-self: flex-end;
  width: auto;
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 6px;
  background: #ff4444;
  color: white;
  margin-top: 10px;
}

/* ==========================================================================
   6. 結果画面（ダッシュボード・チャート）
   ========================================================================== */
.resultContainer {
  max-width: 1200px;
  margin: auto;
  padding: 20px;
}

.resultDashboard {
  max-width: 1200px;
  margin: auto;
  padding: 20px;
}

.resultHeader {
  margin-bottom: 20px;
}

.resultHeader h1 {
  font-size: 18px;
  font-weight: bold;
  color: #1e293b;
  margin: 0 0 5px 0;
}

.resultQuestionTitle {
  font-size: 24px;
  font-weight: bold;
  color: #334155;
  line-height: 1.4;
  margin: 10px 0 8px 0;
  word-break: break-word;
}

.resultMeta {
  display: flex;
  gap: 20px;
  color: #666;
  font-size: 14px;
}

.resultGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.resultCard {
  background: white;
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.resultCard h2 {
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 24px;
}

/* ドーナツ型円グラフ */
.pieChart {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: conic-gradient(#3b82f6 0% 45%, #ef4444 45% 80%, #aaa 80% 100%);
  position: relative;
  flex-shrink: 0;
}

.pieChart::after {
  content: "";
  position: absolute;
  width: 110px;
  height: 110px;
  background: white;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.overallWrap {
  display: flex;
  gap: 30px;
  align-items: center;
}

.overallStats {
  flex: 1;
}

.statRow {
  display: flex;
  justify-content: space-between;
  margin-top: 16px;
  font-size: 16px;
}

/* 棒グラフ・ゲージ */
.bar {
  height: 12px;
  background: #eee;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}

.fill {
  height: 100%;
  border-radius: 999px;
}

.blue { background: #3b82f6; }
.red { background: #ef4444; }
.gray { background: #999; }

/* ==========================================================================
   7. レスポンシブ対応（スマホ表示用）
   ========================================================================= */
@media (max-width: 768px) {
  header {
    /* 💡 スマホでも縦並びにせず横並びをキープして、40pxの帯サイズを完全に揃える */
    flex-direction: row !important; 
    justify-content: space-between;
    align-items: center;
    gap: 0;
  }

  .nav {
    width: auto;
    flex-wrap: nowrap;
  }

  .nav input {
    width: 90px; /* スマホでは検索窓を少し縮めてはみ出しを防ぐ */
  }

  .threadRow {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }

  .rightMeta {
    font-size: 12px;
    gap: 8px;
  }

  .createContainer,
  .detailContainer {
    padding: 10px;
  }

  .createCard,
  .detailCard,
  .resultCard {
    padding: 15px;
  }

  button {
    font-size: 16px;
  }

  .resultGrid {
    grid-template-columns: 1fr;
  }

  .overallWrap {
    flex-direction: column;
  }

  .pieChart {
    width: 180px;
    height: 180px;
  }
}

@media (max-width: 480px) {
  .voteInfoRow {
    flex-direction: column;
    gap: 12px;
  }
  .voteInfoRow > div {
    width: 100%;
  }
}

/* ==========================================================================
   8. アンケート作成ボタン (FAB)
   ========================================================================== */
.fab-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: white;
  border: none;
  padding: 16px 32px;
  border-radius: 50px;
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.3);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  z-index: 1000;
  transition: all 0.3s ease;
}

.fab-btn:hover {
  transform: translateY(-4px);
  box-shadow: 0 15px 25px rgba(37, 99, 235, 0.4);
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
}

.fab-icon {
  font-size: 20px;
  line-height: 1;
}

@media (max-width: 600px) {
  .fab-btn {
    padding: 16px;
    border-radius: 50%;
    bottom: 20px;
    right: 20px;
  }
  .fab-text {
    display: none;
  }
}

/* ==========================================================================
   9. 軸反転対応：新・男女別＆年代別統合グラフ用スタイル
   ========================================================================== */
.axis-flipped-container {
  width: 100%;
  margin-top: 15px;
}

.flipped-option-group {
  display: flex;
  align-items: flex-start;
  margin-bottom: 25px;
  padding-bottom: 15px;
  border-bottom: 1px solid #f1f5f9;
}

.flipped-axis-label {
  width: 110px;
  font-size: 14px;
  font-weight: bold;
  color: #1e293b;
  padding-right: 15px;
  word-break: break-all;
  line-height: 1.3;
}

.flipped-bars-stack {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.flipped-bar-row {
  width: 100%;
}

.bar-single-wrap {
  display: flex;
  align-items: center;
  width: 100%;
  height: 20px;
  position: relative;
}

.bar-single-fill {
  height: 100%;
  border-radius: 10px;
  transition: width 0.6s ease-out;
}

.bar-percent-text {
  font-size: 12px;
  font-weight: bold;
  color: #555;
  margin-left: 12px;
  white-space: nowrap;
}

/* ✨ 男女別の重複しない専用カラー */
.bar-single-fill.gender-navy    { background-color: #1e3a8a; }
.bar-single-fill.gender-coral   { background-color: #f43f5e; }

.legend-color.gender-navy-dot   { background-color: #1e3a8a; }
.legend-color.gender-coral-dot  { background-color: #f43f5e; }

/* コメント欄・その他調整 */
.commentSection {
  margin-top: 30px !important;
}

.comment {
  margin-top: 10px;
  background: #f8fafc;
  padding: 10px 12px;
  border-radius: 6px;
  border-left: 4px solid #cbd5e1;
}

.chart-legend, .chart-legend-grid {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-top: 15px;
  padding-top: 10px;
  border-top: 1px solid #f1f5f9;
}

.chart-legend-grid {
  flex-wrap: wrap;
  gap: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  font-size: 13px;
  color: #4b5563;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 6px;
  display: inline-block;
}

/* ==========================================================================
   【修正】全体と男女別を絶対に横並びにする設定
   ========================================================================== */
.resultGrid-top {
  display: flex !important;
  gap: 20px;
  margin-bottom: 20px;
  width: 100%;
}

.resultGrid-top .resultCard {
  flex: 1;
  min-width: 0;
}

@media (max-width: 768px) {
  .resultGrid-top {
    flex-direction: column !important;
  }
}

/* ページネーションのボタンが無効化されたときのデザイン */
.pager button:disabled {
  background-color: #cbd5e1;
  color: #94a3b8;
  cursor: not-allowed;
  border-color: #cbd5e1;
}

/* style.css に追加 */
.fill.blue { background-color: #3b82f6; }
.fill.red { background-color: #ef4444; }
.fill.green { background-color: #22c55e; }
.fill.orange { background-color: #f97316; }
.fill.purple { background-color: #a855f7; }
.fill.cyan { background-color: #06b6d4; }
.fill.magenta { background-color: #d946ef; }
.fill.lime { background-color: #84cc16; }
.fill.pink { background-color: #ec4899; }
.fill.teal { background-color: #14b8a6; }
