/**
 * DSS Components - Layer 3 (Component Styles)
 *
 * All component styling using semantic tokens from dss-theme.css.
 *
 * FIRST PRINCIPLES:
 * - This layer references semantic tokens (--header-*, --sidebar-*, etc.)
 * - NO fallback values - tokens and theme layers MUST load first
 * - If layers are missing, theme-loader.js handles it
 * - Uses BEM methodology for class naming
 */

/* ==========================================================================
   App Header
   ========================================================================== */

.app-header {
  background-color: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  color: var(--header-text);
  padding: 0 var(--ds-space-4);
  gap: var(--ds-space-4);
  height: var(--header-height);
}

.app-header__project-selector {
  flex: 0 0 auto;
}

.app-header__team-selector {
  flex: 0 0 auto;
}

.app-header__actions {
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
  margin-left: auto;
}

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

.sidebar {
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  color: var(--sidebar-text);
  padding: var(--ds-space-4);
  width: var(--sidebar-width);
}

.sidebar__header {
  margin-bottom: var(--ds-space-6);
}

.sidebar__logo {
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
  font-weight: var(--ds-font-weight-semibold);
  font-size: var(--ds-font-size-lg);
}

.sidebar__logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background-color: var(--ds-color-primary);
  color: var(--ds-color-primary-foreground);
  border-radius: var(--ds-radius-md);
}

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

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

.sidebar__footer {
  margin-top: var(--ds-space-4);
  padding-top: var(--ds-space-4);
  border-top: 1px solid var(--sidebar-border);
}

/* ==========================================================================
   Navigation
   ========================================================================== */

.nav-section {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-1);
}

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

.nav-section__title {
  font-size: var(--ds-font-size-xs);
  font-weight: var(--ds-font-weight-semibold);
  color: var(--nav-section-title);
  text-transform: uppercase;
  letter-spacing: var(--ds-letter-spacing-wider);
  padding: var(--ds-space-2) var(--ds-space-3);
}

.nav-section__content {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-1);
}

/* Sub-sections within nav sections */
.nav-sub-section {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-1);
  margin-top: var(--ds-space-1);
}

.nav-sub-section__title {
  font-size: var(--ds-font-size-xs);
  font-weight: var(--ds-font-weight-medium);
  color: var(--nav-section-title);
  padding: var(--ds-space-1) var(--ds-space-3);
  padding-left: var(--ds-space-4);
  opacity: 0.8;
}

/* Navigation item levels */
.nav-item--level-1 {
  padding-left: var(--ds-space-3);
}

.nav-item--level-2 {
  padding-left: var(--ds-space-6);
  font-size: var(--ds-font-size-sm);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--nav-item-gap);
  padding: var(--nav-item-padding);
  border-radius: var(--nav-item-radius);
  color: var(--nav-item-text);
  font-size: var(--ds-font-size-sm);
  font-weight: var(--ds-font-weight-medium);
  transition: all var(--ds-transition-fast) var(--ds-ease-out);
  border: 2px solid transparent;
  cursor: pointer;
}

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

.nav-item:focus {
  outline: none;
  border-color: var(--nav-item-border-focus);
  background-color: var(--nav-item-bg-hover);
}

.nav-item.active {
  background-color: var(--nav-item-bg-active);
  color: var(--nav-item-text-active);
  font-weight: var(--ds-font-weight-semibold);
}

.nav-item__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: transform var(--ds-transition-fast) var(--ds-ease-out);
}

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

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

.app-main {
  background-color: var(--main-bg);
  color: var(--main-text);
}

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

/* ==========================================================================
   Landing Page
   ========================================================================== */

.landing-page {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow-y: auto;
  padding: var(--ds-space-6);
  background-color: var(--landing-bg);
  width: 100%;
}

.landing-page.active {
  display: flex;
}

.landing-hero {
  text-align: center;
  padding: var(--ds-space-8) 0;
  margin-bottom: var(--ds-space-8);
}

.landing-hero h1 {
  font-size: var(--ds-font-size-3xl);
  font-weight: var(--ds-font-weight-bold);
  color: var(--landing-hero-text);
  margin-bottom: var(--ds-space-3);
}

.landing-hero p {
  font-size: var(--ds-font-size-lg);
  color: var(--landing-hero-subtitle);
  max-width: 600px;
  margin: 0 auto;
}

.landing-content {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-8);
}

/* ==========================================================================
   Dashboard Category
   ========================================================================== */

.dashboard-category {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-4);
}

.dashboard-category__title {
  font-size: var(--ds-font-size-lg);
  font-weight: var(--ds-font-weight-semibold);
  color: var(--category-title-text);
  padding-bottom: var(--ds-space-3);
  border-bottom: 1px solid var(--category-title-border);
}

/* ==========================================================================
   Dashboard Grid
   ========================================================================== */

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: var(--ds-space-4);
}

/* ==========================================================================
   Dashboard Card
   ========================================================================== */

.dashboard-card {
  display: flex;
  flex-direction: column;
  padding: var(--ds-space-5);
  background-color: var(--dashboard-card-bg);
  border: 1px solid var(--dashboard-card-border);
  border-radius: var(--card-radius);
  color: var(--dashboard-card-text);
  cursor: pointer;
  transition: all var(--ds-transition-normal) var(--ds-ease-out);
  text-decoration: none;
  gap: var(--ds-space-3);
}

.dashboard-card:hover {
  border-color: var(--dashboard-card-border-hover);
  box-shadow: var(--dashboard-card-shadow-hover);
  transform: translateY(-2px);
}

.dashboard-card:focus {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

.dashboard-card__icon {
  font-size: var(--ds-font-size-2xl);
}

.dashboard-card__content {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-1);
  flex: 1;
}

.dashboard-card__title {
  font-size: var(--ds-font-size-base);
  font-weight: var(--ds-font-weight-semibold);
  color: var(--dashboard-card-text);
}

.dashboard-card__description {
  font-size: var(--ds-font-size-sm);
  color: var(--dashboard-card-text-muted);
  line-height: var(--ds-line-height-relaxed);
}

.dashboard-card__meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  color: var(--dashboard-card-text-muted);
  font-size: var(--ds-font-size-lg);
}

/* ==========================================================================
   AI Sidebar (Right Panel)
   ========================================================================== */

.app-sidebar {
  width: 360px;
  background-color: var(--sidebar-bg);
  border-left: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-sidebar[hidden] {
  display: none;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

ds-button,
.ds-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ds-space-2);
  padding: var(--button-padding-y) var(--button-padding-x);
  font-size: var(--button-font-size);
  font-weight: var(--button-font-weight);
  border-radius: var(--button-radius);
  transition: all var(--ds-transition-fast) var(--ds-ease-out);
  cursor: pointer;
  border: 1px solid transparent;
}

ds-button[data-variant="default"],
.ds-button--default {
  background-color: var(--button-bg);
  color: var(--button-text);
  border-color: var(--button-border);
}

ds-button[data-variant="default"]:hover,
.ds-button--default:hover {
  background-color: var(--button-bg-hover);
}

ds-button[data-variant="ghost"],
.ds-button--ghost {
  background-color: var(--button-ghost-bg);
  color: var(--button-ghost-text);
}

ds-button[data-variant="ghost"]:hover,
.ds-button--ghost:hover {
  background-color: var(--button-ghost-bg-hover);
}

ds-button[data-variant="outline"],
.ds-button--outline {
  background-color: var(--button-outline-bg);
  color: var(--button-outline-text);
  border-color: var(--button-outline-border);
}

ds-button[data-variant="outline"]:hover,
.ds-button--outline:hover {
  background-color: var(--button-outline-bg-hover);
}

ds-button[data-size="icon"],
.ds-button--icon {
  padding: var(--ds-space-2);
  width: 36px;
  height: 36px;
}

ds-button:focus,
.ds-button:focus {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

/* ==========================================================================
   Cards
   ========================================================================== */

ds-card,
.ds-card {
  display: block;
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  padding: var(--card-padding);
  box-shadow: var(--card-shadow);
  color: var(--card-text);
}

ds-card:hover,
.ds-card:hover {
  box-shadow: var(--card-shadow-hover);
}

/* ==========================================================================
   Badges
   ========================================================================== */

ds-badge,
.ds-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--badge-padding-y) var(--badge-padding-x);
  font-size: var(--badge-font-size);
  font-weight: var(--ds-font-weight-medium);
  border-radius: var(--badge-radius);
  background-color: var(--badge-bg);
  color: var(--badge-text);
}

ds-badge[data-variant="secondary"],
.ds-badge--secondary {
  background-color: var(--badge-secondary-bg);
  color: var(--badge-secondary-text);
}

ds-badge[data-variant="outline"],
.ds-badge--outline {
  background-color: var(--badge-outline-bg);
  color: var(--badge-outline-text);
  border: 1px solid var(--badge-outline-border);
}

ds-badge[data-variant="success"],
.ds-badge--success {
  background-color: var(--badge-success-bg);
  color: var(--badge-success-text);
}

ds-badge[data-variant="warning"],
.ds-badge--warning {
  background-color: var(--badge-warning-bg);
  color: var(--badge-warning-text);
}

ds-badge[data-variant="error"],
.ds-badge--error {
  background-color: var(--badge-error-bg);
  color: var(--badge-error-text);
}

/* ==========================================================================
   Inputs
   ========================================================================== */

ds-input,
.ds-input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea {
  display: block;
  width: 100%;
  padding: var(--input-padding-y) var(--input-padding-x);
  background-color: var(--input-bg);
  color: var(--input-text);
  border: 1px solid var(--input-border);
  border-radius: var(--input-radius);
  font-size: var(--ds-font-size-sm);
  transition: border-color var(--ds-transition-fast) var(--ds-ease-out);
}

ds-input:focus,
.ds-input:focus,
input:focus,
textarea:focus {
  outline: none;
  border-color: var(--input-border-focus);
  box-shadow: 0 0 0 var(--focus-ring-width) var(--focus-ring-color);
}

ds-input::placeholder,
.ds-input::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--input-placeholder);
}

/* ==========================================================================
   Select
   ========================================================================== */

select,
.ds-select {
  display: block;
  width: 100%;
  padding: var(--input-padding-y) var(--input-padding-x);
  background-color: var(--input-bg);
  color: var(--input-text);
  border: 1px solid var(--input-border);
  border-radius: var(--input-radius);
  font-size: var(--ds-font-size-sm);
  cursor: pointer;
}

select:focus,
.ds-select:focus {
  outline: none;
  border-color: var(--input-border-focus);
  box-shadow: 0 0 0 var(--focus-ring-width) var(--focus-ring-color);
}

.team-select {
  padding: var(--ds-space-1-5) var(--ds-space-3);
  background-color: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--input-radius);
}

/* ==========================================================================
   Avatar
   ========================================================================== */

.ds-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--avatar-size-md);
  height: var(--avatar-size-md);
  background-color: var(--avatar-bg);
  color: var(--avatar-text);
  border: 1px solid var(--avatar-border);
  border-radius: var(--ds-radius-full);
  font-size: var(--ds-font-size-sm);
  font-weight: var(--ds-font-weight-medium);
  cursor: pointer;
}

.ds-avatar:focus {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

/* ==========================================================================
   Help Panel
   ========================================================================== */

.help-panel {
  background-color: var(--help-panel-bg);
  border-radius: var(--ds-radius-md);
  border: 1px solid var(--help-panel-border);
}

.help-panel__toggle {
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
  padding: var(--ds-space-3);
  font-size: var(--ds-font-size-sm);
  font-weight: var(--ds-font-weight-medium);
  color: var(--help-panel-text);
  cursor: pointer;
  list-style: none;
}

.help-panel__toggle::-webkit-details-marker {
  display: none;
}

.help-panel__content {
  padding: var(--ds-space-3);
  padding-top: 0;
  font-size: var(--ds-font-size-sm);
  color: var(--help-panel-text-muted);
}

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

.help-section strong {
  display: block;
  color: var(--help-panel-text);
  margin-bottom: var(--ds-space-1);
}

.help-section ul,
.help-section ol {
  padding-left: var(--ds-space-4);
  list-style: disc;
}

.help-section ol {
  list-style: decimal;
}

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

/* ==========================================================================
   Status Indicators
   ========================================================================== */

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--ds-radius-full);
  background-color: var(--ds-color-muted-foreground);
}

.status-dot--success {
  background-color: var(--ds-color-success);
}

.status-dot--warning {
  background-color: var(--ds-color-warning);
}

.status-dot--error {
  background-color: var(--ds-color-error);
}

.status-dot--info {
  background-color: var(--ds-color-info);
}

/* ==========================================================================
   Notification Toggle Container
   ========================================================================== */

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

/* ==========================================================================
   Project Selector
   ========================================================================== */

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

.project-selector__label {
  font-size: var(--ds-font-size-sm);
  font-weight: var(--ds-font-weight-medium);
  color: var(--text-muted);
}

.project-selector__select {
  padding: var(--ds-space-1-5) var(--ds-space-3);
  background-color: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--input-radius);
  font-size: var(--ds-font-size-sm);
}

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

@media (max-width: 1024px) {
  .app-sidebar {
    width: 300px;
  }

  .dashboard-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}

@media (max-width: 768px) {
  .app-header__team-selector {
    display: none;
  }

  .app-sidebar {
    position: fixed;
    top: var(--header-height);
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 360px;
    transform: translateX(100%);
    transition: transform var(--ds-transition-slow) var(--ds-ease-out);
    z-index: 60;
  }

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

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .landing-hero h1 {
    font-size: var(--ds-font-size-2xl);
  }

  .landing-hero p {
    font-size: var(--ds-font-size-base);
  }
}
