/**
 * Modern Dark-Themed Styling for Maia-3 Analysis Studio
 * Professional Chess Workstation Aesthetic (Slate Graphite + WeChat Brand Green)
 */

:root {
  --bg-main: #111111;
  --bg-card: #191919;
  --bg-card-hover: #232323;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(7, 193, 96, 0.4);
  --text-main: #F3F4F6;
  --text-muted: #9CA3AF;
  --text-dim: #6B7280;
  --brand-green: #07C160;
  --brand-gold: #FA9D3B;
  --brand-red: #FA5151;
  --brand-blue: #10AEFF;
  --board-light: #f0d9b5;
  --board-dark: #b58863;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  user-select: none;
}

/* Header Navbar */
.studio-navbar {
  height: 56px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  z-index: 100;
}

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

.studio-logo {
  font-size: 20px;
}

.studio-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.studio-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 12px;
  background: rgba(7, 193, 96, 0.15);
  color: var(--brand-green);
  border: 1px solid rgba(7, 193, 96, 0.3);
  font-weight: 600;
}

.studio-header-center {
  display: flex;
  align-items: center;
  gap: 16px;
}

.game-meta-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.game-meta-result {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--brand-gold);
}

.studio-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.engine-status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6B7280;
}

.status-dot.ready { background: var(--brand-green); box-shadow: 0 0 8px rgba(7, 193, 96, 0.5); }
.status-dot.loading { background: var(--brand-gold); animation: pulse 1.2s infinite; }
.status-dot.error { background: var(--brand-red); }

@keyframes pulse {
  0% { opacity: 0.4; }
  50% { opacity: 1; }
  100% { opacity: 0.4; }
}

.btn-header {
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-header:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-primary {
  background: var(--brand-green);
  border-color: var(--brand-green);
  color: #ffffff;
}

.btn-primary:hover {
  background: #06AD56;
}

/* Workspace Layout */
.studio-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(420px, 640px) 1fr;
  gap: 20px;
  padding: 20px 24px;
  max-width: 1680px;
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 980px) {
  .studio-layout {
    grid-template-columns: 1fr;
  }
}

/* Board Column */
.board-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.maia-board-wrapper {
  width: 100%;
  max-width: 600px;
  aspect-ratio: 1 / 1;
  background: #151515;
  border-radius: 12px;
  box-shadow: 0 20px 48px -12px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.08);
  position: relative;
  overflow: hidden;
  border: none;
}

.maia-chessboard {
  width: 100%;
  height: 100%;
  position: relative;
}

.maia-square {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease;
}

.maia-square.light { background-color: var(--board-light); }
.maia-square.dark { background-color: var(--board-dark); }

.maia-square.selected {
  background-color: rgba(20, 85, 30, 0.5) !important;
}

.maia-square.light.last-move-from,
.maia-square.light.last-move-to {
  background-color: #cdd26a !important;
}
.maia-square.dark.last-move-from,
.maia-square.dark.last-move-to {
  background-color: #829769 !important;
}

.maia-square.check {
  background: radial-gradient(circle, rgba(250, 81, 81, 0.85) 0%, rgba(250, 81, 81, 0.35) 75%, transparent 100%) !important;
  animation: check-pulse 1.8s ease-in-out infinite;
}

@keyframes check-pulse {
  0% { filter: drop-shadow(0 0 2px rgba(250, 81, 81, 0.4)); }
  50% { filter: drop-shadow(0 0 8px rgba(250, 81, 81, 0.8)); }
  100% { filter: drop-shadow(0 0 2px rgba(250, 81, 81, 0.4)); }
}

.coord {
  position: absolute;
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
  opacity: 0.75;
}

.coord-rank {
  top: 3px;
  left: 4px;
}

.coord-file {
  bottom: 2px;
  right: 4px;
}

.maia-square.light .coord { color: var(--board-dark); }
.maia-square.dark .coord { color: var(--board-light); }

.maia-piece {
  width: 90%;
  height: 90%;
  cursor: grab;
  position: relative;
  z-index: 10;
  transition: transform 0.12s cubic-bezier(0.2, 0, 0, 1);
  will-change: transform;
}

.maia-piece:hover {
  transform: scale(1.04);
}

.maia-piece:active {
  cursor: grabbing;
  transform: scale(1.12);
}

.legal-hint-dot {
  width: 24%;
  height: 24%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.28);
  pointer-events: none;
  position: absolute;
  z-index: 5;
}

.legal-hint-ring {
  width: 82%;
  height: 82%;
  border-radius: 50%;
  border: 4px solid rgba(0, 0, 0, 0.32);
  pointer-events: none;
  position: absolute;
  z-index: 5;
}

.maia-board-svg-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
}

.maia-board-svg-overlay line[stroke-dasharray] {
  animation: dash-flow 1.2s linear infinite;
}

@keyframes dash-flow {
  to {
    stroke-dashoffset: -20;
  }
}

/* Board Bottom Navigation Controls */
.board-controls {
  width: 100%;
  max-width: 600px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.btn-nav-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-nav {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
}

.btn-nav:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.branch-banner {
  width: 100%;
  max-width: 600px;
  background: rgba(250, 157, 59, 0.12);
  border: 1px solid rgba(250, 157, 59, 0.35);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--brand-gold);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Analysis Column (Right) */
.analysis-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* Evaluation Trend Chart */
.eval-chart-wrapper {
  background: var(--bg-card);
  border-radius: 10px;
  border: 1px solid var(--border-color);
  padding: 14px 18px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

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

.eval-chart-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.eval-chart-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.eval-chart-badge {
  font-size: 11px;
  font-family: monospace;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  transition: all 0.2s ease;
}

.eval-chart-legend {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-dim);
}

.eval-chart-legend .legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dot-red { width: 7px; height: 7px; border-radius: 50%; background: #ef4444; }
.dot-orange { width: 7px; height: 7px; border-radius: 50%; background: #f59e0b; }
.dot-gold { width: 7px; height: 7px; border-radius: 50%; background: #e6a520; }

.eval-chart-body {
  width: 100%;
  height: 125px;
  position: relative;
  overflow: hidden;
  border-radius: 6px;
}

.eval-chart-svg {
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.eval-chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(18, 24, 38, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  color: #fff;
  white-space: nowrap;
  transform: translate(-50%, -100%);
  display: none;
  z-index: 10;
  backdrop-filter: blur(4px);
}

/* Divergence Insight Box */
.divergence-box {
  background: var(--bg-card);
  border-radius: 10px;
  border: 1px solid var(--border-color);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.divergence-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--brand-gold);
  background: rgba(250, 157, 59, 0.12);
  padding: 3px 8px;
  border-radius: 4px;
  align-self: flex-start;
}

.divergence-content {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-main);
}

/* Three-way Comparison Panel */
.compare-panel {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}

.compare-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all 0.2s ease;
  cursor: default;
  min-width: 0;
}

.compare-card:hover {
  background: var(--bg-card-hover);
}

.compare-card.card-engine {
  border-color: rgba(7, 193, 96, 0.25);
}

.compare-card.card-intuition {
  border-color: rgba(230, 165, 32, 0.25);
}

.compare-card.card-played {
  border-color: rgba(255, 255, 255, 0.12);
}

.compare-card.card-played.is-blunder {
  border-color: rgba(250, 81, 81, 0.35);
  background: rgba(250, 81, 81, 0.04);
}

.compare-card-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.compare-card-label .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-engine { background: var(--brand-green); }
.dot-intuition { background: #e6a520; }
.dot-played { background: var(--text-muted); }

.compare-card-san {
  font-size: 18px;
  font-weight: 800;
  font-family: inherit;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compare-card-meta {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compare-match-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(7, 193, 96, 0.15);
  color: var(--brand-green);
  margin-left: 4px;
  vertical-align: middle;
}

/* Tabs: Blunder Leaderboard & Move Notation */
.panel-tabs {
  display: flex;
  background: var(--bg-card);
  border-radius: 10px 10px 0 0;
  border: 1px solid var(--border-color);
  border-bottom: none;
  overflow: hidden;
}

.tab-btn {
  flex: 1;
  padding: 12px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn.active {
  color: var(--brand-green);
  border-bottom: 2px solid var(--brand-green);
  background: rgba(7, 193, 96, 0.05);
}

.tab-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 0 0 10px 10px;
  flex: 1;
  max-height: 520px;
  overflow-y: auto;
  padding: 14px;
}

/* Blunder Cards */
.blunder-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.blunder-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.15s ease;
  cursor: pointer;
}

.blunder-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.16);
}

.blunder-card.active {
  border-color: rgba(230, 165, 32, 0.6);
  background: rgba(230, 165, 32, 0.08);
}

.blunder-card-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.blunder-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

.blunder-card-title {
  font-size: 13.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-main);
}

.blunder-move-num {
  color: var(--text-muted);
  font-weight: 600;
}

.blunder-side-icon {
  font-size: 11px;
}

.blunder-san {
  color: var(--text-main);
}

.blunder-tags-group {
  display: flex;
  align-items: center;
  gap: 5px;
}

.blunder-type-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 1.5px 6px;
  border-radius: 4px;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.tag-blunder {
  background: rgba(239, 68, 68, 0.18);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.tag-mistake {
  background: rgba(245, 158, 11, 0.18);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.tag-inaccuracy {
  background: rgba(245, 158, 11, 0.12);
  color: #eab308;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.tag-trap {
  background: rgba(230, 165, 32, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(230, 165, 32, 0.35);
}

.blunder-loss-tag {
  font-size: 11px;
  font-weight: 700;
  color: #ef4444;
  white-space: nowrap;
  margin-left: auto;
  background: rgba(239, 68, 68, 0.08);
  padding: 2px 7px;
  border-radius: 4px;
}

.blunder-card-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.sub-best-move strong {
  color: var(--brand-green);
  font-weight: 700;
}

.sub-trap-prob {
  color: #fbbf24;
  font-size: 11px;
}

/* Move Notation Table */
.move-notation-table {
  width: 100%;
  display: flex;
  flex-direction: column;
}

.notation-row {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 4px;
}

.notation-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.notation-num {
  width: 38px;
  color: var(--text-dim);
  font-size: 12px;
}

.notation-move {
  flex: 1;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.notation-move:hover {
  background: rgba(255, 255, 255, 0.08);
}

.notation-move.active {
  background: rgba(7, 193, 96, 0.2);
  color: var(--brand-green);
  font-weight: 700;
}

.annotation-badge {
  font-size: 11px;
  font-weight: 700;
  margin-left: 4px;
}
.annotation-blunder { color: var(--brand-red); }
.annotation-mistake { color: var(--brand-gold); }

/* PGN Import Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 90%;
  max-width: 520px;
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
}

.pgn-textarea {
  width: 100%;
  height: 180px;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-main);
  padding: 10px;
  font-family: monospace;
  font-size: 12px;
  resize: vertical;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Global Drag & Drop Overlay */
.drag-drop-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: all 0.2s ease;
}

.drag-drop-card {
  border: 2px dashed var(--brand-green);
  background: rgba(7, 193, 96, 0.08);
  border-radius: 16px;
  padding: 40px 60px;
  text-align: center;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  animation: pulse-drop 1.5s infinite alternate ease-in-out;
}

@keyframes pulse-drop {
  from { transform: scale(0.98); }
  to { transform: scale(1.02); }
}

/* Floating Toast Notification */
.studio-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(18, 24, 38, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.studio-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

