/* ==========================================================================
   ESPDIY.COM - 专用交互组件样式 (components.css)
   包含：Pinout速查器、WebFlasher烧录器、BOM材料清单、项目筛选器、对比器
   ========================================================================== */

/* ==========================================================================
   1. 交互式 Pinout 引脚速查器 (Pinout Explorer)
   ========================================================================== */
.pinout-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 32px;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-lg);
}

.pinout-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.chip-select-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.chip-btn {
  background: #1e293b;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.chip-btn:hover {
  background: #334155;
  color: #fff;
  border-color: var(--color-cyan);
}

.chip-btn.active {
  background: var(--color-cyan);
  color: #090d16;
  border-color: var(--color-cyan);
  box-shadow: 0 2px 10px rgba(6, 182, 212, 0.4);
}

/* 引脚类型筛选器图例 */
.pin-filter-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--border-subtle);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
  user-select: none;
}

.filter-chip:hover {
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

.filter-chip.active {
  background: #1e293b;
  color: #fff;
  border-color: var(--color-cyan);
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.25);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* 核心 Pinout 可视化主视区 */
.pinout-stage {
  position: relative;
  min-height: 480px;
  background: #080c15;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
  overflow-x: auto;
}

.board-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  position: relative;
}

.board-pins-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pin-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 6px;
  transition: var(--transition-fast);
}

.pin-row:hover, .pin-row.highlighted {
  background: rgba(6, 182, 212, 0.15);
  transform: scale(1.02);
}

.pin-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 4px;
  min-width: 72px;
  text-align: center;
  font-weight: 600;
  transition: var(--transition-fast);
}

.pin-row.left .pin-tag {
  text-align: right;
}

.pin-hardware-hole {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #334155;
  border: 2px solid #64748b;
  transition: var(--transition-fast);
  flex-shrink: 0;
}

.pin-row:hover .pin-hardware-hole, .pin-row.highlighted .pin-hardware-hole {
  border-color: #fff;
  transform: scale(1.2);
}

/* 模拟板身 */
.board-body-pcb {
  width: 190px;
  height: 380px;
  background: linear-gradient(180deg, #064e3b 0%, #022c22 100%);
  border: 2px solid #059669;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), inset 0 0 15px rgba(16, 185, 129, 0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 16px 10px;
  position: relative;
  user-select: none;
}

.board-metal-shield {
  width: 140px;
  height: 160px;
  background: linear-gradient(135deg, #94a3b8 0%, #475569 50%, #64748b 100%);
  border-radius: 6px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid #cbd5e1;
  color: #0f172a;
  text-align: center;
  padding: 8px;
}

.board-metal-shield .shield-title {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.board-metal-shield .shield-sub {
  font-size: 0.65rem;
  font-weight: 600;
  opacity: 0.85;
}

.board-usb-port {
  width: 44px;
  height: 20px;
  background: #cbd5e1;
  border: 2px solid #475569;
  border-radius: 3px;
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.4);
}

.board-leds {
  display: flex;
  gap: 10px;
}

.board-led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 6px #ef4444;
}

.board-led.blue {
  background: #3b82f6;
  box-shadow: 0 0 6px #3b82f6;
}

/* 硬件避坑警告栏 */
.hardware-alerts-bar {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.alert-card {
  background: rgba(236, 72, 153, 0.08);
  border: 1px solid rgba(236, 72, 153, 0.3);
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.alert-card.warning-amber {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.3);
}

.alert-icon {
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
}

.alert-content h5 {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.alert-content p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* 引脚悬停悬浮卡片 (Popover) */
.pin-popover {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #0d1527;
  border: 1px solid var(--color-cyan);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), var(--glow-cyan);
  padding: 16px 20px;
  border-radius: 12px;
  min-width: 320px;
  max-width: 440px;
  z-index: 100;
  pointer-events: none;
  animation: fadeIn 0.2s ease-out;
}

.pin-popover h4 {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  color: var(--color-cyan);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pin-popover .pin-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.pin-popover .pin-warning-tag {
  color: #f43f5e;
  font-weight: 600;
  font-size: 0.8rem;
}

/* ==========================================================================
   2. Web 固件免驱一键烧录器 (Web Flasher)
   ========================================================================== */
.flasher-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 32px;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-lg);
}

.flasher-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}

.flasher-config-box {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-select, .form-input {
  background: #1e293b;
  border: 1px solid var(--border-subtle);
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  transition: var(--transition-fast);
}

.form-select:focus, .form-input:focus {
  outline: none;
  border-color: var(--color-cyan);
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.3);
}

/* 固件卡片选择单选器 */
.firmware-cards-group {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.firmware-card {
  background: #131d31;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.firmware-card:hover {
  background: #1e293b;
  border-color: var(--color-cyan);
}

.firmware-card.selected {
  background: rgba(6, 182, 212, 0.12);
  border-color: var(--color-cyan);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.25);
}

.firmware-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
}

.firmware-version {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-cyan);
}

.firmware-desc {
  font-size: 0.775rem;
  color: var(--text-dim);
  line-height: 1.4;
  margin-top: 4px;
}

/* 烧录控制台窗口 */
.flasher-console-box {
  background: #050811;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.console-header {
  background: #0c1220;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.console-dots {
  display: flex;
  gap: 6px;
}

.console-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #334155;
}

.console-dot.red { background: #ef4444; }
.console-dot.yellow { background: #f59e0b; }
.console-dot.green { background: #10b981; }

.console-screen {
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.825rem;
  line-height: 1.6;
  color: #a5f3fc;
  height: 280px;
  overflow-y: auto;
  background: #03060c;
}

.console-line {
  margin-bottom: 4px;
  word-break: break-all;
}

.console-line.success { color: var(--color-emerald); }
.console-line.warning { color: var(--color-amber); }
.console-line.error { color: var(--color-rose); }
.console-line.dim { color: var(--text-dim); }

/* 烧录进度条 */
.progress-bar-wrapper {
  margin-top: 14px;
  background: #1e293b;
  border-radius: 9999px;
  height: 8px;
  overflow: hidden;
}

.progress-bar-fill {
  background: linear-gradient(90deg, var(--color-cyan), var(--color-emerald));
  height: 100%;
  width: 0%;
  transition: width 0.2s ease;
  box-shadow: 0 0 10px var(--color-cyan);
}

/* ==========================================================================
   3. 项目库与多维即时筛选系统 (Projects Explorer)
   ========================================================================== */
.projects-filter-bar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 36px;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-row-label {
  font-size: 0.825rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  font-family: var(--font-mono);
  min-width: 80px;
}

.filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-btn {
  background: #131d31;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.825rem;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.tag-btn:hover {
  background: #1e293b;
  color: #fff;
}

.tag-btn.active {
  background: var(--color-cyan);
  color: #090d16;
  font-weight: 600;
  border-color: var(--color-cyan);
  box-shadow: 0 2px 8px rgba(6, 182, 212, 0.4);
}

/* 项目卡片网格 */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 28px;
}

.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  overflow: hidden;
  transition: var(--transition-normal);
  display: flex;
  flex-direction: column;
  cursor: pointer;
}

.project-card:hover {
  transform: translateY(-6px);
  border-color: rgba(6, 182, 212, 0.5);
  box-shadow: var(--shadow-lg), var(--glow-cyan);
}

.project-thumb {
  height: 200px;
  background: #1e293b;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.project-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.project-card:hover .project-thumb img {
  transform: scale(1.05);
}

.project-badges {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 6px;
}

.badge {
  padding: 3px 8px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.725rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-chip {
  background: rgba(6, 182, 212, 0.9);
  color: #090d16;
}

.badge-difficulty {
  background: rgba(16, 185, 129, 0.9);
  color: #090d16;
}

.badge-difficulty.intermediate {
  background: rgba(245, 158, 11, 0.9);
  color: #090d16;
}

.badge-difficulty.advanced {
  background: rgba(244, 63, 94, 0.9);
  color: #fff;
}

.project-content {
  padding: 22px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.project-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
  line-height: 1.35;
}

.project-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 18px;
  flex-grow: 1;
}

.project-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.8rem;
  color: var(--text-dim);
}

.project-cost {
  color: var(--color-emerald);
  font-family: var(--font-mono);
  font-weight: 700;
}

/* ==========================================================================
   4. 项目详情模态框 (Project Modal)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(5, 8, 16, 0.85);
  backdrop-filter: blur(12px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}

.modal-overlay.active {
  display: flex;
}

.modal-dialog {
  background: #0d1424;
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.75), var(--glow-cyan);
  position: relative;
  animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #1e293b;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: var(--transition-fast);
  z-index: 10;
}

.modal-close-btn:hover {
  background: var(--color-rose);
  color: #fff;
}

.modal-body {
  padding: 36px;
}

/* BOM 清单表格 */
.bom-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 24px 0;
  font-size: 0.875rem;
}

.bom-table th {
  background: #131d31;
  color: var(--text-muted);
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.bom-table td {
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.bom-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.bom-buy-link {
  color: var(--color-cyan);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.bom-buy-link:hover {
  text-decoration: underline;
}

/* 代码块容器 */
.code-container {
  background: #050811;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  margin: 16px 0 24px 0;
  overflow: hidden;
}

.code-header-bar {
  background: #0f172a;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.copy-code-btn {
  background: #1e293b;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.copy-code-btn:hover {
  color: #fff;
  border-color: var(--color-cyan);
}

.code-pre {
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.825rem;
  line-height: 1.6;
  color: #e2e8f0;
  overflow-x: auto;
  max-height: 380px;
}

/* ==========================================================================
   5. 芯片参数横向全景对比器 (Chip Comparator)
   ========================================================================== */
.comparator-table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  padding: 24px;
  overflow-x: auto;
  box-shadow: var(--shadow-md);
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

.compare-table th, .compare-table td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.compare-table th {
  background: #0d1527;
  color: #fff;
  font-family: var(--font-heading);
  font-size: 1rem;
}

.compare-table td:first-child {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--color-cyan);
  font-size: 0.85rem;
  background: rgba(6, 182, 212, 0.03);
}

/* ==========================================================================
   6. 常见硬件避坑与排错折叠卡 (FAQ / Troubleshooting)
   ========================================================================== */
.faq-accordion {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  overflow: hidden;
  transition: var(--transition-fast);
}

.faq-item:hover {
  border-color: rgba(6, 182, 212, 0.3);
}

.faq-question {
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  user-select: none;
}

.faq-icon {
  font-size: 1.25rem;
  color: var(--color-cyan);
  transition: transform 0.25s ease;
}

.faq-item.active .faq-icon {
  transform: rotate(180deg);
}

.faq-answer {
  display: none;
  padding: 0 24px 20px 24px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.65;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  padding-top: 14px;
}

.faq-item.active .faq-answer {
  display: block;
}

/* 响应式调整 */
@media (max-width: 900px) {
  .flasher-grid {
    grid-template-columns: 1fr;
  }
  .firmware-cards-group {
    grid-template-columns: 1fr;
  }
}
