/* ===========================
   基本設定
   =========================== */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont,
    "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background: #f5f5f5;
}

/* ===========================
   ヘッダー
   =========================== */
.header {
  background: #111827;
  padding: 16px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.header-left {
  display: flex;
  gap: 12px;
  flex-wrap: nowrap;
  overflow-x: auto;
}

.header h1 {
  margin: 0;
  font-size: 18px;
  color: #fff;
  flex: 1;
}

/* ボタン共通 */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  transition: opacity 0.2s;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  opacity: 0.9;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary { 
  background: #2563eb; 
  color: white; 
}

.btn-secondary { 
  background: #f59e0b; 
  color: white; 
}

.btn-load { 
  background: #10b981; 
  color: white; 
}

.btn-print {
  background: #8b5cf6;
  color: white;
}

.btn-generate {
  background: #10b981;
  color: white;
  width: 100%;
  padding: 14px;
  font-size: 16px;
  margin-top: 16px;
}

/* ===========================
   ステータスバー
   =========================== */
.status-bar {
  background: #fff;
  padding: 12px 16px;
  border-bottom: 1px solid #e5e7eb;
  font-size: 14px;
  color: #4b5563;
}

/* ===========================
   サマリー・プレビューエリア
   =========================== */
.summary-section {
  background: #fff;
  padding: 12px 16px;
  border-bottom: 1px solid #e5e7eb;
}

.summary-list {
  list-style: none;
  padding-left: 0;
  margin: 8px 0 0;
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.summary-list li {
  font-size: 14px;
  margin-bottom: 4px;
}

.preview-section {
  background: #fff;
  padding: 12px 16px;
  border-bottom: 1px solid #e5e7eb;
  max-height: 200px;
  overflow-y: auto;
}

.person-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 14px;
}

.person-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  font-size: 11px;
  color: #fff;
  font-weight: bold;
}

.person-member .person-badge {
  background: #10b981;
}

.person-guest .person-badge {
  background: #3b82f6;
}

.person-master .person-badge {
  background: #f59e0b;
}

.person-other .person-badge {
  background: #f97316;
}

/* 人カードの肩書(テーブルマスター用) */
.person-card .person-title {
  font-size: 10px;
  font-weight: bold;
  color: #92400e;
  margin-bottom: 4px;
  text-align: left;   
}

.person-name {
  min-width: 90px;
  font-weight: 500;
}

.person-meta {
  color: #6b7280;
  font-size: 12px;
}

/* ===========================
   配席設定エリア
   =========================== */
.config-section {
  background: #fff;
  padding: 24px;
  margin: 16px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.config-card h3 {
  margin-top: 0;
  font-size: 18px;
  margin-bottom: 16px;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.config-item label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  color: #374151;
}

.config-item select,
.config-item input {
  width: 100%;
  padding: 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
}

.config-summary {
  background: #f9fafb;
  padding: 12px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.6;
}

/* ===========================
   マトリックス候補カード
   =========================== */
.layout-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}

.layout-section h4 {
  margin: 0 0 4px;
  font-size: 14px;
}

.layout-hint {
  margin: 0 0 12px;
  font-size: 12px;
  color: #6b7280;
  line-height: 1.5;
}

.layout-options {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.layout-card {
  flex: 1 1 180px;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px;
  background: #ffffff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.layout-card.selected {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37,99,235,0.25);
  background: #eff6ff;
}

.layout-badge {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
}

/* 行ごとに中央揃えでテーブルを並べるミニ図 */
.layout-mini {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin: 8px 0 12px;
}

.layout-row {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.layout-dot {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid #9ca3af;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  background: #fff;
  color: #111827;
}

.layout-label {
  font-size: 12px;
  color: #374151;
}

.layout-check {
  margin-left: auto;
  font-size: 11px;
  color: #6b7280;
}

/* ===========================
   メインコンテナ(2カラム)
   =========================== */
.main-container {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 16px;
  padding: 16px;
  min-height: calc(100vh - 320px);
}

/* ===========================
   中央:配席エリア
   =========================== */
.seating-area {
  background: white;
  border-radius: 8px;
  padding: 16px;
  overflow-y: auto;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

/* 行分けレイアウト */
.tables-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 各行を中央揃えで配置 */
.table-row {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* テーブルカード */
.table-card {
  border: 2px solid #d1d5db;
  border-radius: 12px;
  padding: 16px;
  background: #fafafa;
  min-height: 200px;
  max-height: 600px;
  flex: 0 0 auto;
  width: calc(33.333% - 11px);
  min-width: 280px;
  max-width: 400px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #111827;
}

.table-title {
  font-weight: bold;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-count {
  font-size: 14px;
  color: #6b7280;
  font-weight: normal;
}

/* 座席グリッド(2列×4行 = 8マス) */
.seats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.seat {
  border: 2px dashed #d1d5db;
  border-radius: 6px;
  padding: 8px;
  min-height: 80px;
  background: white;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

/* 左上のマスター席だけ背景色変更 */
.seat.master {
  background: #fef3c7;
  border-color: #f59e0b;
  border-style: solid;
}

.seat.occupied {
  border-style: solid;
  border-color: #9ca3af;
}

.seat:hover {
  background: #f9fafb;
}

.seat.master:hover {
  background: #fde68a;
}

.master-label {
  font-size: 11px;
  color: #92400e;
  font-weight: bold;
  text-align: center;
}

/* テーブルサマリー */
.table-summary {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
  font-size: 12px;
  color: #6b7280;
  display: flex;
  justify-content: space-between;
}

/* ===========================
   人カード(ドラッグ可能)
   =========================== */
.person-card {
  padding: 8px;
  border-radius: 6px;
  font-size: 13px;
  cursor: move;
  border: 2px solid;
  line-height: 1.4;
  transition: transform 0.1s;
  user-select: none;
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 100%;
  word-wrap: break-word;
  overflow: hidden;
}

.person-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* 通常会員(福岡飯塚) */
.person-card.jikai {
  background: #d1fae5;
  border-color: #10b981;
  color: #065f46;
}

/* ゲスト */
.person-card.guest {
  background: #dbeafe;
  border-color: #3b82f6;
  color: #1e40af;
}

/* 他会場会員 */
.person-card.other-venue {
  background: #fed7aa;
  border-color: #f97316;
  color: #9a3412;
}

/* 選択状態(タップ/クリック) */
.person-card.selected {
  box-shadow: 0 0 0 4px #2563eb;
  transform: scale(1.05);
}

/* ===========================
   右:サイドゾーン(待機+特殊枠)
   =========================== */
.side-zone {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

/* PA枠・司会枠 */
.special-zone {
  background: white;
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
  border: 2px solid #f59e0b;
}

.special-header {
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid #f59e0b;
  color: #92400e;
}

.special-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 待機ゾーン */
.waiting-zone {
  background: white;
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.waiting-header {
  font-weight: bold;
  font-size: 16px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid #111827;
}

.waiting-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 待機ゾーンの5枠固定 */
.waiting-slot {
  border: 2px dashed #d1d5db;
  border-radius: 6px;
  padding: 8px;
  min-height: 70px;
  background: white;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.waiting-slot:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

.waiting-placeholder {
  color: #9ca3af;
  font-size: 12px;
  text-align: center;
}

/* ===========================
   ドラッグ&ドロップ用
   =========================== */
.dragging {
  opacity: 0.4;
  cursor: grabbing;
}

.drag-over {
  background: #dbeafe !important;
  border-color: #3b82f6 !important;
  border-style: solid !important;
}

/* ===========================
   印刷モーダル
   =========================== */
.print-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.print-modal-content {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 1200px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.print-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 2px solid #e5e7eb;
}

.print-modal-header h3 {
  margin: 0;
  font-size: 18px;
}

.print-modal-close {
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.print-modal-close:hover {
  background: #dc2626;
}

.print-controls {
  padding: 16px 24px;
  display: flex;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid #e5e7eb;
}

.btn-paper-size {
  padding: 8px 16px;
  border: 2px solid #d1d5db;
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.btn-paper-size.active {
  border-color: #2563eb;
  background: #eff6ff;
  color: #2563eb;
}

.print-preview-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: #f5f5f5;
}

/* ===========================
   印刷プレビュー内容
   =========================== */
.print-page {
  background: white;
  margin: 0 auto;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  padding: 20mm;
  position: relative;
  display: flex;
  flex-direction: column;
}

.print-page.a4 {
  width: 210mm;
  min-height: 297mm;
}

.print-page.a3 {
  width: 297mm;
  min-height: 420mm;
}

/* ステージ：中央固定配置 */
.print-stage {
  position: absolute;
  top: 20mm;
  left: 50%;
  transform: translateX(-50%);
  width: 40%;
  height: 80px;
  border: 2px solid #111827;
  border-radius: 8px;
  background: #fafafa;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #6b7280;
}

/* 司会：右上固定配置 */
.print-special-box {
  position: absolute;
  top: 20mm;
  right: 20mm;
  width: 120px;
  height: 80px;
  border: 2px solid #f59e0b;
  border-radius: 8px;
  background: #fffbeb;
  padding: 8px;
  display: flex;
  flex-direction: column;
}

.print-special-label {
  font-size: 12px;
  font-weight: bold;
  color: #92400e;
  margin-bottom: 4px;
  text-align: center;
}

.print-special-card {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
}

/* PA枠：右下固定配置 */
.print-pa-box {
  position: absolute;
  bottom: 20mm;
  right: 20mm;
  width: 100px;
  border: 2px solid #f59e0b;
  border-radius: 8px;
  background: #fffbeb;
  padding: 8px;
  display: flex;
  flex-direction: column;
}

/* テーブルエリア：上下余白均等 */
.print-tables-grid {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  margin-top: 120px;
  padding-bottom: 120px;
}

.print-table-row {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.print-table-card {
  border: 2px solid #d1d5db;
  border-radius: 10px;
  padding: 12px;
  background: #fafafa;
  flex: 0 0 auto;
}

.print-table-card.small {
  width: 150px;
}

.print-table-card.medium {
  width: 190px;
}

.print-table-card.large {
  width: 300px;
}

.print-table-header {
  text-align: center;
  font-weight: bold;
  font-size: 16px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 2px solid #111827;
}

.print-seats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.print-seat {
  min-height: 50px;
  border-radius: 4px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  font-size: 11px;
  font-weight: 500;
  text-align: left;
  word-wrap: break-word;
  line-height: 1.3;
}

.print-seat-label {
  font-size: 9px;
  font-weight: bold;
  margin-bottom: 2px;
  text-align: left;
}

.print-seat.master {
  background: #fef3c7;
  border: 2px solid #f59e0b;
}

.print-seat.jikai {
  background: #d1fae5;
  border: 2px solid #10b981;
  color: #065f46;
}

.print-seat.guest {
  background: #dbeafe;
  border: 2px solid #3b82f6;
  color: #1e40af;
}

.print-seat.other-venue {
  background: #fed7aa;
  border: 2px solid #f97316;
  color: #9a3412;
}

/* ===========================
   @media print
   =========================== */
@media print {
  /* 全て非表示 */
  body * {
    visibility: hidden;
    display: none;
  }
  
  /* 印刷エリアのみ表示 */
  .print-preview-area,
  .print-preview-area *,
  .print-page,
  .print-page * {
    visibility: visible;
    display: block;
  }
  
  /* Flexboxは個別に復元 */
  .print-page {
    display: flex !important;
    flex-direction: column !important;
  }
  
  .print-stage {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  
  .print-tables-grid {
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
  }
  
  .print-table-row {
    display: flex !important;
  }
  
  .print-seats-grid {
    display: grid !important;
  }
  
  .print-seat,
  .print-pa-box,
  .print-special-box {
    display: flex !important;
  }
  
  /* 不要な要素を完全非表示 */
  .header,
  .status-bar,
  .summary-section,
  .preview-section,
  .config-section,
  .main-container,
  .side-zone,
  .waiting-zone,
  .waiting-slot,
  .special-zone,
  .print-modal-header,
  .print-controls {
    display: none !important;
    visibility: hidden !important;
  }
  
  .print-preview-area {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    background: white;
    padding: 0;
  }
  
  .print-page {
    box-shadow: none;
    page-break-after: avoid;
    margin: 0;
    max-width: 100%;
    max-height: 100%;
  }
  
  .print-page.a4,
  .print-page.a3 {
    width: 100%;
    height: auto;
  }
  
  @page {
    margin: 10mm;
    size: auto;
  }
}

/* ===========================
   自動配席選択モーダル
   =========================== */
.auto-seat-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auto-seat-modal-content {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  padding: 32px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.auto-seat-modal-header {
  text-align: center;
  margin-bottom: 32px;
}

.auto-seat-modal-header h3 {
  margin: 0;
  font-size: 20px;
  color: #111827;
}

.auto-seat-buttons {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.btn-auto-large {
  padding: 20px;
  font-size: 18px;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.2s;
}

.btn-auto-large:hover {
  background: #1d4ed8;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* ===========================
   レスポンシブ対応
   =========================== */
@media (max-width: 1024px) {
  .main-container {
    grid-template-columns: 1fr;
  }

  .table-card {
    width: 100%;
    min-width: unset;
  }

  .side-zone {
    flex-direction: row;
    gap: 12px;
  }

  .waiting-zone,
  .special-zone {
    flex: 1;
  }
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: black;
    border-bottom: 2px solid #e0e0e0;
}

.header-left {
    display: flex;
    gap: 0.5rem;
}

.header-right {
    display: flex;
    gap: 0.5rem;
}