/* File: css/layout.css
   Purpose: App shell grid, header, content area, status bar.
*/

/* ── App Shell ── */
.app-shell {
  display: grid;
  grid-template-rows: 56px 1fr 32px;
  min-height: 100vh;
}

.app-body {
  display: block;
  height: calc(100vh - 88px);
  overflow: hidden;
}

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  gap: var(--space-4);
  z-index: var(--z-sticky);
}

.header__logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.header__logo img {
  height: 26px;
  width: auto;
}

/* ── Navigation ── */
.header__nav {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: var(--space-2);
}

.header__nav a {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: 0;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-decoration: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.header__nav a:hover {
  color: var(--text-primary);
  background: transparent;
  text-decoration: none;
}

.header__nav a.active {
  color: var(--text-primary);
  background: transparent;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

.header__nav a .nav-icon {
  width: 16px;
  height: 16px;
  opacity: 0.7;
}

.header__nav a.active .nav-icon { opacity: 1; }

/* ── Header Actions ── */
.header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

#logoutBtn {
  background: transparent;
  border: none;
}
#logoutBtn:hover {
  color: var(--text-primary);
  border: none;
}

/* ── Main Content ── */
.main {
  padding: 0;
  height: 100%;
  min-height: 0;
  overflow: auto;
}

/* ── Status Bar ── */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: var(--text-xs);
  user-select: none;
}

.status-bar__left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.status-bar__dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--text-muted);
}

.status-bar__dot.connected { background: var(--color-success); }
.status-bar__dot.disconnected { background: var(--color-danger); }

/* ── Page Layout Helpers ── */
.page-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
  padding: 0 var(--space-4);
}

.page-topbar:first-child {
  padding-top: var(--space-4);
}

.page-title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: 2px;
}

.page-topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Split layouts */
.page-split {
  display: grid;
  gap: var(--space-4);
  height: 100%;
  min-height: 0;
}

.page-split--pair-detail {
  grid-template-columns: 240px 1fr;
}

@media (max-width: 900px) {
  .page-split--pair-detail {
    grid-template-columns: 1fr;
  }
}

/* ── Floating pair list layout ─────────────────────────────────────── */
.page-layout--pair-detail {
  position: relative;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* Toggle button — fixed top-left corner */
.pair-float-toggle {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 102;
  width: 17px;
  height: 17px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  font-size: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.pair-float-toggle:hover {
  background: var(--bg-surface-2);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.pair-float-toggle.active {
  opacity: 0;
  pointer-events: none;
}

/* Floating panel — overlays content, does NOT push layout */
.pair-float-panel {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 101;
  width: 280px;
  height: calc(100% - 20px);
  display: flex;
  flex-direction: column;
  animation: pairPanelSlideIn 0.15s ease-out;
}

@keyframes pairPanelSlideIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.pair-float-panel.hidden {
  display: none !important;
}

.pair-float-panel-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  padding: 0 !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.45), 0 0 0 1px rgba(255,255,255,0.05);
  border: 1px solid var(--border-default);
}

/* Content area fills full width when using floating layout */
.page-layout--pair-detail > .markets-chart-area,
.page-layout--pair-detail > #insightContent {
  height: 100%;
  width: 100%;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  gap: var(--space-3);
  padding: 0 var(--space-4);
}

.kpi-grid--3 { grid-template-columns: repeat(3, 1fr); }
.kpi-grid--4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
  .kpi-grid--3 { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid--4 { grid-template-columns: repeat(2, 1fr); }
}

/* Two-column layout */
.layout-cols {
  display: grid;
  gap: var(--space-4);
  padding: 0 var(--space-4);
}

.layout-cols--60-40 {
  grid-template-columns: 3fr 2fr;
}

@media (max-width: 1024px) {
  .layout-cols--60-40 {
    grid-template-columns: 1fr;
  }
}

/* ── Status Bar: moved items (Flow selector + Spot Mode + AI status) ── */
.status-sep {
  opacity: 0.35;
  margin: 0 2px;
}

/* Flow selector inside status bar — compact variant */
.sb-flow-selector .flow-selector__select {
  padding: 1px 18px 1px 7px;
  font-size: 10px;
  height: 18px;
}

/* Spot Mode pill in status bar */
.sb-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: var(--radius-full, 999px);
  border: 1px solid var(--border-default);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  cursor: default;
}

/* Exchange badge — same style as sb-pill (Spot Mode) */
.sb-exchange-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: var(--radius-full, 999px);
  border: 1px solid var(--border-default);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  cursor: default;
}

.sb-ai-status {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-full, 999px);
  border: 1px solid transparent;
  white-space: nowrap;
  cursor: default;
  transition: color 0.2s, border-color 0.2s;
}
.sb-ai-online  { color: #a78bfa; border-color: rgba(139,92,246,0.35); }
.sb-ai-offline { color: var(--text-muted); border-color: var(--border-subtle); opacity: 0.6; }
.sb-ai-unknown { color: var(--text-muted); opacity: 0.5; }
