/*
 * public/styles.css
 *
 * Faithful macOS Tahoe AppKit + GTK-Quartz visual system matching actual Bandicoot
 * (src/bandicoot_appkit.mm, src/c-interface-widgets.cc, src/nsv.cc, src/gtk2-interface.c).
 */

:root {
  --mac-window-bg: #ececec;
  --mac-toolbar-top: #f6f6f8;
  --mac-toolbar-bottom: #e2e2e6;
  --mac-menubar-bg: #f4f4f6;
  --mac-sidebar-bg: #e6e6e9;
  --mac-panel-bg: #f2f2f4;
  --mac-border: #bebec2;
  --mac-border-dark: #9c9ca2;
  --mac-text: #1d1d1f;
  --mac-text-secondary: #515156;
  --mac-text-disabled: #8e8e93;
  --mac-accent: #0066cc;
  --mac-accent-hover: #0055b3;
  --mac-bezel-bg: #ffffff;
  --mac-bezel-active: #d0d7e2;
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  --font-mono: "SF Mono", Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
  user-select: none;
}

::selection {
  background: rgba(0, 102, 204, 0.22);
  color: var(--mac-text);
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--mac-window-bg);
  color: var(--mac-text);
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

.bandicoot-window {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  background: var(--mac-window-bg);
}

/* ---- 1. macOS System Menu Bar + Window Title Strip ---- */
.mac-menubar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 25px;
  padding: 0 10px;
  background: var(--mac-menubar-bg);
  border-bottom: 1px solid #d2d2d7;
  flex-shrink: 0;
  z-index: 60;
}

.mac-menubar-left {
  display: flex;
  align-items: center;
  gap: 2px;
}

.mac-app-title {
  font-weight: 700;
  font-size: 12.5px;
  padding: 2px 8px 2px 4px;
  color: #000;
  letter-spacing: -0.01em;
}

.mac-menu-item {
  position: relative;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12.5px;
  font-weight: 400;
  color: var(--mac-text);
  cursor: default;
}

.mac-menu-item:hover,
.mac-menu-item.open {
  background: var(--mac-accent);
  color: #fff;
}

.mac-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  background: rgba(246, 246, 248, 0.98);
  border: 1px solid rgba(0, 0, 0, 0.22);
  border-radius: 6px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
  padding: 4px;
  z-index: 200;
  color: var(--mac-text);
}

.mac-menu-item.open .mac-dropdown {
  display: block;
}

.mac-dropdown-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 4px 10px;
  border: none;
  background: transparent;
  border-radius: 4px;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--mac-text);
  text-align: left;
  cursor: pointer;
}

.mac-dropdown-row:hover {
  background: var(--mac-accent);
  color: #fff;
}

.mac-dropdown-row:hover .mac-kbd {
  color: rgba(255, 255, 255, 0.85);
}

.mac-dropdown-sep {
  height: 1px;
  background: #d4d4d8;
  margin: 4px 6px;
}

.mac-kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--mac-text-secondary);
  margin-left: 16px;
}

.mac-window-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--mac-text-secondary);
  white-space: nowrap;
}

/* ---- 2. Expanded macOS NSToolbar (bandicoot_install_native_toolbar) ---- */
.ns-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 54px;
  padding: 3px 8px;
  background: linear-gradient(180deg, var(--mac-toolbar-top) 0%, var(--mac-toolbar-bottom) 100%);
  border-bottom: 1px solid #b4b4b9;
  flex-shrink: 0;
  overflow-x: auto;
  z-index: 40;
}

.ns-toolbar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 64px;
  height: 46px;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--mac-text);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 400;
  cursor: pointer;
  flex-shrink: 0;
}

.ns-toolbar-item:hover {
  background: rgba(0, 0, 0, 0.055);
  border-color: rgba(0, 0, 0, 0.1);
}

.ns-toolbar-item:active {
  background: rgba(0, 0, 0, 0.11);
}

/* Toggle items in BANDICOOT_EXTRAS use NSButtonTypePushOnPushOff bordered bezel */
.ns-toolbar-item.toggle-item .ns-icon-bezel {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 26px;
  border-radius: 4px;
  background: #fdfdfd;
  border: 1px solid #a8a8ae;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
}

.ns-toolbar-item.toggle-item.active .ns-icon-bezel {
  background: #cfd8e6;
  border-color: #5b7aa6;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

.ns-toolbar-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
}

.ns-toolbar-sep {
  width: 1px;
  height: 34px;
  background: #c5c5ca;
  margin: 0 4px;
  flex-shrink: 0;
}

.ns-toolbar-spacer {
  flex: 1;
}

/* ---- 3. Content Area: Left+Center Stack (SeqView + A/R Bar + GL Canvas) + Right Pinned Sidebar ---- */
.content-area {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
}

.canvas-column {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  position: relative;
}

/* ---- 3a. Docked Sequence View Strip (bandicoot_dock_sequence_view, src/nsv.cc) ---- */
.docked-sequence-view {
  display: flex;
  flex-direction: column;
  padding: 4px 8px 6px;
  background: var(--mac-window-bg);
  border-bottom: 1px solid #a6a6ac;
  flex-shrink: 0;
  z-index: 25;
}

.docked-sequence-view.hidden {
  display: none;
}

.nsv-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  min-height: 28px;
  background: #e4e4e7;
  border-bottom: 1px solid #cacace;
  font-size: 12px;
  color: var(--mac-text);
}

.nsv-mol-label {
  font-weight: 500;
}

.nsv-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.gtk-btn {
  height: 24px;
  padding: 2px 8px;
  background: linear-gradient(180deg, #ffffff 0%, #e9e9ec 100%);
  border: 1px solid #9e9ea4;
  border-radius: 3px;
  color: var(--mac-text);
  font-family: var(--font-ui);
  font-size: 12px;
  cursor: pointer;
}

.gtk-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #ffffff 0%, #dcdce2 100%);
  border-color: #7c7c84;
}

.gtk-btn:active:not(:disabled) {
  background: #d4d4da;
}

.gtk-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

/* White sequence canvas matching nsv.cc sequence_letter_background_colour = "white" */
.nsv-canvas-scroll {
  background: #ffffff;
  overflow-x: auto;
  overflow-y: auto;
  max-height: 64px;
  padding: 2px 6px;
}

.nsv-chain-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  min-height: 26px;
  border-bottom: 1px solid #efefef;
}

.nsv-chain-row:last-child {
  border-bottom: none;
}

.nsv-chain-id {
  position: sticky;
  left: 0;
  background: #ffffff;
  z-index: 2;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: #1d1d1f;
  min-width: 56px;
  padding: 0 6px 3px 4px;
  flex-shrink: 0;
}

.nsv-letters {
  display: flex;
  align-items: flex-end;
}

.nsv-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 14px;
  cursor: pointer;
  padding-bottom: 1px;
  border-radius: 2px;
}

.nsv-cell:hover {
  background: #dbeafe;
}

.nsv-cell.active {
  background: #fde047;
  outline: 1px solid #ca8a04;
}

.nsv-tick {
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: #6b7280;
  height: 10px;
  line-height: 10px;
  white-space: nowrap;
}

.nsv-letter {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 13px;
  color: #111827;
}

.nsv-cell.has-alt .nsv-letter {
  color: #b45309;
  text-decoration: underline;
}

.nsv-cell.rama-bad .nsv-letter {
  color: #dc2626;
}

/* ---- 3b. Docked Accept/Reject Bar (bandicoot_install_accept_reject_bar) ---- */
.docked-ar-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  padding: 3px 8px;
  background: var(--mac-window-bg);
  border-bottom: 1px solid #a6a6ac;
  flex-shrink: 0;
  z-index: 24;
}

.ar-lights-hbox {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 38px;
}

.ar-idle-hint {
  font-size: 12px;
  color: var(--mac-text-secondary);
  padding-left: 4px;
}

/* Exact 58x38 Cairo rectangle from bandicoot_ar_light_expose (bandicoot_appkit.mm:2575-2615) */
.ar-cairo-light {
  width: 58px;
  height: 38px;
  border: 1px solid #4d4d4d;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 3px 2px 2px;
  font-family: var(--font-ui);
  flex-shrink: 0;
}

.ar-cairo-light .light-name {
  font-size: 8.5px;
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 54px;
}

.ar-cairo-light .light-val {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.ar-buttons-box {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ar-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 12px;
  background: linear-gradient(180deg, #ffffff 0%, #e6e6ea 100%);
  border: 1px solid #94949a;
  border-radius: 4px;
  color: var(--mac-text);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.ar-action-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #ffffff 0%, #d8d8df 100%);
  border-color: #6e6e75;
}

.ar-action-btn:disabled {
  opacity: 0.42;
  cursor: default;
}

.ar-action-btn img {
  width: 14px;
  height: 14px;
}

/* ---- 3c. GL Viewport Canvas (with 1px white outline per bandicoot_appkit.mm:1555) ---- */
.gl-viewport-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #000000;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

#gl-canvas, #overlay-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#overlay-canvas {
  pointer-events: none;
}

/* ---- 4. Pinned Right Model/Fit/Refine Sidebar (bandicoot_sidebar_install) ---- */
.model-sidebar {
  width: 206px;
  background: var(--mac-sidebar-bg);
  border-left: 1px solid #a6a6ac;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 30;
}

.model-sidebar.icons-only {
  width: 48px;
}

.model-sidebar.icons-only .sidebar-btn-label {
  display: none;
}

.model-sidebar.icons-only .sidebar-top-pair {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 3px 2px;
}

.model-sidebar.icons-only .sidebar-top-pair .gtk-btn {
  font-size: 10px;
  padding: 2px 1px;
}

.model-sidebar.icons-only .sidebar-tool-btn {
  justify-content: center;
  padding: 3px 0;
}

.model-sidebar.text-only {
  width: 190px;
}

.model-sidebar.text-only .sidebar-btn-icon {
  display: none;
}

.sidebar-top-pair {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 4px 5px 3px;
}

.sidebar-top-pair .gtk-btn {
  width: 100%;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 6px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-scroll-items {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 4px;
}

.sidebar-tool-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 22px;
  padding: 1.5px 5px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--mac-text);
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: -0.1px;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s ease, border-color 0.1s ease;
}

.sidebar-tool-btn:hover {
  background: rgba(255, 255, 255, 0.75);
  border-color: #b4b4bc;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.sidebar-tool-btn:active,
.sidebar-tool-btn.active {
  background: #c5d0e2;
  border-color: #6d8dbf;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12);
}

.sidebar-btn-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-btn-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11px;
}

.sidebar-hsep {
  height: 1px;
  background: #c2c2c8;
  margin: 4px 4px;
  flex-shrink: 0;
}

/* Pinned bottom "⚙ Settings ▸" button from bandicoot_sidebar_pin_settings_item */
.sidebar-settings-footer {
  position: relative;
  border-top: 1px solid #bcbcc2;
  padding: 3px 4px;
  background: #dedee2;
}

.sidebar-settings-btn {
  width: 100%;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: linear-gradient(180deg, #fafafa 0%, #e4e4e8 100%);
  border: 1px solid #9e9ea4;
  border-radius: 3px;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--mac-text);
  cursor: pointer;
}

.sidebar-settings-popup {
  display: none;
  position: absolute;
  bottom: 26px;
  right: 100%;
  margin-right: 4px;
  min-width: 150px;
  background: #f6f6f8;
  border: 1px solid #9a9aa0;
  border-radius: 5px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
  padding: 4px;
  z-index: 100;
}

.sidebar-settings-popup.open {
  display: block;
}

/* ---- 5. Native Bottom Status Bar (bandicoot_install_status_bar) ---- */
.native-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 22px;
  padding: 0 10px;
  background: var(--mac-window-bg);
  border-top: 1px solid #b4b4b9;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--mac-text);
  flex-shrink: 0;
  z-index: 40;
}

.status-right {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--mac-text-secondary);
}

/* ---- 6. Floating Native Utility Windows (Display Manager, Go to Atom, Dialogs) ---- */
.floating-window {
  position: fixed;
  background: var(--mac-panel-bg);
  border: 1px solid #8e8e95;
  border-radius: 7px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.26);
  display: flex;
  flex-direction: column;
  z-index: 80;
  color: var(--mac-text);
  overflow: hidden;
}

.floating-window.hidden {
  display: none;
}

.fw-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 32px;
  padding: 6px 10px;
  background: linear-gradient(180deg, #f5f5f7 0%, #dedee3 100%);
  border-bottom: 1px solid #b0b0b6;
  font-size: 12px;
  font-weight: 600;
  cursor: move;
}

.fw-body {
  padding: 10px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gtk-frame {
  border: 1px solid #b8b8be;
  border-radius: 4px;
  padding: 8px 10px;
  background: #f8f8fa;
}

.gtk-frame-title {
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 6px;
  color: #111;
}

.dm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  font-size: 12px;
}

.dm-row input[type="range"] {
  accent-color: var(--mac-accent);
}

/* Exact Header Browser family washes from src/c-interface-widgets.cc:160-183 */
.hb-frame {
  border: 1px solid #b0b0b8;
  border-radius: 4px;
  margin-bottom: 6px;
  overflow: hidden;
}

.hb-frame-label {
  padding: 3px 8px;
  font-weight: 600;
  font-size: 11.5px;
  background: rgba(0, 0, 0, 0.04);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.hb-frame-pre {
  margin: 0;
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.45;
  color: #111;
  white-space: pre-wrap;
  user-select: text;
}

.hb-family-bibliography  { background: #fff8e3; }
.hb-family-entity        { background: #ffeef3; }
.hb-family-experiment    { background: #e4fde4; }
.hb-family-refinement    { background: #defbff; }
.hb-family-symmetry      { background: #f0ebff; }
.hb-family-annotation    { background: #eaf4f9; }
.hb-family-heterogeneity { background: #ffeac7; }
.hb-family-other         { background: #fafafa; }
