/* Shared dashboard shell — mobile nav, top bar, safe areas */

body {
  overflow-x: clip;
}

body.sidebar-mobile-open,
body.profile-panel-open {
  overflow: hidden;
}

/* Profile panel — mobile sheet header (hidden on desktop dropdown) */
.profile-panel-header {
  display: none;
}

.profile-panel-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 1001;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.profile-panel-backdrop.active {
  display: block;
  opacity: 1;
}

.profile-panel-header-title {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}

.profile-panel-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1.625rem;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: var(--transition);
}

.profile-panel-close-btn:hover {
  background: var(--surface-hover);
}

/* Notification panel — header layout + close control */
.notification-header {
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
}

.notification-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
}

.notification-header-row h3 {
  margin: 0;
  min-width: 0;
}

.notification-header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.notification-clear-btn {
  color: #b91c1c;
}

.notification-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1.625rem;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: var(--transition);
}

.notification-close-btn:hover {
  background: var(--surface-hover);
}

@media (min-width: 769px) {
  .notification-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .notification-header-row {
    width: auto;
    flex: 1;
    min-width: 0;
  }

  .notification-header-actions {
    flex-shrink: 0;
  }

  /* Body-level profile dropdown — anchored to profile button via JS */
  .profile-panel {
    position: fixed;
    top: var(--profile-panel-top, 4.5rem);
    right: var(--profile-panel-right, 1.5rem);
    bottom: auto;
    left: auto;
    width: auto;
    min-width: 260px;
    max-width: min(320px, calc(100vw - 2rem));
    max-height: none;
    margin: 0;
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: 0 8px 24px var(--shadow);
    z-index: 1002;
  }

  .profile-panel-body {
    padding: 0;
  }
}

/* Top bar: menu button + breadcrumb */
.top-bar-leading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1;
}

.mobile-menu-btn {
  display: none;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: var(--transition);
}

.mobile-menu-btn:hover {
  background: var(--surface-hover);
}

.top-bar-leading .breadcrumb {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Sidebar mobile drawer backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 199;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.sidebar-backdrop.active {
  display: block;
  opacity: 1;
}

@media (max-width: 768px) {
  .mobile-menu-btn {
    display: inline-flex;
  }

  .sidebar {
    z-index: 200;
    transition: transform 0.28s ease;
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.12);
  }

  .sidebar.mobile-open {
    transform: translateX(0) !important;
  }

  .top-bar {
    padding: 0.875rem 1rem;
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    gap: 0.75rem;
  }

  .breadcrumb {
    font-size: clamp(1rem, 4.5vw, 1.25rem);
  }

  .top-bar-actions {
    flex-shrink: 0;
    gap: 0.5rem;
  }

  .icon-btn {
    width: 44px;
    height: 44px;
  }

  .content-container,
  .profile-edit-content {
    padding: 1rem !important;
    padding-left: max(1rem, env(safe-area-inset-left)) !important;
    padding-right: max(1rem, env(safe-area-inset-right)) !important;
  }

  .main-content {
    width: 100%;
    min-width: 0;
  }

  .modal {
    padding: 0.75rem;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    align-items: flex-end;
  }

  .modal-content {
    padding: 1.25rem 1rem;
    max-height: min(92dvh, 92vh);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    width: 100%;
  }

  .modal-large,
  #orgModal .modal-content {
    max-width: 100%;
  }

  .profile-panel {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    margin: 0;
    padding: 0;
    background: var(--surface);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    z-index: 1004;
    max-height: min(85dvh, 85vh);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 -8px 32px var(--shadow-lg);
  }

  .profile-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem;
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
  }

  .profile-panel-body {
    padding: 1.25rem 1rem;
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
  }

  .profile-panel-actions .profile-panel-btn,
  .profile-panel-actions .profile-logout-btn {
    min-height: 48px;
  }

  .notification-panel {
    width: 100% !important;
    max-width: 100%;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .notification-header {
    padding: 1rem;
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  .feedback-fab {
    bottom: max(1rem, env(safe-area-inset-bottom));
    right: max(1rem, env(safe-area-inset-right));
  }
}

@media (max-width: 480px) {
  .top-bar {
    padding: 0.75rem 0.875rem;
  }

  .content-container,
  .profile-edit-content {
    padding: 0.875rem !important;
  }

  .ethics-banner {
    flex-wrap: wrap;
    max-height: none;
    padding: 0.5rem 0.75rem;
    padding-top: max(0.5rem, env(safe-area-inset-top));
    justify-content: flex-start;
    align-items: flex-start;
    gap: 0.35rem 0.5rem;
  }

  .ethics-banner .banner-text {
    white-space: normal;
    flex: 1 1 100%;
    line-height: 1.35;
    font-size: 0.8125rem;
  }

  .ethics-banner .banner-view-link {
    font-size: 0.8125rem;
    flex-shrink: 0;
  }

  .ethics-banner .banner-close {
    margin-left: auto;
  }

  .account-settings-page .settings-section {
    padding: 1.125rem 1rem;
  }

  .account-settings-page .settings-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }

  .account-settings-page .settings-static-val {
    text-align: left;
  }

  .profile-edit-actions {
    flex-direction: column;
  }

  .profile-edit-actions .btn {
    width: 100%;
    justify-content: center;
    min-height: 48px;
  }

  .profile-edit-form input[type="text"],
  .profile-edit-form input[type="url"],
  .profile-edit-form textarea,
  .profile-edit-form select,
  .profile-edit-form .profile-select,
  .profile-edit-form .location-chips-input {
    font-size: 16px;
    min-height: 44px;
  }
}

/* Count badge on a side-panel item (for example requests waiting under Privacy and sharing) */
.nav-badge-count { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; background: #dc2626; color: #fff; font-size: .75rem; font-weight: 700; text-align: center; line-height: 20px; }
.sidebar.collapsed .nav-badge-count { display: none; }
