/**
 * Navigation Sidebar Styles
 * Portal-wide styles (mobile toolbar, footer, brand colour) live in portal.css
 */

/* ── Base sidebar ─────────────────────────────────────────────────── */
.navigation-sidebar {
  background-color: #fff;
  border-right: 1px solid #dee2e6;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  z-index: 1000;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid #dee2e6;
  background-color: #f8f9fa;
}

.sidebar-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

/* ── Navigation structure ─────────────────────────────────────────── */
.sidebar-nav {
  padding: 16px 0;
}

.sidebar-section {
  margin-bottom: 24px;
}

.sidebar-section:last-child {
  margin-bottom: 16px;
}

.section-title {
  padding: 0 16px 8px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #6c757d;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #e9ecef;
  margin-bottom: 8px;
}

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

/* Accordion group toggles (kept for backwards compatibility) */
.nav-group-toggle {
  width: 100%;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 6px 16px;
  color: #343a40;
  font-weight: 700;
  cursor: pointer;
}

.nav-group-toggle:hover { background-color: #f8f9fa; }

.nav-group-toggle:focus {
  outline: 2px solid #0479a8;
  outline-offset: -2px;
}

.nav-group-label {
  display: flex;
  align-items: center;
  color: inherit;
  font-weight: inherit;
}

.nav-group-label i {
  width: 20px;
  margin-right: 12px;
  text-align: center;
  font-size: 16px;
}

.nav-sublist {
  list-style: none;
  margin: 0;
  padding: 0 0 6px 0;
  max-height: 480px;
  overflow: hidden;
  opacity: 1;
  transition: max-height 0.2s ease, opacity 0.2s ease, padding-bottom 0.2s ease;
}

.nav-group-chevron {
  font-size: 12px;
  color: #6c757d;
  transition: transform 0.2s ease;
}

.nav-group.nav-group-collapsed .nav-group-chevron { transform: rotate(-90deg); }

.nav-group.nav-group-collapsed .nav-sublist {
  max-height: 0;
  opacity: 0;
  padding-bottom: 0;
}

.nav-sublink {
  padding: 8px 16px 8px 54px;
  font-weight: 500;
  font-size: 0.92rem;
}

.nav-sublink i {
  width: 16px;
  margin-right: 10px;
  font-size: 14px;
}

/* ── Navigation links ─────────────────────────────────────────────── */
.nav-link {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  color: #495057;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
  border-left: 4px solid transparent;
  margin-bottom: 2px;
}

.nav-link:hover {
  background-color: #f8f9fa;
  color: #c5050c;
  text-decoration: none;
  border-left-color: #c5050c;
}

.nav-link.active {
  background-color: rgba(197, 5, 12, 0.1) !important;
  color: #c5050c !important;
  font-weight: 600 !important;
  border-left-color: #c5050c !important;
}

.nav-link i {
  width: 20px;
  margin-right: 12px;
  text-align: center;
  font-size: 16px;
}

.nav-link.external-link i::after {
  content: ' ↗';
  font-size: 10px;
  margin-left: 4px;
}

/* ── Activity / recent projects ───────────────────────────────────── */
.activity-section {
  border-top: 1px solid #dee2e6;
  padding-top: 16px;
  margin-top: 16px;
}

.activity-link {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  color: #6c757d;
  text-decoration: none;
  font-size: 13px;
  transition: all 0.2s ease;
}

.activity-link:hover {
  background-color: #f8f9fa;
  color: #495057;
  text-decoration: none;
}

.activity-link i {
  width: 16px;
  margin-right: 8px;
  font-size: 12px;
}

/* ── Quick links ──────────────────────────────────────────────────── */
.quick-access {
  border-top: 1px solid #dee2e6;
  padding-top: 16px;
  margin-top: 16px;
}

.quick-link {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  color: #0479a8;
  text-decoration: none;
  font-size: 13px;
  transition: all 0.2s ease;
}

.quick-link:hover {
  background-color: #f8f9fa;
  color: #0366d6;
  text-decoration: none;
}

.quick-link i {
  width: 16px;
  margin-right: 8px;
  font-size: 12px;
}

/* ── Sidebar close button (shown on mobile) ───────────────────────── */
.sidebar-close-btn {
  display: none;
  background: transparent;
  border: none;
  color: #6c757d;
  font-size: 16px;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 4px;
  margin-left: auto;
  line-height: 1;
  flex-shrink: 0;
}

.sidebar-close-btn:hover {
  color: #333;
  background-color: #e9ecef;
}

.sidebar-close-btn:focus {
  outline: 2px solid #0479a8;
  outline-offset: -2px;
}

/* ── User section ─────────────────────────────────────────────────── */
.user-section {
  border-top: 1px solid #dee2e6;
  padding: 16px;
  margin-top: auto;
  background-color: #f8f9fa;
}

.user-info {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin-right: 8px;
  background-color: #c5050c;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
}

.user-name {
  font-weight: 600;
  color: #333;
  font-size: 14px;
  margin: 0;
}

.user-actions {
  display: flex;
  gap: 8px;
}

.user-action {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 4px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.user-action.primary {
  background-color: #c5050c;
  color: #fff;
}

.user-action.secondary {
  background-color: transparent;
  color: #6c757d;
  border: 1px solid #dee2e6;
}

.user-action:hover {
  text-decoration: none;
  opacity: 0.8;
}

/* ── Desktop layout — sidebar with content offset ─────────────────── */
@media (min-width: 769px) {
  body {
    margin-left: 280px;
  }

  #main {
    padding-left: 20px;
  }
}

/* ── Mobile layout — overlay sidebar ─────────────────────────────── */
@media (max-width: 768px) {
  body {
    margin-left: 0;
  }

  .uw-global-bar,
  #main {
    margin-left: 0;
    padding-left: 0;
  }

  .navigation-sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .navigation-sidebar.show {
    transform: translateX(0);
  }

  /* Backdrop: below sidebar (z-index 1000) but above page content */
  .sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 995;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }

  .sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
  }

  .sidebar-close-btn {
    display: block;
  }

  .sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
}

/* ── Focus states ─────────────────────────────────────────────────── */
.nav-link:focus,
.activity-link:focus,
.quick-link:focus {
  outline: 2px solid #0479a8;
  outline-offset: -2px;
}

/* ── Loading animation ────────────────────────────────────────────── */
.nav-link.loading i {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ── Print ────────────────────────────────────────────────────────── */
@media print {
  .navigation-sidebar {
    display: none;
  }
}
