/*
  * This file contains the unified styles for the navigation, 
  * including the sidebar and top navigation bar.
*/

:root {
  --primary-color: #007bff;
  --secondary-color: #6c757d;
  --light-gray: #f8f9fa;
  --dark-gray: #343a40;
  --white: #fff;
  --sidebar-width: 250px;
  --top-nav-height: 60px;
}

body {
  margin: 0;
  font-family: sans-serif;
}

.app-container {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background-color: var(--dark-gray);
  color: var(--white);
  transition: transform 0.3s ease;
  position: fixed;
  height: 100%;
  z-index: 1000;
  transform: translateX(0);
}

.main-content {
  flex-grow: 1;
  padding: 20px;
  margin-left: var(--sidebar-width);
  transition: margin-left 0.3s ease;
}

.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--top-nav-height);
  background-color: var(--white);
  border-bottom: 1px solid var(--light-gray);
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 1001;
}

.sidebar-toggle {
  font-size: 24px;
  background: none;
  border: none;
  cursor: pointer;
  display: none; /* Hidden by default on desktop */
  z-index: 1002;
}

/* Responsive adjustments */
@media (max-width: 991px) {
  .sidebar-toggle {
    display: block; /* Show on mobile */
    /* Add these properties to ensure clickability */
    position: relative; /* Ensure it respects z-index */
    z-index: 1003; /* Higher than other elements */
    pointer-events: auto; /* Ensure it can receive clicks */
    /* Add some visual cues for debugging */
    background-color: rgba(0, 0, 0, 0.5) !important; /* Temporarily make it visible */
    padding: 10px;
    border-radius: 5px;
  }
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
  }

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

  .main-content {
    margin-left: 0;
  }
}

/* Stronger mobile overrides to avoid being overridden by other CSS */
@media (max-width: 991px) {
  .sidebar {
    left: calc(-1 * var(--sidebar-width)) !important;
    transform: none !important;
    position: fixed !important;
    top: 0 !important;
    height: 100vh !important;
    z-index: 1030 !important;
  }

  .sidebar.open,
  .sidebar.show-mobile {
    left: 0 !important;
    transform: none !important;
  }

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

/* Also cover other common container names used in templates */
@media (max-width: 991px) {
  .content, .page-content, .container-fluid > .content, .app-container .content {
    margin-left: 0 !important;
    width: 100% !important;
  }

  .app-container > .main-content, .app-container > .content {
    margin-left: 0 !important;
  }

  nav.sidebar, .sidebar {
    left: -250px !important;
  }

  .sidebar.open, .sidebar.show-mobile { left: 0 !important; }
}

/* Backdrop shown when sidebar is open on mobile */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}
.sidebar-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}
