:root {
  --bogel-primary: #005BFF;
  --bogel-accent: #00C8F0;
  --bogel-navy: #081A44;
  --bogel-bg: #F5F7FC;
  --bogel-surface: #FFFFFF;
  --bogel-surface-2: #F0F4FA;
  --bogel-border: #E2E8F0;
  --bogel-text: #0F172A;
  --bogel-muted: #64748B;
  --bogel-success: #16A34A;
  --bogel-error: #EF4444;
  --bogel-warning: #D97706;
  --bogel-radius: 14px;
  --bogel-shadow: 0 4px 20px rgba(8, 26, 68, 0.06);
  --font-display: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
}

html[data-theme="dark"] {
  --bogel-bg: #101827;
  --bogel-surface: #172033;
  --bogel-surface-2: #1E293B;
  --bogel-border: #283548;
  --bogel-text: #F1F5F9;
  --bogel-muted: #94A3B8;
  --bogel-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bogel-bg);
  color: var(--bogel-text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6, .font-display { font-family: var(--font-display); }
code, pre, .font-mono { font-family: var(--font-mono); }
.tabular-nums { font-variant-numeric: tabular-nums; }

.bogel-gradient {
  background: linear-gradient(135deg, var(--bogel-primary) 0%, var(--bogel-accent) 100%);
}
.bogel-navy-gradient {
  background: linear-gradient(155deg, #081A44 0%, #0E2B6B 55%, #005BFF 100%);
}

/* App Shell Layout */
.app-shell {
  display: flex;
  min-height: 100dvh;
  width: 100%;
}

.app-sidebar {
  width: 276px;
  flex-shrink: 0;
  background: var(--bogel-surface);
  border-right: 1px solid var(--bogel-border);
  display: flex;
  flex-direction: column;
  transition: width 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s ease;
  z-index: 40;
}

.app-sidebar.collapsed {
  width: 72px;
}
.app-sidebar.collapsed .sidebar-label,
.app-sidebar.collapsed .sidebar-history,
.app-sidebar.collapsed .sidebar-brand-text {
  display: none !important;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.app-header {
  height: 60px;
  background: var(--bogel-surface);
  border-bottom: 1px solid var(--bogel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  gap: 12px;
  flex-shrink: 0;
}

.bogel-card {
  background: var(--bogel-surface);
  border: 1px solid var(--bogel-border);
  border-radius: var(--bogel-radius);
  box-shadow: var(--bogel-shadow);
}

.nav-item-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--bogel-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.nav-item-link:hover, .nav-item-link.active {
  background: rgba(0, 91, 255, 0.1);
  color: var(--bogel-primary);
}
html[data-theme="dark"] .nav-item-link.active {
  background: rgba(0, 200, 240, 0.14);
  color: var(--bogel-accent);
}

/* Chat Area */
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
}
.chat-container {
  max-width: 860px;
  margin: 0 auto;
}
.msg-bubble-user {
  background: linear-gradient(135deg, var(--bogel-primary), #0046CC);
  color: #fff;
  border-radius: 16px 16px 4px 16px;
  padding: 12px 16px;
  max-width: 82%;
  margin-left: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-bubble-assistant {
  background: var(--bogel-surface);
  border: 1px solid var(--bogel-border);
  border-radius: 16px 16px 16px 4px;
  padding: 14px 18px;
  max-width: 94%;
  word-break: break-word;
}
.msg-bubble-assistant pre {
  background: #0B1220;
  color: #E2E8F0;
  padding: 12px 14px;
  border-radius: 10px;
  overflow-x: auto;
  position: relative;
  font-size: 0.84rem;
}

.chat-composer-wrap {
  border-top: 1px solid var(--bogel-border);
  background: var(--bogel-surface);
  padding: 12px 16px;
}
.chat-composer-box {
  max-width: 860px;
  margin: 0 auto;
  background: var(--bogel-bg);
  border: 1px solid var(--bogel-border);
  border-radius: 16px;
  padding: 10px 12px;
}
.chat-textarea {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--bogel-text);
  resize: none;
  outline: none;
  font-size: 0.94rem;
  max-height: 180px;
}

/* Workspace Split Screen */
.workspace-split {
  display: grid;
  grid-template-columns: 260px 1fr 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.ws-pane {
  border-right: 1px solid var(--bogel-border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.ws-pane:last-child { border-right: 0; }
.ws-scroll { flex: 1; overflow: auto; }

/* Mobile Bottom Nav & Responsive */
.mobile-bottom-nav { display: none; }
.mobile-ws-tabs { display: none; }

@media (max-width: 991.98px) {
  .app-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    width: 280px !important;
  }
  .app-sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 0 0 40px rgba(0,0,0,0.4);
  }
  .mobile-bottom-nav {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: 58px;
    background: var(--bogel-surface);
    border-top: 1px solid var(--bogel-border);
    flex-shrink: 0;
  }
  .mobile-bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.7rem;
    color: var(--bogel-muted);
    text-decoration: none;
    gap: 2px;
  }
  .mobile-bottom-nav a.active { color: var(--bogel-primary); font-weight: 600; }

  .workspace-split {
    display: flex;
    flex-direction: column;
  }
  .mobile-ws-tabs {
    display: flex;
    gap: 4px;
    padding: 6px 10px;
    background: var(--bogel-surface);
    border-bottom: 1px solid var(--bogel-border);
    overflow-x: auto;
  }
  .ws-pane { display: none; width: 100%; flex: 1; border-right: 0; }
  .ws-pane.mobile-active { display: flex; }
}

/* Skeleton Loader */
.skeleton {
  background: linear-gradient(90deg, var(--bogel-surface-2) 25%, var(--bogel-border) 50%, var(--bogel-surface-2) 75%);
  background-size: 200% 100%;
  animation: skel 1.3s infinite;
  border-radius: 8px;
}
@keyframes skel {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
