/* ==========================================================================
   PORTAO ESP-NOW · MASTERPIECE CYBER-GROWTH DESIGN SYSTEM
   Seguindo Padrão Arquitetural /oficina · Artes do Sul
   ========================================================================== */

:root {
  --bg-primary: #080c0a;
  --bg-surface: #101714;
  --bg-surface-elevated: #16221d;
  --bg-card: rgba(18, 26, 22, 0.78);
  --bg-glass: rgba(14, 21, 18, 0.68);
  --bg-glass-elevated: rgba(22, 34, 29, 0.85);

  --ink-primary: #f0f6f2;
  --ink-secondary: #a3b8ad;
  --ink-muted: #6b8075;
  --line: rgba(255, 255, 255, 0.09);
  --line-focus: rgba(255, 107, 53, 0.4);

  --accent-orange: #ff6b35;
  --accent-orange-soft: rgba(255, 107, 53, 0.15);
  --accent-cyan: #00d9ff;
  --accent-cyan-soft: rgba(0, 217, 255, 0.14);
  --accent-green: #10b981;
  --accent-green-soft: rgba(16, 185, 129, 0.15);
  --accent-purple: #a855f7;
  --accent-purple-soft: rgba(168, 85, 247, 0.15);
  --accent-gold: #f59e0b;
  --accent-gold-soft: rgba(245, 158, 11, 0.15);

  /* Marketplaces Colors */
  --color-shopee: #ee4d2d;
  --color-ml: #ffe600;
  --color-amazon: #ff9900;
  --color-aliexpress: #ff4747;

  --font-display: "Bricolage Grotesque", "Chakra Petch", -apple-system, sans-serif;
  --font-body: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "IBM Plex Mono", Consolas, monospace;

  --glass-blur: blur(14px);
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 9999px;

  --shadow-card: 0 8px 32px 0 rgba(0, 0, 0, 0.45);
  --shadow-glow-orange: 0 0 25px rgba(255, 107, 53, 0.25);
  --shadow-glow-cyan: 0 0 25px rgba(0, 217, 255, 0.22);
}

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

html {
  scroll-behavior: smooth;
  color-scheme: dark;
}

body {
  background-color: var(--bg-primary);
  color: var(--ink-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Background Grid Overlay */
body::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: 
    linear-gradient(to right, rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

a {
  color: var(--accent-orange);
  text-decoration: none;
  transition: color 0.2s ease, text-shadow 0.2s ease;
}

a:hover {
  color: #ff8c5f;
  text-shadow: 0 0 8px rgba(255, 107, 53, 0.4);
}

code, pre {
  font-family: var(--font-mono);
}

.shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px 80px;
  position: relative;
  z-index: 1;
}

/* ==========================================================================
   Topbar Header
   ========================================================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: var(--glass-blur);
  background: var(--bg-glass);
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #fff;
}

.brand-logo {
  font-size: 1.6rem;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 10px rgba(0, 217, 255, 0.2);
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  display: block;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-topbar {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface-elevated);
  color: var(--ink-secondary);
  border: 1px solid var(--line);
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-topbar:hover, .btn-topbar.active {
  color: #fff;
  border-color: var(--accent-orange);
  background: var(--accent-orange-soft);
  text-shadow: none;
}

.btn-topbar.btn-accent {
  background: var(--accent-cyan-soft);
  color: var(--accent-cyan);
  border-color: rgba(0, 217, 255, 0.35);
  font-weight: 600;
}

.btn-topbar.btn-accent:hover {
  background: var(--accent-cyan);
  color: #000;
}

/* ==========================================================================
   Hero Cinematic Banner
   ========================================================================== */
.hero-cinematic {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 32px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  min-height: 420px;
  display: flex;
  align-items: flex-end;
}

.hero-bg-wrapper {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1;
}

.hero-bg-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  filter: brightness(0.65) contrast(1.1);
}

.hero-gradient-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, rgba(8, 12, 10, 0.3) 0%, rgba(8, 12, 10, 0.85) 60%, rgba(8, 12, 10, 0.98) 100%);
}

.hero-content {
  position: relative;
  z-index: 2;
  padding: 40px;
  width: 100%;
}

.hero-badges {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.badge-glow {
  background: rgba(255, 107, 53, 0.18);
  color: var(--accent-orange);
  border: 1px solid rgba(255, 107, 53, 0.4);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

.badge-pulse {
  background: rgba(0, 217, 255, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 217, 255, 0.35);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hero-content h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 12px;
  letter-spacing: -0.03em;
}

.hero-content h1 span {
  background: linear-gradient(135deg, #00d9ff 0%, #ff6b35 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-lead {
  font-size: 1.05rem;
  color: var(--ink-secondary);
  max-width: 850px;
  line-height: 1.6;
  margin-bottom: 24px;
}

/* Quick Telemetry Grid in Hero */
.hero-specs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.hero-spec-card {
  background: var(--bg-glass-elevated);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.hero-spec-card:hover {
  transform: translateY(-2px);
  border-color: rgba(0, 217, 255, 0.4);
}

.hero-spec-val {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  display: block;
}

.hero-spec-lbl {
  font-size: 0.72rem;
  color: var(--accent-cyan);
  text-transform: uppercase;
  font-family: var(--font-mono);
  margin-top: 2px;
  display: block;
}

/* ==========================================================================
   Navigation Tabs Bar
   ========================================================================== */
.tabs-nav {
  display: flex;
  gap: 8px;
  background: var(--bg-surface);
  padding: 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  margin-bottom: 32px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-secondary);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.tab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  background: var(--bg-surface-elevated);
  color: var(--accent-cyan);
  border-color: rgba(0, 217, 255, 0.35);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  font-weight: 600;
}

/* Tab Panels */
.tab-panel {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-panel.active {
  display: block;
}

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

/* ==========================================================================
   Section Headers & Cards
   ========================================================================== */
.section-header {
  margin-bottom: 24px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.section-desc {
  color: var(--ink-secondary);
  font-size: 0.95rem;
}

/* ==========================================================================
   Esquema Elétrico & Diagramas
   ========================================================================== */
.schematic-box {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 32px;
}

.schematic-img-wrap {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--line);
  margin-bottom: 20px;
  background: #000;
}

.schematic-img {
  width: 100%;
  display: block;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.schematic-zoom-hint {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.8);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  color: var(--accent-cyan);
}

/* Interactive Circuit Diagram */
.circuit-ascii-card {
  background: #050806;
  border: 1px solid rgba(0, 217, 255, 0.2);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 24px;
  overflow-x: auto;
}

.circuit-ascii-card pre {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.45;
  color: #7ef1a0;
}

/* Pinout Tables */
.pinout-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 32px;
}

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

.pinout-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 20px;
}

.pinout-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.pinout-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pinout-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.pinout-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.pinout-table td {
  padding: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}

.pin-badge {
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.78rem;
  display: inline-block;
  white-space: nowrap;
}

.pin-red { background: rgba(239, 68, 68, 0.15); color: #ef4444; border: 1px solid #ef4444; }
.pin-orange { background: rgba(255, 107, 53, 0.15); color: #ff6b35; border: 1px solid #ff6b35; }
.pin-cyan { background: rgba(0, 217, 255, 0.15); color: #00d9ff; border: 1px solid #00d9ff; }
.pin-green { background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid #10b981; }
.pin-purple { background: rgba(168, 85, 247, 0.15); color: #a855f7; border: 1px solid #a855f7; }
.pin-gold { background: rgba(245, 158, 11, 0.15); color: #f59e0b; border: 1px solid #f59e0b; }
.pin-gray { background: rgba(156, 163, 175, 0.15); color: #9ca3af; border: 1px solid #9ca3af; }

/* ==========================================================================
   Hardware BOM & Marketplaces Cards
   ========================================================================== */
.bom-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.bom-summary-badge {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: var(--bg-surface-elevated);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  color: var(--accent-green);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.bom-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.bom-card {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  position: relative;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.bom-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 107, 53, 0.4);
  box-shadow: var(--shadow-card), 0 0 20px rgba(255, 107, 53, 0.12);
}

.bom-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.bom-item-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
  line-height: 1.3;
}

.bom-item-qty {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  color: var(--accent-cyan);
  white-space: nowrap;
}

.bom-item-role {
  font-size: 0.85rem;
  color: var(--accent-orange);
  font-family: var(--font-mono);
}

.bom-item-obs {
  font-size: 0.85rem;
  color: var(--ink-secondary);
  line-height: 1.5;
}

.bom-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-surface-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  font-size: 0.8rem;
}

.bom-price-est {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-green);
}

/* Marketplace Action Buttons */
.buy-buttons-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 4px;
}

@media (max-width: 480px) {
  .buy-buttons-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.btn-marketplace {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  padding: 8px 4px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-shopee {
  background: rgba(238, 77, 45, 0.12);
  color: #ee4d2d;
  border-color: rgba(238, 77, 45, 0.3);
}
.btn-shopee:hover {
  background: #ee4d2d;
  color: #fff;
  box-shadow: 0 0 12px rgba(238, 77, 45, 0.5);
}

.btn-ml {
  background: rgba(255, 230, 0, 0.12);
  color: #ffe600;
  border-color: rgba(255, 230, 0, 0.3);
}
.btn-ml:hover {
  background: #ffe600;
  color: #000;
  box-shadow: 0 0 12px rgba(255, 230, 0, 0.5);
}

.btn-amazon {
  background: rgba(255, 153, 0, 0.12);
  color: #ff9900;
  border-color: rgba(255, 153, 0, 0.3);
}
.btn-amazon:hover {
  background: #ff9900;
  color: #000;
  box-shadow: 0 0 12px rgba(255, 153, 0, 0.5);
}

.btn-aliexpress {
  background: rgba(255, 71, 71, 0.12);
  color: #ff4747;
  border-color: rgba(255, 71, 71, 0.3);
}
.btn-aliexpress:hover {
  background: #ff4747;
  color: #fff;
  box-shadow: 0 0 12px rgba(255, 71, 71, 0.5);
}

/* ==========================================================================
   Interactive Energy & Battery Calculator
   ========================================================================== */
.calc-container {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 40px;
}

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

@media (max-width: 850px) {
  .calc-grid {
    grid-template-columns: 1fr;
  }
}

.calc-input-group {
  margin-bottom: 20px;
}

.calc-label {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--ink-secondary);
  margin-bottom: 8px;
}

.calc-label-val {
  color: var(--accent-cyan);
  font-weight: 700;
}

.calc-slider {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-surface-elevated);
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.calc-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-orange);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(255, 107, 53, 0.6);
}

.calc-results-box {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.calc-metric-highlight {
  text-align: center;
  padding: 20px;
  background: rgba(0, 217, 255, 0.05);
  border: 1px solid rgba(0, 217, 255, 0.2);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
}

.calc-big-num {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 800;
  color: #fff;
  line-height: 1;
}

.calc-big-num span {
  font-size: 1.2rem;
  color: var(--accent-green);
  font-family: var(--font-mono);
}

.calc-breakdown-list {
  list-style: none;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.calc-breakdown-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink-secondary);
}

.calc-breakdown-item span:last-child {
  color: #fff;
  font-weight: 600;
}

/* ==========================================================================
   Firmware & Code Tabs
   ========================================================================== */
.code-viewer-card {
  background: #070b09;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 32px;
}

.code-viewer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-surface-elevated);
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}

.code-filename {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-copy {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  color: var(--ink-primary);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-copy:hover {
  background: var(--accent-orange);
  color: #000;
  border-color: var(--accent-orange);
}

.code-pre {
  padding: 20px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
  color: #e2e8f0;
  overflow-x: auto;
  max-height: 480px;
}

/* ==========================================================================
   Checklist & Installation Rules
   ========================================================================== */
.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.rule-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 20px;
  border-left: 4px solid var(--accent-orange);
}

.rule-number {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent-orange);
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.rule-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
}

.rule-desc {
  font-size: 0.88rem;
  color: var(--ink-secondary);
  line-height: 1.5;
}

/* Footer */
.footer {
  margin-top: 60px;
  padding-top: 30px;
  border-top: 1px solid var(--line);
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.85rem;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
