/**
 * MainLayout Styles
 */

.mainLayout {
  display: flex;
  height: 100dvh;
  min-height: 100dvh;
  width: 100%;
  overflow: hidden;
  background: var(--bg-primary, #ffffff);
}

@supports not (height: 100dvh) {
  .mainLayout {
    height: 100vh;
    min-height: 100vh;
  }
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  width: 280px;
  min-width: 280px;
  height: 100%;
  background: var(--surface-color, #f8f9fa);
  border-right: 1px solid var(--border-color, #e0e0e0);
  overflow: hidden;
  z-index: 1200;
}

/* Logo */
.logoContainer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.logoImage {
  height: 40px;
  width: auto;
  object-fit: contain;
}

.logoText {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.logoPower {
  color: var(--text-primary, #1a1a1a);
}

.logoOn {
  color: var(--primary-color, #2563eb);
}

/* Navigation */
.navigation {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.5rem 0;
}

.loadingNav,
.errorNav {
  padding: 1rem;
  text-align: center;
  color: var(--text-secondary, #666);
  font-size: 0.875rem;
}

.errorNav {
  color: var(--error-color, #dc2626);
}

/* User Section */
.userSection {
  padding: 1rem;
  border-top: 1px solid var(--border-color, #e0e0e0);
  flex-shrink: 0;
}

/* Content */
.content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  position: relative;
  --mobile-topbar-height: 0px;
  display: flex;
  flex-direction: column;
  /* Let child components handle their own scrolling for sticky headers */
  overflow: hidden;
  background: var(--bg-primary, #ffffff);
  color: var(--text-primary, #1a1a1a);
}

/* Fills .content flex column so admin pages get a bounded height for inner scroll */
.outletShell {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  /* Allow horizontal scroll when inner content has a true minimum width; hiding X clips dashboard/store grids on narrow viewports */
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.mobileTopBar {
  display: none;
}

.mobileMenuButton {
  border: 1px solid var(--border-color, #e0e0e0);
  background: var(--bg-primary, #ffffff);
  color: var(--text-primary, #1a1a1a);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.mobileLogo {
  height: 32px;
  width: auto;
  object-fit: contain;
}

.mobileBackdrop {
  display: none;
}

/* Dark Theme */
:global(.dark-theme) .mainLayout {
  background: var(--bg-dark, #0a0a0a);
}

:global(.dark-theme) .sidebar {
  background: var(--surface-dark, #1a1a1a);
  border-right-color: var(--border-dark, #333);
}

:global(.dark-theme) .logoContainer {
  border-bottom-color: var(--border-dark, #333);
}

:global(.dark-theme) .logoImage {
  filter: brightness(0) invert(1);
}

:global(.dark-theme) .logoPower {
  color: var(--text-primary-dark, #ffffff);
}

:global(.dark-theme) .userSection {
  border-top-color: var(--border-dark, #333);
}

:global(.dark-theme) .content {
  background: var(--bg-dark, #0a0a0a);
  color: var(--text-primary, #e5e7eb);
}

:global(.dark-theme) .mobileMenuButton {
  border-color: var(--border-dark, #333);
  background: var(--surface-dark, #1a1a1a);
  color: var(--text-primary-dark, #ffffff);
}

/* Scrollbar Styling */
.navigation::-webkit-scrollbar {
  width: 6px;
}

.navigation::-webkit-scrollbar-track {
  background: transparent;
}

.navigation::-webkit-scrollbar-thumb {
  background: var(--border-color, #d0d0d0);
  border-radius: 3px;
}

.navigation::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary, #888);
}

:global(.dark-theme) .navigation::-webkit-scrollbar-thumb {
  background: var(--border-dark, #444);
}

:global(.dark-theme) .navigation::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary-dark, #666);
}

@media (max-width: 1024px) {
  .mainLayout {
    position: relative;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100dvh;
    transform: translateX(-100%);
    transition: transform 0.2s ease-in-out;
    box-shadow: 0 18px 32px rgba(0, 0, 0, 0.2);
    border-right: 1px solid var(--border-color, #e0e0e0);
  }

  @supports not (height: 100dvh) {
    .sidebar {
      height: 100vh;
    }
  }

  .sidebarOpen {
    transform: translateX(0);
  }

  .content {
    overflow: auto;
  }

  .mobileTopBar {
    position: sticky;
    top: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-primary, #ffffff);
    border-bottom: 1px solid var(--border-color, #e0e0e0);
  }

  .content {
    --mobile-topbar-height: 57px;
  }

  .mobileBackdrop {
    display: block;
    position: fixed;
    inset: 0;
    border: none;
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.35);
    z-index: 1150;
    cursor: pointer;
  }
}
