/* CNA アリーナ 座席ヒートマップ — スタイルシート v10 */

/* ── embed モード（ダッシュボード iframe 内） ── */
html.embed .header { display: none; }
html.embed body { min-height: 100vh; }

:root {
  --attended: #22C55E;
  --noshow: #FACC15;
  --empty: #E5E7EB;
  --brand-pink: #E60283;
  --brand-black: #111111;
  --text: #111111;
  --bg: #FFFFFF;
  --bg-sub: #F8F9FA;
  --font: 'Calibri', 'Arial', sans-serif;
  --border: #E5E7EB;
  --text-muted: #6B7280;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  font-family: var(--font);
  color: var(--text);
  background-color: var(--bg);
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
}

/* ────────────────────────────────── */
/* ヘッダー */
/* ────────────────────────────────── */

.header {
  background: linear-gradient(to right, #003DA5, #0047C0);
  color: white;
  padding: 16px 24px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ────────────────────────────────── */
/* Zone A: フィルタバー */
/* ────────────────────────────────── */

.filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  background-color: var(--bg-sub);
  border-bottom: 1px solid var(--border);
  flex-wrap: nowrap;
}

.filter-bar select,
.filter-bar input[type="checkbox"],
.filter-bar button {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
}

.filter-bar select {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background-color: white;
  cursor: pointer;
  color: var(--text);
}

.filter-bar select:hover {
  border-color: #BFDBFE;
}

.filter-bar select:focus {
  outline: none;
  border-color: var(--brand-pink);
  box-shadow: 0 0 4px rgba(230, 2, 131, 0.2);
}

.filter-bar button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background-color: white;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
}

.filter-bar button:hover {
  background-color: var(--bg);
  border-color: var(--brand-pink);
  color: var(--brand-pink);
}

.filter-bar button:active {
  background-color: #F8F9FA;
  transform: scale(0.98);
}

.filter-bar label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}

.filter-bar input[type="checkbox"] {
  cursor: pointer;
  width: 18px;
  height: 18px;
}

/* ────────────────────────────────── */
/* メインコンテナ（Zone B） */
/* ────────────────────────────────── */

.main-container {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Zone B 左サイドパネル */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  padding: 16px;
  border-right: 1px solid var(--border);
  background-color: white;
  overflow-y: auto;
  font-size: 14px;
}

.sidebar-section {
  margin-bottom: 20px;
}

.sidebar-section:last-child {
  margin-bottom: 0;
}

.sidebar-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  display: block;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}

.sidebar-item input[type="checkbox"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
}

.sidebar-item label {
  cursor: pointer;
  flex: 1;
  user-select: none;
}

.legend {
  margin-bottom: 16px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
}

.legend-color {
  width: 16px;
  height: 16px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

/* ────────────────────────────────── */
/* メインコンテンツ（SVG グリッド） */
/* ────────────────────────────────── */

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  padding: 16px;
  overflow: hidden;
}

.legend-bar {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px 12px;
  background-color: var(--bg-sub);
  border-radius: 4px;
  font-size: 13px;
  flex-shrink: 0;
}

.legend-bar-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-bar-color {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

/* SVG マップ + 統計パネルの横並びコンテナ */
.grid-and-stats {
  flex: 1;
  display: flex;
  gap: 12px;
  min-height: 0;
}

.grid-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

#grid-container {
  flex: 1;
  overflow: hidden;
  background-color: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  position: relative;
  display: flex;
  align-items: stretch;
}

/* SVG を白枠いっぱいに広げ、左寄せ */
#seat-svg {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  padding-right: 4px; /* わずかに右余白（左寄せ効果）*/
}

#seat-svg:active {
  cursor: grabbing;
}

/* ────────────────────────────────── */
/* 席種別統計パネル */
/* ────────────────────────────────── */

#stats-panel {
  width: 380px;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background-color: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
  font-size: 11px;
}

.stats-panel-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.stats-table th {
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  padding: 3px 4px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.stats-table th.num,
.stats-table td.num {
  text-align: right;
}

.stats-table td {
  padding: 3px 4px;
  border-bottom: 1px solid #F3F4F6;
  white-space: nowrap;
}

.stats-table tr:hover td {
  background-color: #F9FAFB;
}

.stats-table .rate-high { color: #16A34A; font-weight: 600; }
.stats-table .rate-mid  { color: #D97706; }
.stats-table .rate-low  { color: #DC2626; }

.stats-table .non-seat-row td {
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  font-style: italic;
}

/* サイドバー追加スタイル */
.sidebar-item--sub {
  padding-left: 20px;
}

.sidebar-item--fc-all {
  background-color: #F0F7FF;
  border-radius: 4px;
  padding: 6px 6px;
  margin-bottom: 2px;
}

.sidebar-divider {
  height: 1px;
  background-color: var(--border);
  margin: 4px 0 6px;
}

/* SVG 座席スタイル */
.seat {
  transition: fill 0.15s ease, opacity 0.15s ease;
  cursor: pointer;
  vector-effect: non-scaling-stroke;
  stroke-width: 0.5;
  stroke: rgba(0, 0, 0, 0.1);
}

.seat:hover {
  filter: brightness(0.9);
  stroke: rgba(0, 0, 0, 0.3);
}

.seat[data-state="attended"] {
  fill: var(--attended);
}

.seat[data-state="noshow"] {
  fill: var(--noshow);
}

.seat[data-state="empty"] {
  fill: var(--empty);
}

.seat.hidden {
  opacity: 0.15;
}

/* ────────────────────────────────── */
/* ズームコントロール */
/* ────────────────────────────────── */

#zoom-controls {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  justify-content: center;
}

#zoom-controls button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background-color: white;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 36px;
}

#zoom-controls button:hover {
  background-color: var(--bg-sub);
  border-color: var(--brand-pink);
  color: var(--brand-pink);
}

#zoom-controls button:active {
  transform: scale(0.95);
}

/* ────────────────────────────────── */
/* ステータスバー */
/* ────────────────────────────────── */

#status-bar {
  font-size: 13px;
  color: var(--text-muted);
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background-color: var(--bg-sub);
  text-align: center;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ────────────────────────────────── */
/* ツールチップ */
/* ────────────────────────────────── */

#tooltip {
  position: fixed;
  background-color: var(--brand-black);
  color: white;
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 4px;
  z-index: 1000;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  display: none;
}

#tooltip.visible {
  display: block;
}

/* ────────────────────────────────── */
/* スクロールバー */
/* ────────────────────────────────── */

#grid-container::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

#grid-container::-webkit-scrollbar-track {
  background: var(--bg-sub);
}

#grid-container::-webkit-scrollbar-thumb {
  background: #D1D5DB;
  border-radius: 4px;
}

#grid-container::-webkit-scrollbar-thumb:hover {
  background: #9CA3AF;
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: #D1D5DB;
  border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: #9CA3AF;
}

/* ────────────────────────────────── */
/* 複数試合選択パネル */
/* ────────────────────────────────── */

.multi-game-panel {
  background-color: var(--bg-sub);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.multi-game-scroll {
  flex: 1;
  max-height: 140px;
  overflow-y: auto;
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 10px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2px 16px;
  font-size: 13px;
}

.multi-game-scroll label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 3px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.multi-game-scroll .season-header {
  grid-column: 1 / -1;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 0 2px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

.multi-game-scroll .season-header:first-child {
  border-top: none;
  margin-top: 0;
}

.multi-game-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  align-items: flex-end;
}

.multi-game-controls button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: white;
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

#btn-multi-aggregate {
  background: var(--brand-pink);
  color: white;
  border-color: var(--brand-pink);
  font-weight: 600;
}

#btn-multi-aggregate:hover {
  background: #C7026F;
}

#btn-multi-clear:hover {
  border-color: var(--brand-pink);
  color: var(--brand-pink);
}

#multi-game-count {
  font-size: 12px;
  color: var(--text-muted);
}

/* ────────────────────────────────── */
/* 座席購入履歴モーダル */
/* ────────────────────────────────── */

#seat-history-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: relative;
  background: white;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  width: min(580px, 90vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  z-index: 1;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.modal-header button {
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 4px;
}

.modal-header button:hover {
  background-color: var(--bg-sub);
  color: var(--text);
}

.modal-body {
  overflow-y: auto;
  padding: 12px 16px;
  flex: 1;
  min-height: 0;
}

/* ────────────────────────────────── */
/* レスポンシブ（参考：通常はPC専用） */
/* ────────────────────────────────── */

@media (max-width: 1200px) {
  .sidebar {
    width: 200px;
    padding: 12px;
  }

  .filter-bar {
    flex-wrap: wrap;
  }
}
