@use 'variables' as *;
@use 'mixins' as *;

// ━━━ Layout Styles ━━━

// App layout wrapper
.app-layout {
  display: flex;
  min-height: 100vh;
}

// Sidebar
.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: $sidebar-width;
  background: $dark-bg;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  z-index: $z-sidebar;
  transition: width $transition-base;
  display: flex;
  flex-direction: column;
  overflow: hidden;

  &--collapsed {
    width: $sidebar-collapsed-width;

    .sidebar-logo-text,
    .nav-item-title,
    .nav-section-title {
      opacity: 0;
      visibility: hidden;
    }
  }

  // Logo area
  .sidebar-header {
    height: $navbar-height;
    display: flex;
    align-items: center;
    padding-inline: 20px;
    flex-shrink: 0;
  }

  .sidebar-logo-text {
    font-weight: 700;
    font-size: 1.25rem;
    margin-left: 12px;
    transition: opacity $transition-fast;
    white-space: nowrap;
  }

  // Nav items
  .sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px;

    &::-webkit-scrollbar {
      width: 4px;
    }

    &::-webkit-scrollbar-thumb {
      background: rgba(255, 255, 255, 0.1);
      border-radius: 2px;
    }
  }

  // Section title
  .nav-section-title {
    padding: 16px 12px 8px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.35);
    transition: opacity $transition-fast;
    white-space: nowrap;
  }

  // Nav item
  .nav-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    margin-bottom: 2px;
    border-radius: $radius-sm;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    transition: all $transition-fast;
    cursor: pointer;
    white-space: nowrap;

    &:hover {
      background: rgba(255, 255, 255, 0.06);
      color: rgba(255, 255, 255, 0.9);
    }

    &--active {
      background: rgba($primary, 0.15);
      color: $primary-light;

      .nav-item-icon {
        color: $primary-light;
      }
    }

    .nav-item-icon {
      flex-shrink: 0;
      width: 22px;
      height: 22px;
    }

    .nav-item-title {
      margin-left: 12px;
      font-size: 0.875rem;
      font-weight: 500;
      transition: opacity $transition-fast;
    }

    .nav-item-badge {
      margin-left: auto;
    }
  }

  // Sidebar footer (user menu)
  .sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
  }
}

// Top navbar — theme-aware
.app-navbar {
  position: fixed;
  top: 0;
  right: 0;
  left: $sidebar-width;
  height: $navbar-height;
  background: rgba(var(--v-theme-surface), 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(var(--v-theme-on-surface), 0.06);
  z-index: $z-navbar;
  display: flex;
  align-items: center;
  padding-inline: 24px;
  transition: left $transition-base;
}

// Content wrapper
.app-content-wrapper {
  flex: 1;
  margin-left: $sidebar-width;
  transition: margin-left $transition-base;
  min-height: 100vh;
  display: flex;
  flex-direction: column;

  // Collapsed sidebar — class-driven from Vue
  &--collapsed {
    margin-left: $sidebar-collapsed-width;

    .app-navbar {
      left: $sidebar-collapsed-width;
    }
  }
}

// Page content
.app-page-content {
  flex: 1;
  padding: 24px;
  padding-top: calc($navbar-height + 24px);
  max-width: $content-max-width;
  width: 100%;
  margin-inline: auto;
}

// Footer — theme-aware
.app-footer {
  padding: 16px 24px;
  font-size: 0.8125rem;
  color: rgba(var(--v-theme-on-surface), 0.4);
  flex-shrink: 0;
}

// Mobile overlay
.app-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: $z-overlay;
  opacity: 0;
  visibility: hidden;
  transition: opacity $transition-base, visibility $transition-base;

  &--visible {
    opacity: 1;
    visibility: visible;
  }
}

// Mobile responsive
@include mobile {
  .app-sidebar {
    transform: translateX(-100%);

    &--mobile-open {
      transform: translateX(0);
      z-index: $z-overlay + 1;
    }
  }

  .app-navbar {
    left: 0 !important;
  }

  .app-content-wrapper {
    margin-left: 0 !important;
  }
}

@include tablet {
  .app-sidebar:not(.app-sidebar--mobile-open) {
    width: $sidebar-collapsed-width;

    .sidebar-logo-text,
    .nav-item-title,
    .nav-section-title {
      opacity: 0;
      visibility: hidden;
    }
  }

  .app-navbar {
    left: $sidebar-collapsed-width;
  }

  .app-content-wrapper {
    margin-left: $sidebar-collapsed-width;
  }
}
