/**
 * Design System Admin UI - Complete Styles
 * Proper navbar-sidebar-main layout with flat navigation
 */

/* ============================================================================
   RESET & BASE STYLES
   ============================================================================ */

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  line-height: 1.5;
  background: var(--background);
  color: var(--foreground);
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  padding: 0;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

img, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/* ============================================================================
   LAYOUT GRID - NAVBAR | SIDEBAR | MAIN
   ============================================================================ */

#app {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 60px 1fr;
  height: 100vh;
  width: 100vw;
}

/* Header at top, spanning both columns */
.app-header {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  gap: var(--space-4);
  height: 60px;
}

/* Sidebar on left, full height of remaining space */
.sidebar {
  grid-column: 1;
  grid-row: 2;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: var(--space-4);
  overflow-y: auto;
  overflow-x: hidden;
  height: calc(100vh - 60px);
}

/* Main content on right, full height of remaining space */
.app-main {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: calc(100vh - 60px);
}

.app-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5);
}

/* ============================================================================
   HEADER STYLES
   ============================================================================ */

.app-header__project-selector {
  flex: 1;
  min-width: 200px;
}

.app-header__team-selector {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.team-select {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--background);
  color: var(--foreground);
  font-size: var(--text-sm);
  cursor: pointer;
}

.team-select:hover {
  border-color: var(--primary);
}

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

.notification-toggle-container {
  position: relative;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--error);
}

.ds-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
}

/* ============================================================================
   SIDEBAR - LOGO & HEADER
   ============================================================================ */

.sidebar__header {
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-4);
}

.sidebar__logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-weight: 600;
  font-size: var(--text-lg);
  color: var(--foreground);
}

.sidebar__logo-icon {
  width: 2rem;
  height: 2rem;
  background: var(--primary);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}

.sidebar__logo-icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

/* ============================================================================
   SIDEBAR - NAVIGATION
   ============================================================================ */

.sidebar__nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* Navigation Section */
.nav-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.nav-section + .nav-section {
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.nav-section__title {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  padding-left: var(--space-3);
  margin-bottom: var(--space-2);
}

/* Navigation Item */
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius);
  color: var(--foreground);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
  user-select: none;
  border: 2px solid transparent;
  outline: none;
}

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

.nav-item:focus {
  border-color: var(--primary);
  background: var(--muted-background);
  color: var(--primary);
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.nav-item.active:focus {
  border-color: var(--primary);
}

.nav-item__icon {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.nav-item:hover .nav-item__icon {
  transform: scale(1.05);
}

/* ============================================================================
   SIDEBAR - HELP PANEL & FOOTER
   ============================================================================ */

.sidebar__help {
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.help-panel {
  width: 100%;
}

.help-panel__toggle {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  width: 100%;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--foreground);
  transition: all 0.2s ease;
}

.help-panel__toggle:hover {
  background: var(--muted-background);
  color: var(--primary);
}

.help-panel__content {
  display: none;
  margin-top: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--muted-background);
  font-size: var(--text-xs);
}

.help-panel[open] .help-panel__content {
  display: block;
}

.help-section {
  margin-bottom: var(--space-3);
}

.help-section strong {
  display: block;
  margin-bottom: var(--space-2);
  color: var(--foreground);
}

.help-section ul,
.help-section ol {
  margin-left: var(--space-3);
  color: var(--muted);
}

.help-section li {
  margin-bottom: var(--space-1);
}

.sidebar__footer {
  padding-top: var(--space-4);
  text-align: center;
  font-size: var(--text-xs);
}

/* ============================================================================
   AI SIDEBAR (Right)
   ============================================================================ */

.app-sidebar {
  position: fixed;
  right: 0;
  top: 60px;
  width: 320px;
  height: calc(100vh - 60px);
  background: var(--card);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  display: none;
}

.app-sidebar[aria-expanded="true"] {
  display: block;
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

/* Tablet */
@media (max-width: 1024px) {
  #app {
    grid-template-columns: 200px 1fr;
  }

  .sidebar {
    padding: var(--space-3);
  }

  .app-content {
    padding: var(--space-4);
  }
}

/* Mobile */
@media (max-width: 768px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: 60px 1fr;
  }

  .app-header {
    padding: 0 var(--space-3);
  }

  .app-header__project-selector {
    display: none;
  }

  .app-header__team-selector {
    display: none;
  }

  .sidebar {
    position: fixed;
    left: -240px;
    width: 240px;
    height: calc(100vh - 60px);
    top: 60px;
    z-index: 100;
    transition: left 0.3s ease;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar.open {
    left: 0;
  }

  .app-main {
    grid-column: 1;
  }

  .app-content {
    padding: var(--space-3);
  }
}

/* ============================================================================
   UTILITIES
   ============================================================================ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ============================================================================
   COMPONENT PLACEHOLDERS
   ============================================================================ */

ds-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  background: var(--primary);
  color: white;
}

ds-button:hover {
  opacity: 0.9;
}

ds-button[data-variant="ghost"] {
  background: transparent;
  color: var(--foreground);
}

ds-button[data-size="icon"] {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
}

ds-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius);
  font-size: var(--text-xs);
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--muted-background);
  color: var(--muted);
}

ds-notification-center {
  display: block;
}

ds-ai-chat {
  display: block;
  width: 100%;
  height: 100%;
}

ds-toast-provider {
  display: block;
}
