/* ==========================================================================
   Button Box Phone - Technical Blueprint Stylesheet
   Theme: Pristine Architectural White / Clean Industrial CAD Blueprint
   ========================================================================== */

:root {
  --bg-blueprint: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --border-color: #e2e8f0;
  --border-darker: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  
  --accent-cyan: #0ea5e9;
  --accent-cyan-hover: #0284c7;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --accent-purple: #8b5cf6;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-blueprint);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* --------------------------------------------------------------------------
   Technical Blueprint Grid Background Overlay
   -------------------------------------------------------------------------- */
.blueprint-grid-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background-size: 24px 24px, 120px 120px;
  background-image: 
    linear-gradient(to right, rgba(226, 232, 240, 0.6) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(226, 232, 240, 0.6) 1px, transparent 1px),
    linear-gradient(to right, rgba(203, 213, 225, 0.8) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(203, 213, 225, 0.8) 1px, transparent 1px);
  z-index: 1;
}

/* --------------------------------------------------------------------------
   Header / CAD Title Block
   -------------------------------------------------------------------------- */
.blueprint-header {
  position: relative;
  z-index: 10;
  height: 64px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: var(--shadow-sm);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: #f8fafc;
  border: 1px solid var(--border-darker);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-cyan);
}

.brand-title-group h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-title-group p {
  font-size: 0.73rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.cad-badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Main Workspace Layout: Viewport + Blueprint Sidebar
   -------------------------------------------------------------------------- */
.blueprint-layout {
  position: relative;
  flex: 1;
  display: flex;
  overflow: hidden;
  z-index: 5;
}

/* 3D Viewport */
.viewport-wrapper {
  position: relative;
  flex: 1;
  height: 100%;
  overflow: hidden;
}

#viewport-container {
  width: 100%;
  height: 100%;
  outline: none;
}

/* Floating View Switcher Bar */
.viewport-header-bar {
  position: absolute;
  top: 16px;
  left: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  padding: 4px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

.view-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.view-tab-btn:hover {
  color: var(--text-main);
  background: rgba(241, 245, 249, 0.7);
}

.view-tab-btn.active {
  background: var(--text-main);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

/* Floating Toolbar Bottom */
.viewport-floating-toolbar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  padding: 8px 14px;
  border: 1px solid var(--border-color);
  border-radius: 40px;
  box-shadow: var(--shadow-md);
  z-index: 10;
}

.btn-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.btn-pill:hover {
  background: #f1f5f9;
  border-color: var(--border-darker);
}

.btn-pill.primary {
  background: var(--accent-cyan);
  color: #ffffff;
  border-color: var(--accent-cyan);
}

.btn-pill.primary:hover {
  background: var(--accent-cyan-hover);
}

.btn-pill.active {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
}

.toolbar-separator {
  width: 1px;
  height: 20px;
  background: var(--border-color);
}

/* Context info pill, bottom left, stacked above the floating toolbar (not under it) */
.context-info-pill {
  position: absolute;
  bottom: 88px;
  left: 20px;
  max-width: min(400px, calc(100% - 40px));
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

.context-info-pill strong {
  color: var(--text-main);
}

/* --------------------------------------------------------------------------
   Blueprint Documentation Sidebar (Right)
   -------------------------------------------------------------------------- */
.blueprint-sidebar {
  width: 480px;
  height: 100%;
  background: #ffffff;
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 20;
  box-shadow: var(--shadow-sm);
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: #f8fafc;
  overflow-x: auto;
}

.sidebar-tab-btn {
  flex: 1;
  padding: 12px 10px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.sidebar-tab-btn:hover {
  color: var(--text-main);
  background: #ffffff;
}

.sidebar-tab-btn.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
  background: #ffffff;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.tab-pane {
  display: none;
}

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

/* Typography in Sidebar */
.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.45;
}

/* Blueprint Card */
.blueprint-card {
  background: var(--bg-blueprint);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

.blueprint-card h4 {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.blueprint-card p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Technical Metric Callout */
.metric-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}

.metric-item {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.metric-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 4px;
}

.metric-value.highlight-green {
  color: var(--accent-green);
}

.metric-value.highlight-cyan {
  color: var(--accent-cyan);
}

/* BOM Table */
.bom-table-wrapper {
  overflow-x: auto;
  margin-top: 12px;
}

.bom-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.bom-table th {
  text-align: left;
  padding: 8px 10px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-muted);
}

.bom-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.btn-locate {
  padding: 4px 8px;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--accent-cyan);
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-locate:hover {
  background: #f0f9ff;
  border-color: var(--accent-cyan);
}

/* Pinout Matrix */
.pinout-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.pin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.76rem;
}

.pin-tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: bold;
}

.pin-tag.vcc { background: #fee2e2; color: #dc2626; }
.pin-tag.gnd { background: #f1f5f9; color: #334155; }
.pin-tag.spk { background: #e0f2fe; color: #0284c7; }
.pin-tag.trigger { background: #dcfce7; color: #15803d; }

/* Plain bullet list inside cards */
.plain-list {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  padding-left: 18px;
}

code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0 4px;
}

/* Plan Execution Checklist */
.progress-container {
  margin-bottom: 20px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-bottom: 6px;
}

.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent-cyan);
  width: 0%;
  transition: width 0.3s ease;
}

.phase-accordion {
  margin-bottom: 16px;
}

.phase-header {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 10px 12px;
  background: #f1f5f9;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.checklist-items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-left: 4px;
}

.checklist-items li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-main);
  line-height: 1.4;
}

.checklist-items input[type="checkbox"] {
  margin-top: 3px;
  accent-color: var(--accent-cyan);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Soundboard Test Console */
.sound-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.sound-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: all 0.25s ease;
}

.sound-card.playing {
  border-color: var(--accent-cyan);
  background: #f0f9ff;
  box-shadow: 0 0 10px rgba(14, 165, 233, 0.2);
}

.sound-card-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.key-badge {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid;
}

/* Key badges use the same color as the 3D key and its wire (--key-color set inline) */
.key-badge {
  border-color: var(--key-color, var(--border-darker));
  color: var(--text-main);
  background: color-mix(in srgb, var(--key-color, #ffffff) 10%, #ffffff);
}

.key-badge.small {
  width: 26px;
  height: 26px;
  font-size: 0.8rem;
  border-radius: 6px;
}

.pin-table td {
  font-family: var(--font-mono);
}

.sound-info h5 {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
}

.sound-info p {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.sound-card-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-sound-play {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-cyan);
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s;
}

.btn-sound-play:hover {
  transform: scale(1.08);
}

.btn-upload-label {
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px;
  border-radius: 4px;
  transition: background 0.2s;
}

.btn-upload-label:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

/* Toast Notification */
#blueprint-toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: #0f172a;
  color: #ffffff;
  padding: 10px 22px;
  border-radius: 30px;
  font-size: 0.82rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1000;
}

#blueprint-toast.toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Responsive */
@media (max-width: 1024px) {
  .blueprint-sidebar {
    width: 380px;
  }
}

@media (max-width: 768px) {
  .blueprint-layout {
    flex-direction: column;
  }
  .blueprint-sidebar {
    width: 100%;
    height: 45%;
  }
}

/* Phones: keep header, view switcher and toolbar inside the viewport width */
@media (max-width: 480px) {
  .blueprint-header {
    height: auto;
    min-height: 64px;
    padding: 8px 12px;
  }
  .brand-section {
    gap: 10px;
    min-width: 0;
  }
  .brand-icon {
    flex-shrink: 0;
  }
  .brand-title-group h1 {
    font-size: 1rem;
    flex-wrap: wrap;
    row-gap: 2px;
  }
  .brand-title-group p {
    font-size: 0.66rem;
  }
  .viewport-header-bar {
    top: 10px;
    left: 8px;
    right: 8px;
    gap: 2px;
    overflow-x: auto;
  }
  .view-tab-btn svg {
    display: none;
  }
  .view-tab-btn {
    flex: 1 0 auto;
    justify-content: center;
    padding: 7px 8px;
    font-size: 0.72rem;
    white-space: nowrap;
  }
  .viewport-floating-toolbar {
    bottom: 10px;
    gap: 6px;
    padding: 6px 8px;
    max-width: calc(100% - 16px);
  }
  .viewport-floating-toolbar .btn-pill {
    padding: 6px 10px;
    font-size: 0.74rem;
    gap: 6px;
  }
  .viewport-floating-toolbar input[type="range"] {
    width: 56px !important;
  }
  .context-info-pill {
    bottom: 62px;
    left: 8px;
    max-width: calc(100% - 16px);
    padding: 6px 10px;
    font-size: 0.7rem;
  }
}
