/* ============================================================
   SmartAdmin Bootstrap 5 - Layout
   CSS Module: Header, Sidebar, Navigation, Grid
   ============================================================ */

/* App Wrapper */
.app-wrap {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.app-header {
  grid-column: 1 / -1;
  background-color: var(--bs-body-bg);
  border-bottom: 1px solid var(--bs-gray-200);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  z-index: 1020;
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.app-sidebar {
  grid-row: 2;
  background-color: var(--bs-gray-50);
  border-right: 1px solid var(--bs-gray-200);
  width: 260px;
  overflow-y: auto;
  transition: transform 0.3s ease, width 0.3s ease;
}

[data-bs-theme="dark"] .app-sidebar {
  background-color: var(--bs-gray-800);
  border-right-color: var(--bs-gray-700);
}

.app-content {
  grid-row: 2;
  grid-column: 2;
  overflow-y: auto;
  padding: 2rem;
  background-color: var(--bs-body-bg);
}

/* Header Components */
.app-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--bs-primary);
  text-decoration: none;
  white-space: nowrap;
  min-width: 0;
}

.app-logo svg {
  width: 32px;
  height: 32px;
}

.app-logo:hover {
  color: var(--bs-primary);
  text-decoration: none;
}

/* Mobile Menu Toggle */
.mobile-menu-icon {
  background: none;
  border: none;
  color: var(--bs-body-color);
  cursor: pointer;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.mobile-menu-icon svg {
  width: 24px;
  height: 24px;
}

/* Header Nav */
.app-header-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-left: auto;
}

.app-header-nav .nav-link {
  color: var(--bs-body-color);
  text-decoration: none;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: color 0.2s ease;
}

.app-header-nav .nav-link:hover {
  color: var(--bs-primary);
}

.app-header-nav .nav-link.active {
  color: var(--bs-primary);
}

/* Sidebar Nav */
.app-nav {
  list-style: none;
  padding: 0;
  margin: 0;
}

.app-nav-item {
  margin: 0;
}

.app-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--bs-body-color);
  text-decoration: none;
  transition: all 0.2s ease;
  position: relative;
}

.app-nav-link:hover {
  background-color: rgba(0, 0, 0, 0.05);
  color: var(--bs-primary);
}

[data-bs-theme="dark"] .app-nav-link:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.app-nav-link.active {
  background-color: rgba(33, 150, 243, 0.1);
  color: var(--bs-primary);
  font-weight: 600;
}

.app-nav-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background-color: var(--bs-primary);
}

.app-nav-link svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.app-nav-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bs-gray-600);
  padding: 0.75rem 1rem 0.5rem;
  margin-top: 0.5rem;
}

/* Submenu */
.app-nav-submenu {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.app-nav-item.open > .app-nav-submenu {
  max-height: 500px;
}

.app-nav-submenu .app-nav-link {
  padding-left: 3rem;
  font-size: 0.9rem;
}

.app-nav-submenu .app-nav-link::before {
  content: "";
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 4px;
  background-color: currentColor;
  border-radius: 50%;
  opacity: 0.5;
}

.app-nav-submenu .app-nav-link.active::before {
  opacity: 1;
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  padding: 0.5rem 0;
  margin-bottom: 1rem;
  list-style: none;
  gap: 0.5rem;
  background-color: transparent;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
}

.breadcrumb-item a {
  color: var(--bs-primary);
  text-decoration: none;
}

.breadcrumb-item a:hover {
  text-decoration: underline;
}

.breadcrumb-item + .breadcrumb-item::before {
  content: "/";
  padding: 0 0.5rem;
  color: var(--bs-gray-600);
}

.breadcrumb-item.active {
  color: var(--bs-gray-600);
}

/* Grid Container */
.container,
.container-sm,
.container-md,
.container-lg,
.container-xl,
.container-xxl {
  width: 100%;
  padding-right: 0.75rem;
  padding-left: 0.75rem;
  margin-right: auto;
  margin-left: auto;
}

.container {
  max-width: 540px;
}

.container-sm {
  max-width: 540px;
}

.container-md {
  max-width: 720px;
}

.container-lg {
  max-width: 960px;
}

.container-xl {
  max-width: 1140px;
}

.container-xxl {
  max-width: 1320px;
}

/* Row & Columns */
.row {
  display: flex;
  flex-wrap: wrap;
  margin-right: -0.75rem;
  margin-left: -0.75rem;
}

.row > * {
  flex-shrink: 0;
  width: 100%;
  max-width: 100%;
  padding-right: 0.75rem;
  padding-left: 0.75rem;
}

/* Grid Sizes */
@media (min-width: 576px) {
  .container-sm {
    max-width: 540px;
  }
}

@media (min-width: 768px) {
  .container-md {
    max-width: 720px;
  }
}

@media (min-width: 992px) {
  .container-lg {
    max-width: 960px;
  }
}

@media (min-width: 1200px) {
  .container-xl {
    max-width: 1140px;
  }
}

@media (min-width: 1400px) {
  .container-xxl {
    max-width: 1320px;
  }
}

/* Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--bs-gray-200);
}

.page-header h1 {
  font-size: 2rem;
  margin: 0;
}

.page-header .page-actions {
  display: flex;
  gap: 0.75rem;
}

/* Sidebar Collapse */
.app-sidebar-collapsed .app-sidebar {
  width: 60px;
}

.app-sidebar-collapsed .app-nav-link {
  justify-content: center;
  padding: 0.75rem;
}

.app-sidebar-collapsed .app-nav-label,
.app-sidebar-collapsed .app-nav-link span:not(:first-child) {
  display: none;
}

.app-sidebar-collapsed .app-nav-submenu {
  display: none;
}

/* Mobile Responsive */
.app-mobile-menu-open .app-sidebar {
  position: fixed;
  left: 0;
  top: 60px;
  height: calc(100vh - 60px);
  z-index: 1019;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
