:root {
  --sidebar-width: 16rem;
  --sidebar-bg: #f3f4f6;
  --sidebar-border: #d7d8ed;
  --sidebar-text: #1b1d20;
  --sidebar-text-muted: #6b7280;
  --sidebar-hover-bg: #f3f4f6;
  --sidebar-active-bg: #ffffff;
  --sidebar-active-text: #2e77d7;
  --sidebar-active-border: #2e77d7;
}

/* Main Layout */
body.with-sidebar {
  margin: 0;
  padding: 0;
}

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

/* Sidebar Styles */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 1000;
  transition: transform 0.3s ease;
  overflow: visible;
}

/* Sidebar Header */
.sidebar-header {
  padding: 1.25rem;
  border-bottom: 1px solid #d7d8ed !important;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--sidebar-text);
  font-weight: 600;
  font-size: 1.25rem;
}

.sidebar-brand:hover {
  text-decoration: none;
  color: var(--sidebar-text);
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.sidebar-brand-text {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--sidebar-text);
}

.sidebar-toggle {
  background: transparent;
  border: none;
  padding: 0.5rem;
  color: var(--sidebar-text);
  cursor: pointer;
  display: none;
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
}

.sidebar-menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-item {
  margin: 0.125rem 0.75rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: 0.375rem;
  transition: all 0.15s ease;
  font-size: 0.875rem;
  font-weight: 400;
  border: none;
  background: transparent;
}

.sidebar-link:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-text);
  text-decoration: none;
}

.sidebar-link:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.sidebar-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  position: relative;
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 16px;
  background: var(--sidebar-active-border);
  border-radius: 0 2px 2px 0;
}

.sidebar-icon {
  width: 20px;
  text-align: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.sidebar-text {
  flex: 1;
}

/* Sidebar Sections */
.sidebar-section {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-section-title {
  padding: 0.5rem 1.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--sidebar-text-muted);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 0;
  background: var(--sidebar-bg);
  margin-top: auto;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  margin: 0 0.5rem 0.5rem 0.5rem;
  background: transparent;
  border-radius: 0.375rem;
  transition: background-color 0.15s ease;
  border: none;
  text-align: left;
  cursor: pointer;
  width: calc(var(--sidebar-width) - 1rem);
  max-width: calc(var(--sidebar-width) - 1rem);
  overflow: hidden;
}

.user-info:hover {
  background: var(--sidebar-bg);
}

.user-info:focus {
  outline: 2px solid var(--sidebar-active-border);
  outline-offset: 1px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--sidebar-active-text);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  flex-shrink: 0;
}

.user-avatar--local {
  background: #039855; /* Success green */
}

.user-avatar--test,
.user-avatar--uat {
  background: #dc6803; /* Warning orange */
}

.user-avatar--production {
  background: var(--sidebar-active-text); /* Primary blue - same as default */
}

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

.user-info::after {
  content: '\f078';
  font-family: 'Font Awesome 5 Free';
  font-weight: 900;
  font-size: 0.625rem;
  color: var(--sidebar-text-muted);
  flex-shrink: 0;
  margin-left: 0.25rem;
}

.user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.user-email {
  font-size: 0.6875rem;
  color: var(--sidebar-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.help-card {
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
  cursor: pointer;
}

.help-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

.help-icon-wrapper {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(var(--bs-primary-rgb), 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.help-card .card-title {
  color: var(--bs-dark);
}

#helpModal .modal-content {
  border-radius: 1rem;
}

.sidebar-divider {
  margin: 0;
  border: none;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-footer .sidebar-menu {
  padding: 1rem 0 0 0;
}

.sidebar-footer .sidebar-item {
  margin: 0.125rem 0.75rem;
}

.sidebar-footer .sidebar-link {
  font-size: 0.875rem;
  color: var(--sidebar-text);
}

.sidebar-footer .sidebar-link:hover {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
}

.auth-links {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
}

.auth-links .btn {
  flex: 1;
  font-size: 0.875rem;
  padding: 0.375rem 0.75rem;
}

/* Main Content Area */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Mobile Responsive */
@media (max-width: 991px) {
  .sidebar {
    transform: translateX(-100%);
  }

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

  .sidebar-toggle {
    display: block;
  }

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

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

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

@media (max-width: 768px) {
  .top-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .top-bar-left,
  .top-bar-right {
    justify-content: center;
  }

  .hotline-info {
    text-align: center;
  }
}

/* Container adjustments - allow normal Bootstrap padding */
.with-sidebar .container-fluid {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Page content wrapper - fill exact viewport height */
.page-content {
  flex: 1;
  overflow-y: auto;
  background: #f8f9fa;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Mobile responsive container padding */
@media (max-width: 768px) {
  .with-sidebar .container-fluid {
    padding: 1rem;
  }
}

/* Remove old header margins when using sidebar */
.with-sidebar .page-header {
  display: none;
}

/* Badge styles similar to screenshot */
.sidebar-badge {
  background: #ef4444;
  color: white;
  font-size: 0.75rem;
  padding: 0.125rem 0.375rem;
  border-radius: 9999px;
  margin-left: auto;
  font-weight: 600;
}

/* User menu dropdown - rotate chevron when expanded (flip up) */
.user-info[aria-expanded='true']::after {
  transform: rotate(180deg);
}

.user-info::after {
  transition: transform 0.15s ease;
}

/* User dropdown menu styling */
.user-dropdown-menu {
  width: calc(var(--sidebar-width) - 1rem);
  margin-bottom: 0.5rem;
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border: 1px solid var(--sidebar-border);
}

.user-dropdown-menu .dropdown-item {
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  color: var(--sidebar-text);
}

.user-dropdown-menu .dropdown-item:hover {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
}

.user-dropdown-menu .dropdown-item i {
  width: 1rem;
  text-align: center;
}
