/* Right-side detail drawer for a member's profile - same non-modal pattern as
   public/shared/audit-view.css's .audyt-drawer (fixed side panel, not a dialog overlay;
   .profile-drawer-backdrop is just a click target to dismiss it). */
.profile-drawer {
  position: fixed;
  inset: 0;
  z-index: 60;
}

.profile-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
}

.profile-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(290px, 82vw);
  overflow-y: auto;
  padding: 0.75rem 0.9rem 1rem;
  font-size: 0.85rem;
  line-height: 1.4;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 93%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.35);
}

.profile-drawer-close {
  float: right;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  padding: 0.1rem 0.4rem;
  font-size: 0.8rem;
  cursor: pointer;
}

.profile-drawer-close:hover {
  border-color: var(--gold);
  color: var(--gold);
}

/* Photos reuse style.css's .person-main-photo/.person-gallery - the same classes the public
   "O Nas" grid uses - so a profile photo looks like a normal gallery photo, not a shrunk circle,
   and .profile-avatar-placeholder only adds the "no photo yet" initials treatment on top of that
   same box (see profile-panel.js's renderProfile). */
.profile-avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--text-muted);
  cursor: default;
}

.profile-fields {
  margin: 0.5rem 0;
}

/* Wpisowe/składka roczna readout right under the photo (KRKG-0047 follow-up) - same
   .lw-skladka-icon badge (member-area.css, loaded on every page that includes this drawer) and
   layout as profil.js's own copy on Mój profil, which doesn't load this stylesheet at all. */
.lw-dues-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.9rem;
  align-items: center;
  margin: 0.4rem 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.lw-dues-status-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.profile-fields dt {
  color: var(--text-muted);
  font-size: 0.72rem;
  margin-top: 0.35rem;
}

.profile-fields dd {
  margin: 0;
}

/* Identity/weapons/dues are independently permissioned and independently saved, but share one
   "Edytuj" toggle (.profile-editor-toggle-row/.profile-editor-panel below) at the bottom of the
   drawer - the surrounding profile stays read-only until a capability-enabled viewer opens it. */
.profile-identity-section {
  margin: 0.75rem 0 1rem;
}

.profile-identity-form {
  display: grid;
  gap: 0.5rem;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.profile-identity-form label {
  display: grid;
  gap: 0.25rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.profile-identity-form input,
.profile-identity-form select {
  width: 100%;
  box-sizing: border-box;
}

.profile-identity-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Same "auto width" override as .lw-event-edit-actions .add-album-submit (member-area.css) -
   the base .add-album-submit is a full-bleed form submit; this keeps Zapisz sized to its own
   row instead of stretching edge to edge like a page-level submit button. */
.profile-identity-actions .add-album-submit {
  width: auto;
  flex: 1 1 auto;
  padding: 10px 1.25rem;
}

.profile-identity-section--pending {
  opacity: 0.7;
}

.profile-identity-error {
  margin: 0;
  color: var(--danger, #c0392b);
}

/* Each permission-gated editor owns its controls and transient state, so saving dues can never
   disable an unfinished weapons edit (or vice versa). */
.profile-weapons-section,
.profile-dues-section {
  margin: 0.75rem 0 1rem;
}

.profile-weapons-form,
.profile-dues-form {
  display: grid;
  gap: 0.5rem;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.profile-weapons-form fieldset,
.profile-dues-form fieldset {
  display: grid;
  gap: 0.55rem;
  min-width: 0;
  border: 0;
  padding: 0;
}

.profile-weapons-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.profile-dues-form label {
  display: grid;
  gap: 0.25rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.profile-weapons-section--pending,
.profile-dues-section--pending {
  opacity: 0.7;
}

.profile-weapons-error,
.profile-dues-error {
  margin: 0;
  color: var(--danger, #c0392b);
}

.profile-description {
  margin-top: 1rem;
  white-space: pre-wrap;
}

.profile-drawer-error {
  color: var(--danger, #c0392b);
}

/* The shared "Edytuj" toggle/panel wrapping identity+weapons+dues (profileEditorHtml in
   profile-panel.js) - placed at the very bottom of the profile, below Broń and every other
   read-only field. */
.profile-editor-toggle-row {
  margin-top: 0.75rem;
}

.profile-editor-panel {
  margin-top: 0.75rem;
}

.profile-editor-actions {
  margin-top: 0.5rem;
}

/* KRKG-0070: heading above the pendingPhotos gallery, distinguishing a member's still-unapproved
   staging-folder uploads from their live public photos above. */
.profile-pending-heading {
  margin: 1.25rem 0 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* .busy-sticker-loader--feature (style.css) already centers its own contents in a column -
   this just gives it some breathing room inside the drawer. */
.profile-drawer-loading {
  padding: 2rem 0;
}

/* Trigger elements added to existing name cells across the app. Every existing caller wraps its
   visible text in its own colored <span> (a category pill) or renders an icon only, so this base
   rule never needed its own text color - KRKG-0076's /pliki page was the first to put plain
   escaped text directly inside the <button>, which left it at the browser's default button text
   color (opaque black) instead of the surrounding muted/light text color, rendering unreadable
   against this site's dark background. `color: inherit` makes plain-text usage correct too,
   without changing anything for callers whose inner <span>/icon already sets its own color. */
.profile-trigger {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.profile-trigger--icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 6px;
  color: var(--text-muted);
}

.profile-trigger--icon:hover {
  color: var(--gold);
  background: rgba(255, 255, 255, 0.06);
}

.profile-trigger--icon svg {
  width: 1rem;
  height: 1rem;
}

/* Small secondary trigger placed right after a name that's already clickable as a whole pill
   (Lista Wyjazdowa, Spis Ludności) - sized in em so it scales with surrounding text and stays
   visibly smaller than Zarządzanie ludźmi's fixed-size .profile-trigger--icon button. */
.profile-trigger--icon-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  margin-left: 0.35em;
  color: var(--text-muted);
  vertical-align: middle;
}

.profile-trigger--icon-inline:hover {
  color: var(--gold);
}

.profile-trigger--icon-inline svg {
  width: 70%;
  height: 70%;
}

/* Round avatar (people-photos.js) swapped in for the generic person icon / equipment image icon.
   object-fit: cover fills the whole circle. */
.person-avatar {
  display: inline-block;
  box-sizing: border-box;
  width: 1.5em;
  height: 1.5em;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: middle;
  background: rgba(255, 255, 255, 0.08);
}

/* The generic "show profile" person icon next to a name pill is not needed: the pill itself opens
   the profile. It is only kept once people-photos.js has swapped it for the person's avatar. */
.profile-trigger--icon-inline:not(:has(.person-avatar)) {
  display: none;
}

/* In the icon slot: replaces the 1em icon, so the button grows to the avatar's size. */
.profile-trigger--icon-inline:has(.person-avatar) {
  width: auto;
  height: auto;
}

.profile-trigger--icon-inline .person-avatar--icon {
  width: 1.5em;
  height: 1.5em;
}

.profile-trigger--icon .person-avatar--icon {
  width: 1.5rem;
  height: 1.5rem;
}

/* Trailing a name pill: a fixed round box, the same size for everyone, completely filled by the
   picture (cover - the edges of a non-square photo are cropped). */
.person-avatar-slot {
  flex: 0 0 auto;
  box-sizing: border-box;
  width: 1.9em;
  height: 1.9em;
  margin-left: 0.35em;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.08);
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
}

.profile-trigger:has(> .person-avatar-slot),
.profile-trigger:has(> .person-avatar--equipment) {
  display: inline-flex;
  align-items: center;
}

/* A pill with a subline: the pill and the avatar share the first row, the subline sits under the pill.
   The avatar only adds a trailing column, so pills start at the same left edge with or without one. */
.person-pill-cell > .person-avatar-slot {
  grid-row: 1;
  grid-column: 2;
  align-self: center;
}

/* Legacy <img> lead avatar (pill-less triggers only). */
.person-avatar--lead {
  margin-left: 0.35em;
}

/* Replaces the muted image icon that follows an equipment pill (same spacing as that icon). */
.person-avatar--equipment {
  margin: 0;
}

/* Compact slide-out: smaller photos, headings and spacing than the page-level .person-* styles
   (style.css), scoped to the drawer so the public O Nas grid is unaffected. */
.profile-drawer-panel .person-main-photo {
  max-width: 170px;
  margin-bottom: 0.5rem;
}

.profile-drawer-panel .person-gallery {
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.profile-drawer-panel .person-gallery img {
  width: 44px;
  height: 44px;
}

.profile-drawer-panel h3 {
  margin: 0.4rem 0;
  font-size: 1.05rem;
}

.profile-drawer-panel .profile-description {
  margin-top: 0.5rem;
  font-size: 0.82rem;
}

/* Photo placeholder while the profile is still loading (initials) */
.profile-drawer-panel .profile-avatar-placeholder {
  font-size: 1.5rem;
}

.profile-drawer-loading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.profile-drawer-loading-sticker {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

/* Blocks that arrive from the backend after the instant preview slide in - the row grows from 0 to
   its natural height, so everything below it is pushed down smoothly instead of jumping. */
.profile-reveal {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  animation: profile-reveal 0.28s ease-out forwards;
}

.profile-reveal-inner {
  min-height: 0;
  overflow: hidden;
}

@keyframes profile-reveal {
  to {
    grid-template-rows: 1fr;
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .profile-reveal {
    grid-template-rows: 1fr;
    opacity: 1;
    animation: none;
  }
}
