.app-layout {
  display: flex;
  min-height: 100vh;
  margin: 0;
  padding: 0;
}

.sidebar {
  width: 280px;
  background: linear-gradient(165deg, var(--pico-background-color) 0%, var(--surface-2) 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  box-shadow: 4px 0 16px rgba(0, 0, 0, 0.04),
  2px 0 4px rgba(0, 0, 0, 0.02);

  @include dark-mode {
    background: linear-gradient(165deg, #1c1c1c 0%, #161616 100%);
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.3),
    2px 0 4px rgba(0, 0, 0, 0.2);
  }
}

.sidebar-brand {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  gap: 0.875rem;

  @include dark-mode {
    border-bottom-color: rgba(255, 255, 255, 0.06);
  }

  .brand-logo {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.2s ease;

    &:hover {
      transform: scale(1.05);
    }
  }

  h1 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--pico-color);
    letter-spacing: -0.03em;
    line-height: 1.2;
    flex: 1;

    @include dark-mode {
      color: #f0f0f0;
    }
  }
}

.sidebar-nav {
  padding: 1.5rem 1.25rem;
  flex: 1;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  padding: 0.875rem 1.125rem;
  margin-bottom: 0.375rem;
  border-radius: 10px;
  text-decoration: none;
  color: var(--pico-color);
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  background: transparent;
  position: relative;

  @include dark-mode {
    color: #d0d0d0;
  }

  &:hover {
    background: rgba(255, 255, 255, 0.7);
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);

    @include dark-mode {
      background: rgba(255, 255, 255, 0.08);
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }
  }

  &.active {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.7) 100%);
    box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.12),
    inset 0 1px 3px rgba(0, 0, 0, 0.08),
    inset 0 -2px 4px rgba(0, 0, 0, 0.08),
    0 1px 0 rgba(255, 255, 255, 0.8);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);

    @include dark-mode {
      color: var(--pico-primary);
      background: linear-gradient(135deg, rgba(60, 60, 60, 0.95) 0%, rgba(50, 50, 50, 0.8) 100%);
      box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.5),
      inset 0 1px 3px rgba(0, 0, 0, 0.4),
      inset 0 -2px 4px rgba(0, 0, 0, 0.3),
      0 1px 0 rgba(255, 255, 255, 0.08);
      border-bottom-color: rgba(0, 0, 0, 0.5);
    }

    &:hover {
      transform: none;
    }
  }

  .nav-icon {
    margin-right: 0.875rem;
    font-size: 1.3rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;

    svg {
      display: block;
    }
  }

  .nav-label {
    font-size: 0.95rem;
    letter-spacing: -0.01em;
  }
}

.sidebar-user {
  padding: 1.5rem 1.25rem;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.02) 0%, rgba(0, 0, 0, 0.04) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5),
  0 -4px 12px rgba(0, 0, 0, 0.04);

  @include dark-mode {
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0.3) 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 -4px 12px rgba(0, 0, 0, 0.3);
  }
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pico-primary) 0%, var(--pico-primary-focus) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  font-size: 1.15rem;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15),
  inset 0 -2px 4px rgba(0, 0, 0, 0.2),
  inset 0 2px 4px rgba(255, 255, 255, 0.25);
  text-transform: uppercase;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.2s ease;

  &:hover {
    transform: scale(1.05);
  }
}

.user-details {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--pico-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  @include dark-mode {
    color: #e0e0e0;
  }
}

.user-email {
  font-size: 0.8rem;
  color: var(--pico-muted-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  @include dark-mode {
    color: #999;
  }
}

.logout-form {
  margin: 0;
}

.logout-button {
  width: 100%;
  padding: 0.7rem 1rem;
  background: linear-gradient(180deg, #fff 0%, #f8f8f8 100%);
  color: #555;
  border: none;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08),
  inset 0 1px 0 rgba(255, 255, 255, 0.9),
  inset 0 -1px 1px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;

  .logout-icon {
    display: inline-flex;
    align-items: center;
    line-height: 1;

    svg {
      display: block;
    }
  }

  @include dark-mode {
    background: linear-gradient(180deg, #2a2a2a 0%, #242424 100%);
    color: #d0d0d0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 1px rgba(0, 0, 0, 0.3);
  }

  &:hover {
    background: linear-gradient(180deg, #fff 0%, #fcfcfc 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 1),
    inset 0 -1px 1px rgba(0, 0, 0, 0.05);

    @include dark-mode {
      background: linear-gradient(180deg, #333 0%, #2a2a2a 100%);
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5),
      inset 0 1px 0 rgba(255, 255, 255, 0.1),
      inset 0 -1px 1px rgba(0, 0, 0, 0.3);
    }
  }

  &:active {
    transform: translateY(0);
    box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.15),
    inset 0 1px 3px rgba(0, 0, 0, 0.12);

    @include dark-mode {
      box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.5),
      inset 0 1px 3px rgba(0, 0, 0, 0.4);
    }
  }
}

.main-content {
  margin-left: 280px;
  flex: 1;
  width: calc(100% - 280px);
  background: var(--pico-background-color);
  min-height: 100vh;

  main.container {
    @include container(1280px);
    padding: 2rem 1rem;

    @include up(640px) {
      padding: 2rem 1.5rem;
    }

    @include up(1024px) {
      padding: 2rem 2rem;
    }
  }
}

// Page layouts - general container system
.page-container {
  @include container(1280px);
  padding: 1.5rem;

  @include up(768px) {
    padding: 2rem;
  }

  @include up(1024px) {
    padding: 2.5rem 3rem;
  }
}

.page-container-narrow {
  @include container(1000px);
  padding: 1.5rem;

  @include up(768px) {
    padding: 2rem;
  }

  @include up(1024px) {
    padding: 2.5rem;
  }
}

.page-header {
  margin-bottom: 2.5rem;

  h1 {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--pico-color);
    margin: 0 0 0.75rem;
    letter-spacing: -0.025em;
  }

  p {
    font-size: 1rem;
    color: var(--pico-muted-color);
    margin: 0;
    line-height: 1.5;
  }

  .header-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;

    button, a[role="button"] {
      margin: 0;
    }
  }
}

.page-header-centered {
  text-align: center;
  margin-bottom: 3rem;

  h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--pico-color);
    margin: 0 0 0.75rem;
    letter-spacing: -0.025em;
  }

  p {
    font-size: 1rem;
    color: var(--pico-muted-color);
    margin: 0;
    line-height: 1.5;

    i {
      font-style: italic;
      color: var(--pico-primary);
    }
  }
}

// Common card and list layouts
.card-list {
  display: grid;
  gap: 1.5rem;

  @include up(768px) {
    gap: 2rem;
  }
}

.page-navigation {
  text-align: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--pico-card-border-color);

  a {
    color: var(--pico-primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s ease;

    &:hover {
      color: var(--pico-primary-hover);
      text-decoration: underline;
    }
  }
}

.sidebar-toggle {
  @include icon-button;
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 1001;
  color: var(--pico-color);
  cursor: pointer;
}

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

.mobile-brand {
  display: none;
}

@include down(768px) {
  .sidebar-toggle {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 1000;

    &.mobile-open {
      transform: translateX(0);
    }
  }

  .sidebar-overlay.active {
    display: block;
  }

  .sidebar-brand {
    display: none;
  }

  .mobile-brand {
    display: block;
  }

  .main-content {
    margin-left: 0;
    width: 100%;
  }

  .page-container,
  .page-container-narrow,
  .page-container-tight {
    padding-top: 5rem;
  }
}
