/* ==========================================================================
   SchemCAD — Auto-Paired BoardView + PDF Schematic 50/50 Split-Sync & BIOS Bar
   File: frontend/split_sync.css
   Mounts inline inside .canvas-boardbar with zero layout overflow + fixed portal popover
   ========================================================================== */

#splitSyncBar,
.split-sync-bar {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  user-select: none;
}

#splitSyncBar::-webkit-scrollbar,
.split-sync-bar::-webkit-scrollbar {
  display: none;
}

#splitSyncBar.hidden,
.split-sync-bar.hidden,
#splitSyncPopover.hidden,
.ss-popover.hidden,
.ss-hidden {
  display: none !important;
}

/* Split PDF 50/50 Button + Revision Caret Group */
.ss-pdf-group {
  display: inline-flex;
  align-items: stretch;
  height: 24px;
  border-radius: 6px;
  border: 1px solid rgba(44, 165, 104, 0.65);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.22) 0%, rgba(59, 130, 246, 0.22) 100%);
  box-shadow: 0 0 10px rgba(44, 165, 104, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  overflow: hidden;
  flex-shrink: 0;
  transition: border-color 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

.ss-pdf-group:hover {
  border-color: rgba(52, 211, 153, 0.92);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.30) 0%, rgba(59, 130, 246, 0.30) 100%);
  box-shadow: 0 0 14px rgba(44, 165, 104, 0.30), 0 0 8px rgba(59, 130, 246, 0.22);
}

.ss-pdf-group.is-open {
  border-color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.ss-pdf-main-btn,
.ss-pdf-caret-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: #ecfdf5;
  font-family: var(--sans, "Inter", system-ui, sans-serif);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
  padding: 0 8px;
  transition: background 0.12s ease, color 0.12s ease;
}

.ss-pdf-main-btn:hover,
.ss-pdf-caret-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
}

.ss-pdf-main-btn:active,
.ss-pdf-caret-btn:active {
  background: rgba(255, 255, 255, 0.12);
}

.ss-pdf-caret-btn {
  padding: 0 5px;
  border-left: 1px solid rgba(52, 211, 153, 0.36);
  font-size: 10px;
  color: #a7f3d0;
}

.ss-pdf-caret-btn[aria-expanded="true"] {
  background: rgba(56, 189, 248, 0.22);
  color: #ffffff;
}

/* Auto-Sync PDF Toggle Pill */
.ss-autosync-btn {
  appearance: none;
  height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid #2b374b;
  background: #141b27;
  color: #9aa6b8;
  font-family: var(--sans, "Inter", system-ui, sans-serif);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
}

.ss-autosync-btn:hover {
  background: #1c2536;
  border-color: #3d4f6b;
  color: #e2e8f0;
}

.ss-autosync-btn.active,
.ss-autosync-btn[aria-pressed="true"] {
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.24) 0%, rgba(16, 185, 129, 0.16) 100%);
  border-color: rgba(59, 130, 246, 0.72);
  color: #e0f2fe;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.20);
}

.ss-sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #475569;
  flex-shrink: 0;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.ss-autosync-btn.active .ss-sync-dot,
.ss-autosync-btn[aria-pressed="true"] .ss-sync-dot {
  background: #34d399;
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.85);
}

/* Compact Gold BIOS Pill */
.ss-bios-btn {
  appearance: none;
  height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid rgba(220, 160, 58, 0.58);
  background: linear-gradient(180deg, rgba(220, 160, 58, 0.24) 0%, rgba(220, 160, 58, 0.10) 100%);
  color: #fde68a;
  font-family: var(--sans, "Inter", system-ui, sans-serif);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 0 8px rgba(220, 160, 58, 0.14);
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
}

.ss-bios-btn:hover,
.ss-bios-btn[aria-expanded="true"] {
  background: linear-gradient(180deg, rgba(220, 160, 58, 0.34) 0%, rgba(220, 160, 58, 0.16) 100%);
  border-color: rgba(245, 184, 75, 0.88);
  color: #fffbeb;
  box-shadow: 0 0 12px rgba(220, 160, 58, 0.28);
}

/* Fixed Portal Mini Popover (PDF Revisions & BIOS .BIN Dumps) */
.ss-popover {
  position: fixed;
  z-index: 2450;
  width: min(420px, calc(100vw - 16px));
  max-height: min(380px, calc(100vh - 72px));
  background: #121722;
  border: 1px solid #2e3b50;
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.72), 0 0 0 1px rgba(255, 255, 255, 0.03);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--text, #e8edf5);
  font-family: var(--sans, "Inter", system-ui, sans-serif);
}

.ss-popover--bios {
  border-color: rgba(220, 160, 58, 0.45);
}

.ss-popover--pdf {
  border-color: rgba(44, 165, 104, 0.48);
}

.ss-pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: #171e2c;
  border-bottom: 1px solid #253043;
  flex-shrink: 0;
}

.ss-pop-head-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ss-pop-title {
  font-size: 12px;
  font-weight: 700;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ss-pop-sub {
  font-size: 10.5px;
  color: #8b9ab0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ss-pop-close {
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: 1px solid transparent;
  background: transparent;
  color: #94a3b8;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ss-pop-close:hover {
  background: #232d3f;
  border-color: #36445c;
  color: #f8fafc;
}

.ss-pop-list {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  min-height: 0;
  padding: 4px;
  gap: 3px;
}

.ss-pop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.015);
  transition: background 0.12s ease, border-color 0.12s ease;
}

.ss-pop-row:hover {
  background: #1b2333;
  border-color: #2d3a50;
}

.ss-pop-row.is-selected {
  background: rgba(16, 185, 129, 0.10);
  border-color: rgba(44, 165, 104, 0.45);
}

.ss-pop-row--clickable {
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-family: inherit;
  color: inherit;
}

.ss-pop-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1 1 auto;
}

.ss-pop-item-title {
  font-size: 11.5px;
  font-weight: 600;
  color: #e6edf6;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.ss-pop-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.ss-badge {
  font-family: var(--mono, "JetBrains Mono", monospace);
  font-size: 9.5px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid #2c384e;
  background: #141a25;
  color: #94a3b8;
  line-height: 1.35;
}

.ss-badge--pdf {
  border-color: rgba(44, 165, 104, 0.45);
  background: rgba(44, 165, 104, 0.14);
  color: #6ee7b7;
}

.ss-badge--bios {
  border-color: rgba(220, 160, 58, 0.48);
  background: rgba(220, 160, 58, 0.14);
  color: #fcd34d;
}

.ss-badge--plat {
  border-color: rgba(59, 130, 246, 0.42);
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
}

.ss-badge--ready {
  border-color: rgba(16, 185, 129, 0.40);
  background: rgba(16, 185, 129, 0.12);
  color: #a7f3d0;
}

/* 1-Click BIOS Download Anchor (intercepted cleanly by saas_client.js) */
.ss-bios-dl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 26px;
  padding: 0 9px;
  border-radius: 5px;
  border: 1px solid rgba(220, 160, 58, 0.62);
  background: linear-gradient(180deg, rgba(220, 160, 58, 0.24) 0%, rgba(220, 160, 58, 0.11) 100%);
  color: #fde68a;
  font-family: var(--sans, "Inter", system-ui, sans-serif);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.ss-bios-dl-btn:hover {
  background: linear-gradient(180deg, rgba(220, 160, 58, 0.38) 0%, rgba(220, 160, 58, 0.18) 100%);
  border-color: #f5b84b;
  color: #fffbeb;
}

.ss-pdf-open-chip {
  font-family: var(--mono, "JetBrains Mono", monospace);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 5px;
  border: 1px solid rgba(44, 165, 104, 0.50);
  background: rgba(44, 165, 104, 0.16);
  color: #a7f3d0;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Compact Desktop Breakpoint */
@media (max-width: 1200px) {
  .ss-autosync-btn .ss-autosync-label {
    max-width: 112px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* Mobile CAD Responsive Strip */
@media (max-width: 860px) {
  #splitSyncBar,
  .split-sync-bar {
    width: 100%;
    padding: 2px 0 0;
    gap: 5px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
  }

  .ss-pdf-group,
  .ss-autosync-btn,
  .ss-bios-btn {
    height: 26px;
  }

  .ss-popover {
    left: 8px !important;
    right: 8px !important;
    width: calc(100vw - 16px) !important;
  }
}
