/* ============================================================
   WijiBoard — Reusable Component Styles
   web/styles/components.css
   Requires: base.css
   ============================================================ */

/* ══════════════════════════════════════════════════════════════
   APP SHELL — Top bar + Sidebar + Layout
   ══════════════════════════════════════════════════════════════ */

.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* ── Top bar ─────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-height);
  background: rgba(13, 15, 20, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 14px;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(255,255,255,0.03);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  flex: 1;
}

.topbar-brand .brand-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1a2a4a, #0f1c38);
  border: 1px solid rgba(68,138,255,0.3);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(68,138,255,0.25);
}

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

/* ── Hamburger button ────────────────────────────────────────── */
.hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 36px; height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  flex-shrink: 0;
}
.hamburger:hover { background: var(--surface-2); }
.hamburger-bar {
  width: 18px; height: 2px;
  background: var(--text-secondary);
  border-radius: 2px;
  transition: transform var(--transition), opacity var(--transition);
}
.hamburger.open .hamburger-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open .hamburger-bar:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.open .hamburger-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 10px;
  gap: 4px;
  z-index: 90;
  transform: translateX(0);
  transition: transform var(--transition-slow);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar.collapsed {
  transform: translateX(calc(-1 * var(--sidebar-width)));
}

/* Sidebar overlay (mobile / collapsed state backdrop) */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 89;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-slow);
}
.sidebar-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Sidebar nav section label */
.sidebar-section-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 12px 10px 6px;
}

/* Sidebar nav item */
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  text-align: left;
  text-decoration: none;
}
.sidebar-nav-item:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}
.sidebar-nav-item.active {
  background: rgba(68,138,255,0.12);
  color: var(--accent-blue);
  border: 1px solid rgba(68,138,255,0.2);
}
.sidebar-nav-item .nav-icon {
  width: 18px; height: 18px;
  opacity: 0.7;
  flex-shrink: 0;
}
.sidebar-nav-item.active .nav-icon { opacity: 1; }

/* ── Main content area ───────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  flex: 1;
  height: calc(100vh - var(--topbar-height));
  overflow-y: auto;
  padding: var(--content-padding);
  transition: margin-left var(--transition-slow);
}
.main-content.sidebar-collapsed {
  margin-left: 0;
}


/* ══════════════════════════════════════════════════════════════
   BLE STATUS (top bar)
   ══════════════════════════════════════════════════════════════ */

.ble-status {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 5px 12px 5px 8px;
  transition: border-color var(--transition);
}
.ble-status.connected {
  border-color: rgba(0, 230, 118, 0.3);
  background: rgba(0, 230, 118, 0.07);
}

.ble-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background var(--transition), box-shadow var(--transition);
}
.ble-status.connected .ble-dot {
  background: var(--accent-green);
  box-shadow: 0 0 8px rgba(0,230,118,0.7);
  animation: pulse 2s ease-in-out infinite;
}

.ble-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: color var(--transition);
  white-space: nowrap;
}
.ble-status.connected .ble-label { color: var(--accent-green); }


/* ══════════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: transform var(--transition), box-shadow var(--transition),
              background var(--transition), border-color var(--transition),
              opacity var(--transition);
  position: relative;
  overflow: hidden;
  user-select: none;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.07);
  opacity: 0;
  transition: opacity var(--transition);
}
.btn:hover:not(:disabled)::after { opacity: 1; }
.btn:active:not(:disabled) { transform: scale(0.96); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* Variants */
.btn-primary {
  background: linear-gradient(135deg, #2a3f80, #1a2a5e);
  color: #fff;
  border-color: rgba(68,138,255,0.4);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: var(--glow-blue);
  border-color: var(--accent-blue);
}

.btn-success {
  background: linear-gradient(135deg, #0a3322, #052212);
  color: var(--accent-green);
  border-color: rgba(0,230,118,0.3);
}
.btn-success:hover:not(:disabled) {
  box-shadow: var(--glow-green);
  border-color: var(--accent-green);
}

.btn-danger {
  background: linear-gradient(135deg, #3a1a1a, #2a1010);
  color: #ffb3b3;
  border-color: rgba(255,82,82,0.3);
}
.btn-danger:hover:not(:disabled) {
  box-shadow: var(--glow-red);
  border-color: var(--accent-red);
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) {
  border-color: var(--border-hover);
  background: var(--surface-3);
}

.btn-icon-only {
  padding: 9px;
  min-width: 38px;
}

/* Size variants */
.btn-sm  { padding: 6px 12px; font-size: 0.78rem; border-radius: var(--radius-sm); }
.btn-lg  { padding: 13px 22px; font-size: 0.95rem; }
.btn-full { width: 100%; }

/* Loading state */
.btn.loading .btn-text  { opacity: 0; }
.btn.loading .spinner   { position: absolute; }


/* ══════════════════════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════════════════════ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35),
              inset 0 1px 0 rgba(255,255,255,0.04);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 10px;
}
.card-title {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
}
.card-title-accent {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}


/* ══════════════════════════════════════════════════════════════
   STATUS ROW / PILL
   ══════════════════════════════════════════════════════════════ */

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  gap: 10px;
}
.status-label {
  font-size: 0.73rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
}
.status-value {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}


/* ══════════════════════════════════════════════════════════════
   LOG CONSOLE
   ══════════════════════════════════════════════════════════════ */

.log-console {
  background: #07090d;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  height: 140px;
  overflow-y: auto;
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Courier New', monospace;
  font-size: 0.72rem;
  line-height: 1.75;
}
.log-entry { display: block; }
.log-entry.info    { color: #6a7a9a; }
.log-entry.success { color: var(--accent-green); }
.log-entry.error   { color: var(--accent-red); }
.log-entry.warn    { color: var(--accent-amber); }
.log-entry.sent    { color: #7eb8f7; }

.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.log-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
}
.log-clear-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.70rem;
  font-family: inherit;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color var(--transition), background var(--transition);
}
.log-clear-btn:hover { color: var(--text-primary); background: rgba(255,255,255,0.06); }


/* ══════════════════════════════════════════════════════════════
   FORM CONTROLS (input, range, number)
   ══════════════════════════════════════════════════════════════ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-label {
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.form-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.875rem;
  padding: 8px 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-input:focus {
  border-color: rgba(68,138,255,0.5);
  box-shadow: 0 0 0 3px rgba(68,138,255,0.12);
}
.form-input[type="number"] { width: 80px; text-align: center; }

/* Range slider */
.form-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent-blue);
  box-shadow: 0 0 8px rgba(68,138,255,0.5);
  transition: box-shadow var(--transition);
  cursor: pointer;
}
.form-range::-webkit-slider-thumb:hover {
  box-shadow: var(--glow-blue);
}
.form-range::-moz-range-thumb {
  width: 16px; height: 16px;
  border: none;
  border-radius: 50%;
  background: var(--accent-blue);
  cursor: pointer;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.range-value {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 36px;
  text-align: right;
}


/* ══════════════════════════════════════════════════════════════
   STEPPER JOG PANEL
   ══════════════════════════════════════════════════════════════ */

.stepper-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.stepper-card:hover {
  border-color: rgba(68,138,255,0.18);
}

.stepper-pos-display {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.stepper-pos-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  text-align: center;
}
.stepper-pos-num {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-blue);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.stepper-pos-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: 2px;
}

.jog-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.jog-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.jog-row .btn {
  flex: 1;
}
.step-input-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
}
.step-input-wrapper label {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}


/* ══════════════════════════════════════════════════════════════
   SCARA VISUALIZER
   ══════════════════════════════════════════════════════════════ */

.visualizer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px;
  gap: 10px;
}

.scara-svg {
  width: 100%;
  max-width: 340px;
  border-radius: var(--radius-md);
  background: #070a0f;
  border: 1px solid var(--border);
}

/* SVG internal elements */
.arm-seg-1  { stroke: var(--accent-blue); stroke-width: 5; stroke-linecap: round; }
.arm-seg-2  { stroke: #7eb8f7; stroke-width: 4; stroke-linecap: round; }
.joint-base { fill: var(--accent-blue); }
.joint-elbow{ fill: #a0c4ff; }
.end-eff    { fill: var(--accent-green); }
.workspace-arc { stroke: rgba(68,138,255,0.12); stroke-width: 1; fill: none; }
.grid-line  { stroke: rgba(255,255,255,0.04); stroke-width: 1; }
.crosshair  { stroke: rgba(0,230,118,0.35); stroke-width: 1; }


/* ══════════════════════════════════════════════════════════════
   SECTION WRAPPERS
   ══════════════════════════════════════════════════════════════ */

.section-page {
  max-width: 1100px;
  margin: 0 auto;
  animation: fadeIn 0.25s var(--transition) both;
}

.section-header {
  margin-bottom: 24px;
}
.section-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}
.section-header p {
  margin-top: 4px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* Responsive */
@media (max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .main-content { padding: 16px; }
  .sidebar { width: 220px; }
  :root { --sidebar-width: 220px; }
}

/* Divider */
.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}
