/* DSS Workdesk - IDE-style Theme */
/* Based on VS Code dark theme color palette */

:root {
  /* VS Code color palette */
  --vscode-bg: #1e1e1e;
  --vscode-sidebar: #252526;
  --vscode-activitybar: #333333;
  --vscode-panel: #1e1e1e;
  --vscode-border: #3e3e42;
  --vscode-text: #cccccc;
  --vscode-text-dim: #858585;
  --vscode-accent: #007acc;
  --vscode-accent-hover: #0098ff;
  --vscode-selection: #264f78;

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;

  /* Layout dimensions */
  --activitybar-width: 48px;
  --sidebar-width: 280px;
  --panel-height: 280px;
}

/* Reset and base styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Ubuntu', 'Helvetica Neue', sans-serif;
  font-size: 13px;
  color: var(--vscode-text);
  background-color: var(--vscode-bg);
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

/* Shell grid layout - 3 column, single row (no bottom panel) */
ds-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr 350px;
  grid-template-rows: 1fr;
  grid-template-areas: "sidebar stage chat";
  width: 100%;
  height: 100vh;
  overflow: hidden;
  transition: grid-template-columns 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* When chat sidebar is collapsed, adjust grid to expand stage */
ds-shell:has(ds-ai-chat-sidebar.collapsed) {
  grid-template-columns: var(--sidebar-width) 1fr 0;
}

/* Activity Bar (hidden - items moved to stage-header-right) */
ds-activity-bar {
  display: none;
}

.activity-item {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--vscode-text-dim);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: all 0.1s;
}

.activity-item:hover {
  color: var(--vscode-text);
}

.activity-item.active {
  color: var(--vscode-text);
  border-left-color: var(--vscode-accent);
}

/* Sidebar (second column) */
ds-sidebar {
  grid-area: sidebar;
  background-color: var(--vscode-sidebar);
  border-right: 1px solid var(--vscode-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--vscode-border);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--vscode-text-dim);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-sm);
}

/* Stage (main work area) */
ds-stage {
  grid-area: stage;
  background-color: var(--vscode-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.stage-header {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--vscode-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stage-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-lg);
}

/* Chat Sidebar (right column) */
ds-ai-chat-sidebar {
  grid-area: chat;
  background-color: var(--vscode-sidebar);
  border-left: 1px solid var(--vscode-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  width: 350px;

  /* Smooth transitions for collapse/expand animation */
  transition: width 350ms cubic-bezier(0.4, 0, 0.2, 1),
              border-left 300ms cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 300ms cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 50;
}

/* Chat Panel Component - Critical for scroll containment */
ds-chat-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0; /* Critical: allows flex item to shrink below content size */
  overflow: hidden;
  position: relative; /* Positioning context for absolute children (tooltips, overlays) */
}

ds-ai-chat-sidebar.collapsed {
  width: 0;
  border-left: none;
  box-shadow: none;
  overflow: hidden;
}

.ai-chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

/* Animated toggle button with rotation effect */
.ai-chat-toggle-btn {
  transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1),
              color 200ms cubic-bezier(0.4, 0, 0.2, 1),
              opacity 200ms cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: center;
}

.ai-chat-toggle-btn.rotating {
  transform: rotate(180deg);
}

.ai-chat-toggle-btn:hover {
  color: var(--vscode-accent-hover);
}

/* Panel (bottom panel) - HIDDEN (functionality moved to sidebar) */
ds-panel {
  display: none !important;
}

.panel-header {
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid var(--vscode-border);
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.panel-tab {
  padding: var(--spacing-xs) var(--spacing-sm);
  cursor: pointer;
  color: var(--vscode-text-dim);
  border-bottom: 1px solid transparent;
  transition: color 200ms cubic-bezier(0.4, 0, 0.2, 1), border-bottom-color 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.panel-tab:hover {
  color: var(--vscode-text);
}

.panel-tab.active {
  color: var(--vscode-text);
  border-bottom-color: var(--vscode-accent);
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-md);
}

/* Common components */
button {
  transition: background-color 200ms cubic-bezier(0.4, 0, 0.2, 1), color 200ms cubic-bezier(0.4, 0, 0.2, 1), border-color 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.button {
  padding: var(--spacing-xs) var(--spacing-md);
  background-color: var(--vscode-accent);
  color: white;
  border: none;
  border-radius: 2px;
  cursor: pointer;
  font-size: 13px;
  transition: background-color 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.button:hover {
  background-color: var(--vscode-accent-hover);
}

.button:active {
  opacity: 0.8;
}

/* Focus visible styling for keyboard accessibility */
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--vscode-accent);
  outline-offset: 2px;
}

.team-btn:focus-visible {
  outline: 2px solid var(--vscode-accent);
  outline-offset: 1px;
}

/* Respect prefers-reduced-motion for accessibility */
/* Users who prefer reduced motion will have animations/transitions disabled */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
  }

  /* Disable scrolling animations */
  html {
    scroll-behavior: auto !important;
  }
}

input,
textarea,
select {
  transition: background-color 200ms cubic-bezier(0.4, 0, 0.2, 1), border-color 200ms cubic-bezier(0.4, 0, 0.2, 1), box-shadow 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.input {
  padding: var(--spacing-xs) var(--spacing-sm);
  background-color: var(--vscode-sidebar);
  border: 1px solid var(--vscode-border);
  color: var(--vscode-text);
  border-radius: 2px;
  font-size: 13px;
  transition: background-color 200ms cubic-bezier(0.4, 0, 0.2, 1), border-color 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.input:focus {
  outline: 1px solid var(--vscode-accent);
  border-color: var(--vscode-accent);
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--vscode-bg);
}

::-webkit-scrollbar-thumb {
  background: var(--vscode-border);
  border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Utility classes */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.gap-sm {
  gap: var(--spacing-sm);
}

.gap-md {
  gap: var(--spacing-md);
}

.text-dim {
  color: var(--vscode-text-dim);
}

.text-accent {
  color: var(--vscode-accent);
}

/* Admin Full-Page Mode */
/* When admin team is active, panel minimizes and stage takes full height */
ds-shell.admin-mode {
  grid-template-rows: 1fr 40px; /* Minimize panel to 40px */
}

ds-shell.admin-mode ds-panel {
  overflow: hidden;
}

ds-shell.admin-mode ds-panel .panel-content {
  display: none; /* Hide panel content in admin mode */
}

ds-shell.admin-mode ds-panel .panel-header {
  background-color: var(--vscode-panel);
  border-top: 1px solid var(--vscode-border);
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: 11px;
  color: var(--vscode-text-dim);
}

/* Admin dashboard cards in stage area */
ds-shell.admin-mode ds-stage .stage-content {
  height: 100%;
  overflow-y: auto;
}

/* Responsive Design - Tablet (1024px and below) */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 240px;
  }

  ds-shell {
    grid-template-columns: var(--sidebar-width) 1fr;
  }

  /* Hide chat sidebar on tablet, move to bottom or toggle */
  ds-ai-chat-sidebar {
    display: none !important;
  }

  .stage-header {
    flex-wrap: wrap;
    gap: var(--spacing-sm);
  }

  #team-selector {
    order: 1;
    width: 100%;
    padding-bottom: var(--spacing-sm);
    border-right: none;
    border-bottom: 1px solid var(--vscode-border);
  }
}

/* Responsive Design - Mobile (768px and below) */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 200px;
  }

  ds-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 44px 1fr;
    grid-template-areas:
      "stage"
      "stage";
  }

  /* Hide sidebar on mobile - use hamburger toggle */
  ds-sidebar {
    display: none;
    position: fixed;
    left: 0;
    top: 44px;
    width: 200px;
    height: calc(100vh - 44px);
    z-index: 100;
    background-color: var(--vscode-sidebar);
    border-right: 1px solid var(--vscode-border);
    border-bottom: none;
  }

  ds-sidebar.mobile-open {
    display: flex;
  }

  /* Add hamburger menu button */
  .hamburger-menu {
    display: flex;
    padding: 6px 8px;
    background: transparent;
    border: none;
    color: var(--vscode-text-dim);
    cursor: pointer;
    font-size: 20px;
    transition: all 0.1s;
  }

  .hamburger-menu:hover {
    color: var(--vscode-text);
    background: var(--vscode-selection);
  }

  .stage-header {
    padding: var(--spacing-sm);
    min-height: 44px;
  }

  .stage-header-left {
    width: 100%;
    flex-wrap: wrap;
  }

  #team-selector {
    width: 100%;
    padding: var(--spacing-sm) 0;
    border-right: none;
  }

  #stage-title {
    width: 100%;
    margin-top: var(--spacing-xs);
  }

  ds-project-selector {
    width: 100%;
    order: 2;
  }

  .stage-content {
    padding: var(--spacing-md);
  }

  .panel-header {
    padding: var(--spacing-xs) var(--spacing-sm);
  }
}

/* Responsive Design - Small Mobile (640px and below) */
@media (max-width: 640px) {
  body {
    font-size: 12px;
  }

  ds-shell {
    grid-template-rows: 40px 1fr;
  }

  .stage-header {
    padding: var(--spacing-xs);
    min-height: 40px;
  }

  .stage-header-right {
    gap: var(--spacing-xs) !important;
  }

  .stage-header-right button {
    padding: 4px 6px !important;
    font-size: 14px !important;
  }

  #team-selector {
    gap: 2px !important;
  }

  .team-btn {
    padding: 4px 6px !important;
    font-size: 10px !important;
  }

  .stage-content {
    padding: var(--spacing-sm);
  }

  .panel-content {
    padding: var(--spacing-sm);
  }

  .sidebar-content {
    padding: var(--spacing-xs);
  }
}
