/* ============================================================
   ts-quantum Shared Layout — Base styles for all pages
   ============================================================ */

:root {
  /* Backgrounds */
  --bg-body: #f0f2f5;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #f8f9fa;
  --bg-hover: #f1f3f4;
  --bg-active: #e8f0fe;
  --bg-code: #f6f8fa;

  /* Text */
  --text-primary: #1a1a2e;
  --text-secondary: #5f6368;
  --text-muted: #80868b;
  --text-accent: #1a73e8;

  /* Borders */
  --border-light: #e8eaed;
  --border-medium: #dadce0;
  --border-focus: #1a73e8;

  /* Accent colors */
  --accent-primary: #1a73e8;
  --accent-primary-hover: #1557b0;
  --accent-secondary: #00acc1;
  --accent-success: #34a853;
  --accent-warning: #f9ab00;
  --accent-danger: #ea4335;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(60, 64, 67, 0.08);
  --shadow-md: 0 2px 8px rgba(60, 64, 67, 0.12);
  --shadow-lg: 0 4px 16px rgba(60, 64, 67, 0.16);

  /* Layout */
  --sidebar-width: 260px;
  --sidebar-collapsed: 60px;
  --header-height: 56px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

/* Dark theme override */
html.dark-theme {
  --bg-body: #0d1117;
  --bg-sidebar: #161b22;
  --bg-card: #1c2128;
  --bg-input: #21262d;
  --bg-hover: #21262d;
  --bg-active: #1f3a5f;
  --bg-code: #161b22;

  --text-primary: #c9d1d9;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --text-accent: #58a6ff;

  --border-light: #30363d;
  --border-medium: #484f58;
  --border-focus: #58a6ff;

  --accent-primary: #58a6ff;
  --accent-primary-hover: #79b8ff;
  --accent-secondary: #39d0d8;
  --accent-success: #3fb950;
  --accent-warning: #d29922;
  --accent-danger: #f85149;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.5);
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
}

/* ============================================================
   App Layout
   ============================================================ */

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   Sidebar
   ============================================================ */

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease, transform 0.3s ease;
  flex-shrink: 0;
  z-index: 100;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border-light);
  height: var(--header-height);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-decoration: none;
}

.logo-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.sidebar.collapsed .logo-text {
  display: none;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar.collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

/* Navigation */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.nav-section {
  margin-bottom: 8px;
}

.nav-section-title {
  display: block;
  padding: 8px 16px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.sidebar.collapsed .nav-section-title {
  display: none;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.15s;
  border-left: 3px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--bg-active);
  color: var(--text-accent);
  border-left-color: var(--accent-primary);
  font-weight: 500;
}

.nav-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-icon svg {
  width: 16px;
  height: 16px;
}

.sidebar.collapsed .nav-text {
  display: none;
}

/* Footer */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-light);
  text-align: center;
}

.version {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sidebar.collapsed .version {
  display: none;
}

/* ============================================================
   Main Content
   ============================================================ */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.top-bar h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.hamburger {
  display: none;
  background: none;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  padding: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.hamburger:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.top-bar-actions {
  display: flex;
  gap: 8px;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 1rem;
  transition: all 0.2s;
}

.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

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

/* ============================================================
   Mobile Overlay
   ============================================================ */

.mobile-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

.mobile-overlay.show {
  display: block;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    z-index: 100;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    margin-left: 0;
  }

  .hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .content {
    padding: 16px;
  }
}
