/* =============================================
   components.css (Reusable UI components)
   Depends on: base.css (tokens), layout.css (grids)
   ============================================= */

/* Buttons */
.btn {
  display: inline-block;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  letter-spacing: 0.01em;
  background: transparent;
  transition: 0.2s;
}
.btn.primary {
  background: var(--brand);
  color: #0a0c10;
  border-color: var(--brand-700);
  font-weight: 700;
  box-shadow: 0 0 22px rgba(0, 255, 209, 0.25);
}
.btn.primary:hover {
  background: var(--brand-700);
}
.btn.small {
  padding: 6px 10px;
  font-size: 13px;
}
.select.small {
  padding: 6px 10px;
  font-size: 13px;
}
.btn:hover {
  border-color: rgba(0, 231, 255, 0.2);
  transform: translateY(-1px);
  background: rgba(0, 0, 0, 0.3);
}

/* Cards & KPI */
.card,
.kpi,
.note,
.chart-wrap,
.sim-panel,
.scenario-chart,
.financial-metrics,
.investment-input,
.accordion .item,
.inputs,
.portfolio-stat,
.strategy-item,
.site-card,
.metric-group,
.metric,
.box-common {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-soft);
  transition: 0.2s;
}
.card:hover,
.kpi:hover,
.portfolio-stat:hover,
.metric:hover {
  border-color: rgba(0, 231, 255, 0.2);
  transform: translateY(-2px);
}
.card h3 {
  margin: 0 0 8px;
  font-size: 1.125rem;
  letter-spacing: 0.01em;
}
.card p {
  margin: 0;
  line-height: 1.4;
}

/* KPI specific */
.kpi {
  text-align: center;
  padding: 16px 12px;
}
.kpi .value {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 4px;
  line-height: 1;
}
.kpi .label {
  font-size: 12px;
  color: var(--muted);
}

/* Global KPI list (used by Economics, Finance, etc.) */
.kpi-list {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.75rem;
  margin: 0;
}
.kpi-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  transition: 0.2s;
}
.kpi-list li:hover {
  background: rgba(0, 0, 0, 0.3);
  border-color: rgba(0, 231, 255, 0.2);
  transform: translateY(-1px);
}
.kpi-list .label {
  color: rgba(255, 255, 255, 0.7);
}
.kpi-list .value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-width: 160px;
  text-align: right;
}

/* Hero */
.hero {
  padding: 92px 0 72px;
  border-bottom: 1px solid var(--border);
}
.hero h1 {
  margin: 0 0 10px;
  background: linear-gradient(
    135deg,
    var(--accent) 0%,
    var(--brand) 50%,
    var(--accent) 100%
  );
  background-size: 200% 200%;
  -webkit-background-clip: text;
  background-clip: text; /* compatibility */
  color: transparent;
  animation: neonTitleGlow 3s ease-in-out infinite alternate;
  position: relative;
}
.hero h1::before {
  content: "";
  position: absolute;
  inset: -2px;
  background: linear-gradient(
    45deg,
    transparent,
    rgba(0, 231, 255, 0.1),
    transparent
  );
  border-radius: 4px;
  animation: titlePulseGlow 4s ease-in-out infinite;
}
.hero p {
  color: var(--muted);
  margin: 0 0 20px;
}
.hero-actions {
  display: flex;
  gap: 12px;
}

/* Navigation (cyber) */
.cyber-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 14, 18, 0.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 1px rgba(0, 231, 255, 0.08);
  transition: 0.3s;
}
.cyber-header.scrolled {
  background: rgba(10, 14, 18, 0.9);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 231, 255, 0.06);
}
.cyber-nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
  padding: 0 1.5rem;
}
.cyber-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  font-weight: 700;
  color: var(--text);
  padding: 0.75rem;
  border-radius: 8px;
  transition: 0.2s;
}
.cyber-logo:hover {
  background: rgba(0, 0, 0, 0.25);
  transform: translateY(-1px);
}
.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 4px;
  border: 1px solid rgba(34, 197, 94, 0.2);
}
.logo-svg {
  width: 100%;
  height: 100%;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  filter: drop-shadow(0 0 10px rgba(34, 197, 94, 0.5)) drop-shadow(0 0 20px rgba(56, 189, 248, 0.3));
  transition: all 0.3s ease;
}
.cyber-logo:hover .logo-icon {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(34, 197, 94, 0.4);
}
.cyber-logo:hover .logo-svg {
  filter: drop-shadow(0 0 15px rgba(34, 197, 94, 0.8)) drop-shadow(0 0 25px rgba(56, 189, 248, 0.5));
  transform: scale(1.1);
}
.logo-text {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 4px;
  line-height: 1;
  font-size: 14px;
  white-space: nowrap;
}
.brand-primary {
  color: var(--accent);
}
.brand-secondary {
  color: var(--brand);
}
.system-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
  animation: pulse 2s infinite;
  box-shadow: 0 0 8px rgba(0, 255, 209, 0.5);
}
.cyber-nav {
  display: flex;
}
.nav-links {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 0.5rem;
}
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-weight: 600;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  transition: 0.2s;
  /* Reset native button styles when .nav-link is used on <button> */
  background: transparent;
  border: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
  line-height: inherit;
  font-size: 14px;
}
.nav-link .link-icon {
  font-size: 0.9em;
  opacity: 0.85;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
}
.nav-link .link-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}
.nav-link .link-text {
  font-size: inherit;
  letter-spacing: 0.06em;
}
.nav-link:focus-visible {
  outline: 2px solid rgba(0, 231, 255, 0.5);
  outline-offset: 2px;
}
.nav-link::after {
  content: "";
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: 0.5rem;
  height: 2px;
  background: var(--accent);
  opacity: 0;
  transform: scaleX(0);
  transform-origin: left;
  transition: 0.2s;
  box-shadow: 0 0 8px rgba(0, 231, 255, 0.3);
}
.nav-link:hover {
  color: #fff;
  background: rgba(0, 0, 0, 0.25);
}
.nav-link:hover::after,
.nav-link.active::after {
  opacity: 1;
  transform: scaleX(1);
}
.cta-link {
  background: var(--brand);
  color: #08111d;
  font-weight: 700;
  border-radius: 8px;
  box-shadow: 0 0 16px rgba(0, 255, 209, 0.25);
}
.cta-link:hover {
  background: var(--brand-700);
}
.cyber-menu-toggle {
  display: none;
  /* improved tap target and visuals */
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease,
    transform 0.15s ease;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  z-index: 120; /* above overlay */
  flex-direction: column; /* stack hamburger lines */
  gap: 5px; /* modern browsers */
}
.cyber-menu-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(0, 231, 255, 0.25);
}
.cyber-menu-toggle:active {
  transform: translateY(1px);
}
.cyber-menu-toggle:focus-visible {
  outline: 2px solid rgba(0, 231, 255, 0.6);
  outline-offset: 2px;
}
.cyber-menu-toggle .toggle-line {
  height: 2px;
  width: 22px;
  background: #c2d1df;
  border-radius: 2px;
  transition: transform 0.22s ease, opacity 0.18s ease, width 0.18s ease,
    background 0.2s ease;
  display: block; /* ensure width/height apply on spans */
  transform-origin: center; /* smoother rotation */
}
/* Fallback gap for older browsers without flex gap */
.cyber-menu-toggle .toggle-line + .toggle-line {
  margin-top: 5px;
}
.cyber-menu-toggle.active .toggle-line {
  background: var(--accent);
}
.cyber-menu-toggle.active .toggle-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.cyber-menu-toggle.active .toggle-line:nth-child(2) {
  opacity: 0;
  width: 0;
}
.cyber-menu-toggle.active .toggle-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Prevent background scroll when mobile nav is open */
body.no-scroll {
  overflow: hidden;
}

@media (max-width: 768px) {
  .cyber-nav {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    background: rgba(10, 14, 18, 0.94);
    backdrop-filter: blur(20px);
    transform: translateY(-100%);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    z-index: 110; /* above overlay */
  }
  .cyber-nav.open {
    transform: translateY(0);
    opacity: 1;
  }
  .nav-links {
    flex-direction: column;
    gap: 0.25rem;
    padding: 1.25rem 1rem;
  }
  .nav-link {
    width: 100%;
    justify-content: flex-start;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }
  .cyber-menu-toggle {
    display: flex;
  }
  .system-status {
    display: none;
  }
}

/* Mobile overlay for cyber nav (replaces legacy styles) */
.cyber-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 90;
}
.cyber-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

/* Animated border line under header */
.cyber-border {
  position: relative;
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.cyber-border .border-glow {
  position: absolute;
  top: -1px;
  left: -20%;
  width: 40%;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  filter: drop-shadow(0 0 8px rgba(0, 231, 255, 0.4));
  animation: borderSweep 5s linear infinite;
}
@keyframes borderSweep {
  0% {
    left: -40%;
  }
  50% {
    left: 60%;
  }
  100% {
    left: 120%;
  }
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: separate;
  border: 1px solid #1f2a3a;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.03);
  box-shadow: var(--shadow-soft);
}
.data-table th,
.data-table td {
  padding: 1rem 1.25rem;
  text-align: left;
  font-size: 14px;
  border-bottom: 1px solid #1f2a3a;
}
.data-table thead th {
  background: rgba(0, 0, 0, 0.2);
  color: #cbd5e1;
  font-weight: 600;
}
.data-table tbody tr:hover {
  background: rgba(12, 19, 33, 0.6);
}

/* Inputs */
input[type="number"],
input[type="text"],
select {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 0.75rem;
  color: var(--text);
  font-size: 1rem;
  transition: 0.2s;
}
input:focus,
select:focus {
  outline: none;
  border-color: rgba(0, 231, 255, 0.5);
  background: rgba(0, 0, 0, 0.3);
}

/* Accordion */
.accordion .q {
  width: 100%;
  text-align: left;
  background: none;
  color: var(--text);
  border: none;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.accordion .a {
  display: none;
  padding: 0 16px 16px;
  color: var(--muted);
}
.accordion .item.open .a {
  display: block;
}

/* Utility spacing fixes */
.section > *:first-child {
  margin-top: 0;
}
.section > *:last-child {
  margin-bottom: 0;
}

/* Charts (shared) */
.chart-wrap {
  position: relative;
}
.chart-wrap canvas {
  width: 100%;
  height: 220px;
  display: block;
}
.chart-legend {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
/* Default colors; features can override for specific contexts */
.dot.up {
  background: var(--accent);
}
.dot.down {
  background: var(--brand);
}
.dot.spread {
  background: #a78bfa;
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(6, 8, 12, 0.98);
  color: var(--text);
  border: 1px solid #1f2a3a;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  transform: translate(-50%, -120%);
}
.chart-tooltip.hidden {
  display: none;
}

/* Inputs helpers */
.inputs.hidden {
  display: none;
}
.inputs label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

/* Data-table action buttons */
.data-table .apply {
  padding: 6px 10px;
  border: 1px solid #1f2a3a;
  border-radius: 6px;
  background: #0c1321;
  color: #e6edf3;
}
.data-table .apply:hover {
  background: #112236;
}

/* Glitch title effect (reusable) */
.glitch {
  position: relative;
  display: inline-block;
}
.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  color: var(--accent);
  opacity: 0.35;
}
.glitch::before {
  filter: blur(0.5px);
  transform: translate(1px, 0);
}
.glitch::after {
  color: var(--brand);
  filter: blur(0.5px);
  transform: translate(-1px, 0);
}

/* Contact form layout & inputs */
.contact-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}
.contact-form input[type="text"],
.contact-form input[type="email"],
.contact-form textarea {
  width: 100%;
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
}
.contact-form textarea {
  min-height: 120px;
  resize: vertical;
}
.contact-form .actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.honeypot {
  position: absolute;
  left: -9999px;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* Contact section enhancements */
.contact-layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  align-items: start;
  gap: 2.5rem;
  margin-top: 2rem;
}
.contact-info {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.contact-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
}
.contact-highlights {
  display: grid;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.contact-highlights li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.75rem 0.9rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}
.contact-highlight-label {
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.contact-highlight-value {
  font-weight: 600;
  text-align: right;
  display: inline-flex;
  gap: 0.2rem;
}
.contact-channel {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 1rem;
}
.contact-channel:last-child {
  margin-bottom: 0;
}
.channel-label {
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.contact-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.5rem;
}
.contact-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}
.contact-form-grid .full {
  grid-column: 1 / -1;
}
.contact-consent {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.contact-consent input[type="checkbox"] {
  margin: 0;
}

/* Quick question buttons */
.quick-question-btn {
  padding: 0.6rem 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  text-align: left;
}
.quick-question-btn:hover {
  border-color: rgba(0, 231, 255, 0.3);
  background: rgba(0, 0, 0, 0.3);
}

/* 3D Battery Visualization Styles */
.battery-3d-container {
  width: 100%;
  height: min(70vh, 680px);
  min-height: 320px;
  margin: 2rem auto;
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  background: radial-gradient(
      ellipse at center,
      rgba(14, 165, 233, 0.08) 0%,
      rgba(14, 165, 233, 0.02) 35%,
      rgba(0, 0, 0, 0) 70%
    ),
    linear-gradient(135deg, #0a0f1c 0%, #09131c 100%);
  border: 1px solid #203040;
  display: grid;
  place-items: center;
  box-shadow: 0 16px 60px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.battery-3d-container::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(
      circle at 30% 30%,
      rgba(0, 255, 221, 0.08) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 70% 70%,
      rgba(0, 136, 255, 0.08) 0%,
      transparent 50%
    );
  pointer-events: none;
  z-index: 1;
}

.battery-3d-container canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  border-radius: 12px;
  position: relative;
  z-index: 2;
}

/* If any legacy CSS battery markup sneaks in, hide it when WebGL renderer is active */
.battery-3d-container[data-renderer] .battery-3d { display: none !important; }

/* Loading state styling */
.battery-3d-container > div {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  background: rgba(10, 15, 28, 0.9);
  border-radius: 12px;
}

/* Loading state for 3D battery */
.battery-3d-container:not([data-renderer]) {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
}

.battery-3d-container:not([data-renderer])::after {
  content: "Loading 3D Battery Visualization...";
  animation: pulse 2s infinite;
}

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

/* Cybertruck-style loading indicator */
.battery-3d-container[data-renderer="loading"] {
  background: linear-gradient(45deg, #0f172a, #1e293b);
  border: 2px solid #00ffdd;
  animation: cyberGlow 2s infinite;
}

@keyframes cyberGlow {
  0%,
  100% {
    border-color: #00ffdd;
    box-shadow: 0 0 20px rgba(0, 255, 221, 0.3);
  }
  50% {
    border-color: #00aaff;
    box-shadow: 0 0 30px rgba(0, 170, 255, 0.5);
  }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .battery-3d-container {
    height: 300px;
    margin: 1.5rem auto;
  }
}

@media (max-width: 480px) {
  .battery-3d-container {
    height: 250px;
    margin: 1rem auto;
  }
}
