/* ========== 全局重置 ========== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #0f0f13;
  color: #e4e4e8;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ========== 顶部状态栏 ========== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: linear-gradient(180deg, #1a1a24 0%, #14141c 100%);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.app-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #60a5fa, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-status {
  display: flex;
  gap: 10px;
}

.status-badge {
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 12px;
}

.status-on {
  background: #166534;
  color: #bbf7d0;
}

.status-off {
  background: #7f1d1d;
  color: #fca5a5;
}

.status-warn {
  background: #854d0e;
  color: #fef08a;
}

/* ========== 主布局 ========== */
.app-main {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 16px;
  padding: 16px;
  max-width: 1800px;
  margin: 0 auto;
}

@media (max-width: 1400px) {
  .app-main {
    grid-template-columns: 1fr 1fr;
  }
  .assist-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .app-main {
    grid-template-columns: 1fr;
  }
}

/* ========== 面板通用 ========== */
.panel {
  background: #16161e;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 600px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.panel-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: #f4f4f5;
}

/* ========== 按钮 ========== */
.btn {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  padding: 8px 16px;
  border: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.btn-blue {
  background: #1d4ed8;
  color: #fff;
}
.btn-blue:hover:not(:disabled) {
  background: #2563eb;
  transform: translateY(-1px);
}

.btn-red {
  background: #991b1b;
  color: #fff;
}
.btn-red:hover:not(:disabled) {
  background: #b91c1c;
}

.btn-green {
  background: #166534;
  color: #fff;
}
.btn-green:hover:not(:disabled) {
  background: #15803d;
}

.btn-slate {
  background: #27272a;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.15);
}
.btn-slate:hover:not(:disabled) {
  background: #3f3f46;
}

.btn-block {
  width: 100%;
  padding: 10px;
  font-size: 0.9rem;
}

/* ========== 视频区域 ========== */
.video-container {
  position: relative;
  background: #0a0a0f;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 16/9;
  min-height: 300px;
}

.capture-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.capture-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* 裁剪覆盖层 */
.crop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 10;
  cursor: crosshair;
}

.crop-instruction {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(96,165,250,0.9);
  color: #fff;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  z-index: 11;
}

.crop-box {
  position: absolute;
  border: 2px dashed #60a5fa;
  background: rgba(96,165,250,0.1);
  border-radius: 4px;
}

/* 检测叠加层 */
.detection-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.detection-box {
  position: absolute;
  border: 2px solid #4ade80;
  background: rgba(74,222,128,0.08);
  border-radius: 4px;
  transition: all 0.2s ease;
}

.detection-box.enemy {
  border-color: #f87171;
  background: rgba(248,113,113,0.08);
}

.detection-label {
  position: absolute;
  top: -20px;
  left: -2px;
  background: #4ade80;
  color: #0a0a0f;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  white-space: nowrap;
}

.detection-box.enemy .detection-label {
  background: #f87171;
}

/* ========== 捕获信息 ========== */
.capture-info {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.03);
  border-radius: 8px;
}

.info-row {
  font-size: 0.78rem;
  color: #a1a1aa;
  display: flex;
  align-items: center;
  gap: 4px;
}

.info-row span:last-child {
  color: #e4e4e8;
  font-weight: 600;
}

.select-inline {
  background: #1e1e28;
  border: 1px solid rgba(255,255,255,0.15);
  color: #e4e4e8;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.78rem;
}

/* ========== 队伍区域 ========== */
.team-section {
  margin-bottom: 8px;
}

.team-title {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ally-title {
  color: #60a5fa;
}

.opponent-title {
  color: #f87171;
}

.toggle-label-inline {
  font-size: 0.7rem;
  color: #a1a1aa;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}

/* 我方队伍网格 */
.team-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

@media (max-width: 600px) {
  .team-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.pokemon-slot {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all 0.2s ease;
  min-height: 100px;
}

.pokemon-slot.empty {
  align-items: center;
  justify-content: center;
  opacity: 0.5;
}

.pokemon-slot.identified {
  background: rgba(96,165,250,0.08);
  border-color: rgba(96,165,250,0.3);
}

.pokemon-slot.active {
  border-color: #4ade80;
  box-shadow: 0 0 12px rgba(74,222,128,0.2);
}

.pokemon-slot.fainted {
  opacity: 0.3;
  filter: grayscale(0.8);
}

.slot-placeholder {
  font-size: 0.7rem;
  color: #71717a;
  text-align: center;
}

.poke-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: rgba(0,0,0,0.3);
  border-radius: 6px;
}

.poke-name {
  font-size: 0.7rem;
  font-weight: 700;
  color: #f4f4f5;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.poke-types {
  display: flex;
  gap: 2px;
  justify-content: center;
}

.type-badge {
  font-size: 0.55rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  color: #fff;
  text-transform: uppercase;
}

.poke-hp-bar {
  height: 3px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
}

.poke-hp-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* 对手列表 */
.team-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.opponent-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  min-height: 56px;
}

.opponent-card.empty {
  justify-content: center;
}

.opponent-card.identified {
  background: rgba(248,113,113,0.06);
  border-color: rgba(248,113,113,0.2);
}

.opponent-card.active {
  border-color: #f87171;
  box-shadow: 0 0 12px rgba(248,113,113,0.15);
}

.opp-thumb-wrap {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  background: rgba(0,0,0,0.3);
  border-radius: 6px;
  overflow: hidden;
}

.opp-thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.opp-info {
  flex: 1;
  min-width: 0;
}

.opp-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.opp-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: #f4f4f5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.opp-meta {
  font-size: 0.6rem;
  color: #a1a1aa;
  line-height: 1.3;
}

.opp-stats {
  display: flex;
  gap: 4px;
  font-size: 0.6rem;
  color: #d4d4d8;
}

.opp-stat {
  background: rgba(255,255,255,0.06);
  padding: 1px 4px;
  border-radius: 3px;
}

/* ========== 对战日志 ========== */
.battle-log-section {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.log-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #e5e7eb;
  margin-bottom: 6px;
}

.battle-log {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 8px 10px;
  flex: 1;
  overflow-y: auto;
  max-height: 200px;
  font-size: 0.75rem;
  line-height: 1.6;
}

.log-entry {
  padding: 2px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.log-info { color: #93c5fd; }
.log-success { color: #4ade80; }
.log-warning { color: #fbbf24; }
.log-error { color: #f87171; }
.log-battle { color: #d8b4fe; }

/* ========== 辅助面板 ========== */
.assist-panel {
  gap: 14px;
}

.selected-pokemon {
  background: rgba(96,165,250,0.06);
  border: 1px solid rgba(96,165,250,0.2);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.selected-thumb {
  width: 64px;
  height: 64px;
  object-fit: contain;
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
}

.selected-name {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}

.selected-meta {
  font-size: 0.75rem;
  color: #a1a1aa;
}

.selected-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: #d4d4d8;
}

.stat-line span:first-child {
  width: 36px;
  color: #a1a1aa;
  font-weight: 600;
}

.stat-bar {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
}

.stat-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.hp-fill { background: linear-gradient(90deg, #4ade80, #22c55e); }
.hp-fill.medium { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.hp-fill.low { background: linear-gradient(90deg, #f87171, #ef4444); }

.stat-value {
  font-weight: 700;
  font-family: 'SF Mono', 'Fira Code', monospace;
  min-width: 40px;
  text-align: right;
}

.stat-value.high { color: #4ade80; }
.stat-value.medium { color: #fbbf24; }
.stat-value.low { color: #f87171; }

.selected-moves h4,
.selected-abilities h4,
.selected-items h4 {
  font-size: 0.75rem;
  color: #a1a1aa;
  margin-bottom: 4px;
  font-weight: 600;
}

.moves-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.move-card {
  background: rgba(59,130,246,0.12);
  border: 1px solid rgba(59,130,246,0.2);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.7rem;
  color: #eff6ff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.move-card.disabled {
  opacity: 0.35;
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.06);
}

.move-pp {
  font-size: 0.6rem;
  color: #93c5fd;
}

.ability-text,
.item-text {
  font-size: 0.75rem;
  color: #d4d4d8;
  background: rgba(255,255,255,0.04);
  padding: 4px 8px;
  border-radius: 6px;
}

/* ========== 类型分析 ========== */
.type-chart-section {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 12px;
}

.type-chart-section h3 {
  font-size: 0.85rem;
  font-weight: 700;
  color: #e5e7eb;
  margin-bottom: 8px;
}

.type-hint {
  font-size: 0.75rem;
  color: #71717a;
  text-align: center;
  padding: 8px;
}

.type-analysis-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.type-result {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
}

.type-result.super-effective {
  background: rgba(248,113,113,0.15);
  color: #fca5a5;
}

.type-result.not-very-effective {
  background: rgba(96,165,250,0.1);
  color: #93c5fd;
}

.type-result.immune {
  background: rgba(255,255,255,0.04);
  color: #71717a;
}

.type-result-label {
  font-weight: 700;
  min-width: 48px;
}

/* ========== 匹配结果 ========== */
.match-section {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 12px;
}

.match-section h3 {
  font-size: 0.85rem;
  font-weight: 700;
  color: #e5e7eb;
  margin-bottom: 8px;
}

.match-results {
  font-size: 0.75rem;
}

.match-status {
  color: #71717a;
  text-align: center;
  padding: 8px;
}

.match-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.match-card:hover {
  background: rgba(96,165,250,0.08);
  border-color: rgba(96,165,250,0.25);
}

.match-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.match-card-name {
  font-weight: 700;
  color: #f4f4f5;
}

.match-card-rate {
  font-size: 0.65rem;
  color: #4ade80;
  font-weight: 700;
}

.match-card-preview {
  display: flex;
  gap: 3px;
}

.match-mini-slot {
  width: 24px;
  height: 24px;
  background: rgba(0,0,0,0.3);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.55rem;
}

/* ========== 伤害计算器 ========== */
.damage-calc {
  background: rgba(34,197,94,0.06);
  border: 1px solid rgba(34,197,94,0.15);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.damage-calc h3 {
  font-size: 0.85rem;
  font-weight: 700;
  color: #4ade80;
}

.calc-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.calc-row label {
  font-size: 0.75rem;
  color: #a1a1aa;
  min-width: 48px;
  font-weight: 600;
}

.select-block {
  flex: 1;
  background: #1e1e28;
  border: 1px solid rgba(255,255,255,0.12);
  color: #e4e4e8;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 0.78rem;
}

.calc-result {
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  padding: 10px;
  font-size: 0.78rem;
  line-height: 1.6;
  min-height: 60px;
}

.calc-result-text {
  color: #d4d4d8;
}

.calc-damage-range {
  font-size: 1.1rem;
  font-weight: 700;
  color: #4ade80;
  margin: 4px 0;
}

.calc-percent {
  font-size: 0.85rem;
  color: #fbbf24;
  font-weight: 600;
}

/* ========== 底部调试 ========== */
.app-footer {
  padding: 8px 24px;
  background: #0a0a0f;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.debug-section {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 0.72rem;
}

.debug-row {
  color: #71717a;
  display: flex;
  align-items: center;
  gap: 4px;
}

.debug-value {
  color: #93c5fd;
  font-weight: 600;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

/* ========== 开关 ========== */
.toggle-label {
  font-size: 0.78rem;
  color: #d4d4d8;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.toggle-label input[type="checkbox"] {
  accent-color: #60a5fa;
  width: 14px;
  height: 14px;
}

/* ========== 滚动条 ========== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.02);
}

::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.2);
}

/* ========== 动画 ========== */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

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

.pokemon-slot.identified,
.opponent-card.identified {
  animation: slideUp 0.3s ease;
}

.detecting-pulse {
  animation: pulse 1.5s ease infinite;
}