/* ============================================================
   Sidebar + topbar layout for protected_download app
   ============================================================ */
:root {
  --pd-sidebar-width: 250px;
  --pd-topbar-height: 64px;
}

.pd-layout { position: relative; min-height: 100vh; }

/* ---- Sidebar ---- */
.pd-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--pd-sidebar-width);
  height: 100vh;
  background: #ffffff;
  border-right: 1px solid #e8e8e8;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 1040;
}
.pd-sidebar__brand {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #f0f0f0;
}
.pd-sidebar__brand img { height: 38px; width: auto; }
.pd-sidebar__nav { padding: .75rem .75rem 2rem; }

.pd-nav-group { margin-bottom: 1.1rem; }
.pd-nav-group__title {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #9e9e9e;
  padding: 0 .6rem .35rem;
}
.pd-nav-link {
  display: block;
  padding: .5rem .6rem;
  margin-bottom: .1rem;
  border-radius: 8px;
  color: #3a3a3a;
  font-weight: 500;
  text-decoration: none;
  transition: background-color .15s ease, color .15s ease;
}
.pd-nav-link:hover,
.pd-nav-link:focus { background-color: #f2f2f2; color: #000; }
.pd-nav-link.active {
  background-color: #ececec;
  color: #000;
  box-shadow: inset 3px 0 0 #424242;
}

/* ---- Main area ---- */
.pd-main {
  margin-left: var(--pd-sidebar-width);
  min-height: 100vh;
}
.pd-content { padding-top: 1.25rem; padding-bottom: 2rem; }

/* ---- Topbar ---- */
.pd-topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  height: var(--pd-topbar-height);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  background: #ffffff;
  border-bottom: 1px solid #e8e8e8;
}

/* Sidebar toggle (hamburger) — hidden on desktop */
.pd-sidebar-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 40px;
  height: 40px;
  padding: 0 9px;
  background: transparent;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
}
.pd-sidebar-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  background: #3a3a3a;
  border-radius: 2px;
}

/* ---- Global search ---- */
.pd-search {
  display: flex;
  align-items: stretch;
  flex: 1 1 auto;
  max-width: 620px;
  height: 40px;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  background: #fafafa;
  overflow: hidden;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.pd-search:focus-within {
  border-color: #bdbdbd;
  box-shadow: 0 0 0 .2rem rgba(66, 66, 66, .1);
  background: #fff;
}
.pd-search__scope {
  border: none;
  border-right: 1px solid #e6e6e6;
  background: #f0f0f0;
  color: #3a3a3a;
  font-weight: 500;
  padding: 0 .6rem;
  border-radius: 0;
  outline: none;
  cursor: pointer;
}
.pd-search__input {
  border: none;
  background: transparent;
  outline: none;
  flex: 1 1 auto;
  padding: 0 .8rem;
  color: #212121;
  font-size: .95rem;
}
.pd-search__btn {
  border: none;
  background: transparent;
  color: #616161;
  padding: 0 .9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
.pd-search__btn:hover { color: #000; }

/* ---- Topbar right / avatar ---- */
.pd-topbar__right { margin-left: auto; display: flex; align-items: center; }
.pd-avatar-toggle { display: inline-flex; align-items: center; text-decoration: none; }
.pd-avatar-toggle::after { display: none !important; content: none !important; }
.pd-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; border-radius: 50%;
  font-weight: 600; font-size: .85rem; line-height: 1;
  user-select: none;
}

/* ---- Backdrop for mobile sidebar ---- */
.pd-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .4);
  z-index: 1035;
}
.pd-sidebar-backdrop.show { display: block; }

/* ---- Responsive: collapse sidebar to off-canvas ---- */
@media (max-width: 991.98px) {
  .pd-sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 0 0 30px rgba(0, 0, 0, .15);
  }
  .pd-sidebar.pd-sidebar--open { transform: translateX(0); }
  .pd-main { margin-left: 0; }
  .pd-sidebar-toggle { display: flex; }
  .pd-search { max-width: none; }
}

@media (max-width: 575.98px) {
  .pd-search__scope { display: none; }
}

.pd-btn-logout { background: transparent; color: #212121; border: 1px solid #bdbdbd; padding: .25rem .6rem; border-radius: 6px; }
.pd-btn-logout:hover { background: #424242; color: #fff; border-color: #424242; }

/* Match rate_limit_status card header styling across protected pages */
.protected-download .card-header { background-color: #f0f0f0; border-bottom: 1px solid #e0e0e0; }
.protected-download .card { border-radius: 6px; }

/* Sticky header for important fields (like billing email) */
.pd-card-header-sticky {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: #fff; /* keep header visible over content */
  padding-top: .75rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid #e9e9e9;
}
