/* ===================================================================
   AI Werewolf Benchmark Platform - Theme Stylesheet
   Modern Dark Cyber-Wolf Aesthetic with Full Responsiveness
   =================================================================== */

:root {
  --bg-main: #0b0f19;
  --bg-card: #151d2e;
  --bg-card-hover: #1c273d;
  --bg-input: #0f172a;
  --border-color: #26334d;
  --border-focus: #3b82f6;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-light: rgba(59, 130, 246, 0.15);
  
  --success: #10b981;
  --success-light: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --warning-light: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-light: rgba(239, 68, 68, 0.15);
  --purple: #8b5cf6;
  --purple-light: rgba(139, 92, 246, 0.15);
  --cyan: #06b6d4;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.5);
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

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

html, body {
  max-width: 100%;
  overflow-x: hidden;
  width: 100%;
}

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-family);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Layout */
.container {
  max-width: 1560px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px 40px 20px;
  box-sizing: border-box;
  transition: max-width 0.2s ease-in-out;
}

header {
  background: linear-gradient(180deg, #101726 0%, rgba(11, 15, 25, 0.95) 100%);
  border-bottom: 1px solid var(--border-color);
  padding: 18px 24px;
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(8px);
}

.header-content {
  max-width: 1560px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  transition: max-width 0.2s ease-in-out;
}

/* Widescreen layout for Submissions & Text Data Management */
.container.wide-layout,
.header-content.wide-layout {
  max-width: min(97vw, 2200px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #ef4444 0%, #8b5cf6 50%, #3b82f6 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.3);
}

.brand-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(90deg, #f8fafc 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

/* Nav Tabs */
.nav-tabs {
  display: flex;
  gap: 8px;
  background: rgba(15, 23, 42, 0.8);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.nav-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s;
}

.card:hover {
  border-color: rgba(59, 130, 246, 0.4);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.card-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Badges & Pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.badge-primary { background: var(--primary-light); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-success { background: var(--success-light); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-warning { background: var(--warning-light); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-danger  { background: var(--danger-light); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-purple  { background: var(--purple-light); color: #c084fc; border: 1px solid rgba(139, 92, 246, 0.3); }
.badge-cyan    { background: rgba(6, 182, 212, 0.15); color: #22d3ee; border: 1px solid rgba(6, 182, 212, 0.3); }
.badge-orange  { background: rgba(249, 115, 22, 0.15); color: #fb923c; border: 1px solid rgba(249, 115, 22, 0.3); }
.badge-pink    { background: rgba(236, 72, 153, 0.15); color: #f472b6; border: 1px solid rgba(236, 72, 153, 0.3); }
.badge-indigo  { background: rgba(99, 102, 241, 0.15); color: #818cf8; border: 1px solid rgba(99, 102, 241, 0.3); }
.badge-gray    { background: rgba(148, 163, 184, 0.15); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, 0.3); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
  outline: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.5);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(30, 41, 59, 0.8);
  border-color: var(--border-color);
  color: var(--text-primary);
}
.btn-secondary:hover {
  background: rgba(51, 65, 85, 0.8);
  border-color: var(--text-muted);
}

.btn-danger {
  background: var(--danger-light);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* Forms */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.form-textarea {
  resize: vertical;
  min-height: 120px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
}

/* Quick Select Pills */
.quick-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.quick-pill {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.quick-pill:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: var(--primary);
  color: var(--text-primary);
}

/* Grid System */
.grid {
  display: grid;
  gap: 20px;
}

.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-cols-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }

.workspace-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.workspace-col {
  grid-column: span 6;
}

.question-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.question-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: all 0.2s ease;
  user-select: none;
  overflow: hidden;
}

.question-card:hover {
  border-color: rgba(59, 130, 246, 0.4);
  background: var(--bg-card-hover);
}

.question-card.active {
  border-color: var(--primary) !important;
  background: rgba(59, 130, 246, 0.12) !important;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.25);
}

.question-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  width: 100%;
  min-width: 0;
}

.question-card-role {
  max-width: 58%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px !important;
  flex-shrink: 1;
}

.question-card-stage {
  max-width: 42%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px !important;
  flex-shrink: 0;
  text-align: right;
}

.question-card-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 3px;
  color: #fff;
  line-height: 1.35;
  text-align: left;
  word-break: break-word;
  white-space: normal;
}

.question-card-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  text-align: left;
  word-break: break-all;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  display: block;
}

.mobile-question-dropdown {
  display: none;
}

.table-scroll-hint {
  display: none;
}

/* Distribution Bars */
.dist-item {
  margin-bottom: 14px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  transition: all 0.2s;
}

.dist-item:hover {
  border-color: rgba(59, 130, 246, 0.5);
  background: rgba(30, 41, 59, 0.4);
}

.dist-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.dist-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.dist-count {
  font-size: 13px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.dist-progress-bg {
  height: 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.dist-progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.dist-models {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11px;
}

/* Table */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

th {
  background: #0f172a;
  color: var(--text-muted);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s ease, background-color 0.15s ease;
}

th.sortable:hover {
  color: #fff;
  background: #1e293b;
}

td {
  padding: 11px 14px;
  border-bottom: 1px solid rgba(38, 51, 77, 0.5);
  vertical-align: middle;
}

tr:hover td {
  background: rgba(30, 41, 59, 0.4);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
}

/* Code block */
pre.code-block {
  background: #090d16;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #38bdf8;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  border: 1px solid var(--primary);
  color: var(--text-primary);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  z-index: 100;
  animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

[x-cloak] { display: none !important; }

/* ===================================================================
   Responsive Design & Mobile Portrait Optimization (竖屏手机端优化)
   =================================================================== */

/* Tablet & Medium Screens (<= 1024px) */
@media (max-width: 1024px) {
  .grid-cols-12, .workspace-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  .grid-cols-12 > div, .workspace-col {
    grid-column: 1 / -1 !important;
  }
  .grid-cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .question-cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)) !important;
  }
}

/* Mobile & Portrait Screens (<= 768px) */
@media (max-width: 768px) {
  /* Layout & Container */
  .container {
    padding: 0 10px 30px 10px !important;
    margin-top: 10px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }

  /* Header Optimization: 2-row layout */
  header {
    padding: 10px 12px !important;
  }

  .header-content {
    display: grid !important;
    grid-template-columns: 1fr auto !important;
    grid-template-rows: auto auto !important;
    gap: 10px 8px !important;
    align-items: center !important;
  }

  .header-content > .brand {
    grid-column: 1 !important;
    grid-row: 1 !important;
    gap: 8px !important;
  }

  .brand-icon {
    width: 36px !important;
    height: 36px !important;
    font-size: 20px !important;
  }

  .brand-title {
    font-size: 15px !important;
    line-height: 1.2 !important;
  }

  .brand-subtitle {
    display: none !important; /* Hide verbose subtitle to prevent header bloating */
  }

  .header-content > .header-actions {
    grid-column: 2 !important;
    grid-row: 1 !important;
    justify-self: end !important;
  }

  .header-reload-btn {
    padding: 5px 9px !important;
    font-size: 11px !important;
  }

  /* Navigation Tabs: smooth horizontal swipeable bar */
  .header-content > .nav-tabs {
    grid-column: 1 / -1 !important;
    grid-row: 2 !important;
    width: 100% !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    gap: 4px !important;
    padding: 3px !important;
    scrollbar-width: none !important; /* Firefox */
  }

  .header-content > .nav-tabs::-webkit-scrollbar {
    display: none !important; /* Chrome / Safari */
  }

  .nav-tab-btn {
    padding: 6px 12px !important;
    font-size: 12px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }

  /* Mobile Question Selector Dropdown */
  .mobile-question-dropdown {
    display: block !important;
  }

  .desktop-subtitle {
    display: none !important;
  }

  .question-cards-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 8px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }

  .question-card {
    padding: 10px 12px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    text-align: left !important;
  }

  .question-card-meta {
    width: 100% !important;
    min-width: 0 !important;
  }

  .question-card-role {
    max-width: 55% !important;
    font-size: 10.5px !important;
    padding: 2px 7px !important;
  }

  .question-card-stage {
    max-width: 45% !important;
    font-size: 10px !important;
    padding: 2px 6px !important;
  }

  .question-card-title {
    font-size: 12.5px !important;
    line-height: 1.3 !important;
    text-align: left !important;
  }

  .question-card-desc {
    font-size: 10.5px !important;
    text-align: left !important;
  }

  /* Cards & Padding */
  .card {
    padding: 14px 12px !important;
    border-radius: var(--radius-md) !important;
  }

  .card-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    margin-bottom: 14px !important;
  }

  .card-header > div:first-child {
    width: 100% !important;
  }

  .card-header .btn, .card-header button {
    width: 100% !important;
    justify-content: center !important;
  }

  .card-title {
    font-size: 15px !important;
    line-height: 1.35 !important;
  }

  .copy-prompt-btn {
    width: 100% !important;
  }

  /* All Grids: collapse to single column */
  .grid {
    gap: 12px !important;
  }

  .grid-cols-2, .grid-cols-3, .grid-cols-4, .grid-cols-12, .workspace-grid {
    grid-template-columns: 1fr !important;
  }

  .grid-cols-12 > div, .workspace-col {
    grid-column: 1 / -1 !important;
  }

  /* Mode Switcher Buttons */
  .mode-toggle-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }

  .mode-toggle-btns {
    width: 100% !important;
    display: flex !important;
  }

  .mode-toggle-btns .btn {
    flex: 1 !important;
    font-size: 11px !important;
    padding: 7px 4px !important;
    text-align: center !important;
    justify-content: center !important;
  }

  /* Forms & Inputs */
  .form-group {
    margin-bottom: 12px !important;
  }

  .form-label {
    font-size: 12px !important;
    margin-bottom: 4px !important;
  }

  .form-input, .form-select {
    padding: 8px 10px !important;
    font-size: 13px !important;
  }

  .form-textarea {
    min-height: 90px !important;
    padding: 8px 10px !important;
    font-size: 12px !important;
  }

  /* Quick Pills: touch-friendly, compact */
  .quick-pills {
    gap: 4px !important;
    margin-top: 4px !important;
  }

  .quick-pill {
    padding: 3px 8px !important;
    font-size: 11px !important;
    line-height: 1.3 !important;
  }

  /* Filter Bar in Tab 3 */
  .filter-bar {
    flex-direction: column !important;
    gap: 8px !important;
    padding: 10px !important;
  }

  .filter-bar > div {
    width: 100% !important;
    min-width: 0 !important;
  }

  .filter-bar .form-input, .filter-bar .form-select {
    width: 100% !important;
  }

  /* Table Horizontal Scrolling & Compact Cells */
  .table-scroll-hint {
    display: block !important;
  }

  .table-wrapper {
    -webkit-overflow-scrolling: touch !important;
  }

  table {
    min-width: 680px !important;
  }

  th {
    padding: 8px 10px !important;
    font-size: 11px !important;
  }

  td {
    padding: 8px 10px !important;
    font-size: 11px !important;
  }

  /* Modals on Mobile */
  .modal-overlay {
    padding: 8px !important;
  }

  .modal-content {
    padding: 16px 12px !important;
    max-height: 94vh !important;
    border-radius: var(--radius-md) !important;
  }

  .modal-header-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }

  .modal-header-row > div:last-child {
    display: flex !important;
    justify-content: flex-end !important;
    width: 100% !important;
  }

  /* Code blocks & Pre tags */
  pre.code-block {
    padding: 10px !important;
    font-size: 11px !important;
  }

  /* Toast: Centered at Mobile Bottom */
  .toast {
    left: 14px !important;
    right: 14px !important;
    bottom: 14px !important;
    justify-content: center !important;
    font-size: 13px !important;
    padding: 10px 14px !important;
  }
}
