/************************************************************
 * PROFILIO TOPBAR
 * CSS do HTML/PHP z poprzedniej wiadomości
 ************************************************************/

/* ------------- RESET DLA KOMPONENTU ------------- */

#pf-topbar *,
#pf-topbar *::before,
#pf-topbar *::after {
  box-sizing: border-box;
}

/* ------------- ZMIENNE ------------- */

#pf-topbar {
  --pf-bg: #ffffff;
  --pf-bg-soft: #f4f4f5;       /* zinc-100 */
  --pf-bg-dashed: #bbf7d0;     /* emerald-200 */
  --pf-border: #e4e4e7;        /* zinc-200 */
  --pf-border-soft: #f4f4f5;
  --pf-shadow-soft: 0 10px 40px rgba(15, 23, 42, 0.06);
  --pf-text-main: #18181b;     /* zinc-900 */
  --pf-text-muted: #71717a;    /* zinc-500 */
  --pf-text-soft: #a1a1aa;     /* zinc-400 */
  --pf-emerald: #059669;
  --pf-emerald-soft: #ecfdf5;
  --pf-sky: #0284c7;
  --pf-sky-soft: #e0f2fe;
  --pf-red: #dc2626;
  --pf-blue: #2563eb;
  --pf-radius-lg: 1.5rem;
  --pf-radius: 999px;
  --pf-radius-card: 1.25rem;
  --pf-transition-fast: 150ms ease-out;
  --pf-shadow-chip: 0 4px 14px rgba(16, 185, 129, 0.25);
}

/* ------------- GŁÓWNY CONTAINER ------------- */

#pf-topbar {
  position: fixed;
  inset-inline: 0;
  top: 0;
  height: 56px;
  z-index: 40;
  border-bottom: 1px solid var(--pf-border);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(16px);
}

#pf-topbar .pf-topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  height: 56px;
  padding-inline: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ------------- LEWA STRONA ------------- */

.pf-topbar-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pf-logo-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.375rem;
  padding: 0.1rem 0.15rem;
}

.pf-logo-img {
  height: 24px;
  width: auto;
  object-fit: contain;
}

/* ------------- PRAWA STRONA ------------- */

.pf-topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ------------- IKONOWE PRZYCISKI ------------- */

.pf-icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--pf-border);
  background: #ffffff;
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.06);
  cursor: pointer;
  transition: background var(--pf-transition-fast),
              transform var(--pf-transition-fast),
              box-shadow var(--pf-transition-fast);
}

.pf-icon-button--lg {
  width: 44px;
  height: 44px;
}

.pf-icon-button--pill {
  padding: 0;
  width: 44px;
  height: 36px;
}

.pf-icon-button--avatar {
  width: 36px;
  height: 36px;
  padding: 0;
}

.pf-icon-button--badge {
  position: relative;
}

.pf-icon-button:hover {
  background: #fafafa;
  transform: translateY(-1px);
  box-shadow: 0 8px 26px rgba(15, 23, 42, 0.08);
}

.pf-icon-button:active {
  transform: scale(0.97);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
}

/* Lucide ikony – tylko rozmiary/kolory, JS je podmieni */
.pf-icon {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

.pf-icon-sm {
  width: 18px;
  height: 18px;
}

.pf-icon-xs {
  width: 12px;
  height: 12px;
}

.pf-icon-emerald {
  color: var(--pf-emerald);
}

.pf-icon-blue {
  color: var(--pf-blue);
}

.pf-icon-muted {
  color: var(--pf-text-soft);
}

/* ------------- BADGE / PILL / CHIP ------------- */

.pf-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding-inline: 3px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
}

.pf-badge--red {
  background: var(--pf-red);
}

.pf-lang-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 1px 4px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.85);
  color: #27272a;
}

.pf-flag-circle {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pf-flag-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pf-lang-code {
  letter-spacing: 0.02em;
}

/* Mały chevron na avatarze / organizacji */
.pf-chevron-badge {
  position: absolute;
  right: -2px;
  bottom: -2px;
  border-radius: 999px;
  border: 1px solid var(--pf-border);
  background: #ffffff;
  padding: 2px;
  display: grid;
  place-items: center;
}

.pf-chevron-badge--emerald .pf-icon {
  color: var(--pf-emerald);
}

.pf-chevron-badge--blue .pf-icon {
  color: var(--pf-blue);
}

/* Niewielkie kropki statusowe */
.pf-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: transparent;
}

.pf-dot--emerald {
  background: var(--pf-emerald);
}

/* Chip "Otwórz" przy aplikacjach */
.pf-chip {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
}

.pf-chip--open {
  background: var(--pf-emerald-soft);
  color: var(--pf-emerald);
  box-shadow: var(--pf-shadow-chip);
}

/* ------------- AVATARY ------------- */

.pf-avatar {
  border-radius: 999px;
  background: var(--pf-bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pf-avatar--app {
  width: 32px;
  height: 32px;
  overflow: hidden;
}

.pf-avatar--circle {
  width: 32px;
  height: 32px;
}

.pf-avatar-img {
  border-radius: 999px;
  object-fit: cover;
  display: block;
}

.pf-avatar-img--md {
  width: 32px;
  height: 32px;
}

.pf-avatar-initials {
  font-size: 11px;
  font-weight: 600;
  color: #3f3f46;
}

/* ------------- GŁÓWNE MENU (DESKTOP) ------------- */

.pf-main-nav {
  display: none;
  align-items: center;
  gap: 1.5rem;
  font-size: 15px;
  font-weight: 600;
}

.pf-main-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  border-radius: 6px;
  border: none;
  background: transparent;
  font: inherit;
  color: #142931;
  cursor: pointer;
  transition: color var(--pf-transition-fast),
              background var(--pf-transition-fast);
}

.pf-main-nav-link:hover {
  color:#142931;
}

/* ------------- DROPDOWNS / POPOVERY ------------- */

.pf-dropdown {
  position: relative;
}

.pf-popover {
  position: absolute;
  inset-inline-start: 0;
  margin-top: 8px;
  min-width: 260px;
  border-radius: var(--pf-radius-card);
  border: 1px solid var(--pf-border);
  background: #ffffff;
  box-shadow: var(--pf-shadow-soft);
  padding: 8px;
  display: none; /* JS: doda .is-open */
  z-index: 50;
}

.pf-popover--apps {
  width: 320px;
}

.pf-popover--section {
  width: 320px;
}

.pf-popover--lang {
  right: 0;
  left: auto;
  width: 320px;
}

.pf-popover--messages {
  right: 0;
  left: auto;
  width: 360px;
}

.pf-popover--org {
  right: 0;
  left: auto;
  width: 380px;
}

.pf-popover--profile {
  right: 0;
  left: auto;
  width: 260px;
}

.pf-popover-header {
  padding: 4px 6px 8px;
}

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

.pf-popover-header--center {
  padding-top: 4px;
}

.pf-popover-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--pf-text-main);
}

/* Treść */
.pf-popover-body {
  padding: 4px 4px 6px;
}

/* Scrollowane wnętrza */
.pf-scroll-y {
  max-height: 260px;
  overflow-y: auto;
}

/* ------------- SEARCH INPUT W POPOVERACH ------------- */

.pf-search-field {
  margin-top: 8px;
  border-radius: 999px;
  border: 1px solid var(--pf-border);
  padding-inline: 12px;
  padding-block: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
}

.pf-search-field--lg {
  border-radius: 14px;
  padding-block: 8px;
}

.pf-search-input {
  border: none;
  outline: none;
  background: transparent;
  width: 100%;
  font-size: 13px;
  color: var(--pf-text-main);
}

.pf-search-input::placeholder {
  color: var(--pf-text-soft);
}

/* ------------- APLIKACJE (LISTA) ------------- */

.pf-app-item {
  width: 100%;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
  text-align: left;
  transition: background var(--pf-transition-fast),
              transform var(--pf-transition-fast);
}

.pf-app-item:hover {
  background: #fafafa;
  transform: translateY(-1px);
}

.pf-app-item .pf-avatar--app img {
  width: 100%;
  height: 100%;
}

.pf-app-text {
  min-width: 0;
  flex: 1;
}

.pf-app-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--pf-text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pf-app-desc {
  margin-top: 1px;
  font-size: 12px;
  color: var(--pf-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ------------- TAGI W DROPACH ------------- */

.pf-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}

.pf-tag {
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 500;
}

.pf-tag--sky {
  background: var(--pf-sky-soft);
  color: #0369a1;
}

/* ------------- LINKI W DROPACH (SEKCJE) ------------- */

.pf-section-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 14px;
}

.pf-section-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--pf-text-main);
  transition: background var(--pf-transition-fast),
              transform var(--pf-transition-fast);
}

.pf-section-link:hover {
  background: #f4f4f5;
  transform: translateY(-1px);
}

.pf-section-link-icon {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--pf-border);
  background: #ffffff;
  display: grid;
  place-items: center;
}

.pf-section-link-text {
  flex: 1;
}

/* ------------- LISTY JĘZYK/WALUTA ------------- */

.pf-section-label {
  margin-top: 4px;
  margin-bottom: 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--pf-text-soft);
}

.pf-section-label--mt {
  margin-top: 8px;
}

.pf-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 4px;
}

.pf-list-item {
  position: relative;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  transition: background var(--pf-transition-fast);
}

.pf-list-item:hover {
  background: #f4f4f5;
}

.pf-list-main {
  flex: 1;
  text-align: left;
}

.pf-list-meta {
  font-size: 11px;
  color: var(--pf-text-muted);
}

/* aktywne PL / PLN */
.pf-list-item.is-active {
  background: var(--pf-emerald-soft);
}

/* wyszarzone, nieklikalne */
.pf-list-item.is-disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

/* ------------- WIADOMOŚCI ------------- */

.pf-empty {
  padding: 18px 10px;
  text-align: center;
  font-size: 13px;
  color: var(--pf-text-muted);
}

/* ------------- ORG / PROFILE DROPDOWN ------------- */

.pf-org-item {
  border: none;
  background: transparent;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  transition: background var(--pf-transition-fast);
}

.pf-org-item:hover {
  background: #f4f4f5;
}

.pf-org-text {
  min-width: 0;
  flex: 1;
}

.pf-org-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--pf-text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pf-org-meta {
  font-size: 12px;
  color: var(--pf-text-muted);
}

.pf-org-scroll-hint {
  padding-top: 6px;
  padding-bottom: 2px;
  display: flex;
  justify-content: center;
  background: linear-gradient(to top, #ffffff, rgba(255, 255, 255, 0.7));
}

/* ------------- PROFIL DROPDOWN ------------- */

.pf-profile-header {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 12px;
  background: #f4f4f5;
  padding: 8px 10px;
}

.pf-profile-text {
  min-width: 0;
}

.pf-profile-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--pf-text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pf-profile-role {
  font-size: 11px;
  color: var(--pf-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pf-profile-menu-list {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pf-profile-item {
  width: 100%;
  border: none;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  color: var(--pf-text-main);
  transition: background var(--pf-transition-fast),
              transform var(--pf-transition-fast);
}

.pf-profile-item:hover {
  background: #f4f4f5;
  transform: translateY(-1px);
}

.pf-profile-item-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* ------------- BUTTONY (ZALOGUJ / REJESTRACJA / MODAL) ------------- */

.pf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-inline: 16px;
  padding-block: 7px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--pf-transition-fast),
              color var(--pf-transition-fast),
              border-color var(--pf-transition-fast),
              box-shadow var(--pf-transition-fast),
              transform var(--pf-transition-fast);
}

.pf-btn--ghost {
  border-color: #38bdf8;
  background: #e0f2fe;
  color: #0369a1;
}

.pf-btn--ghost:hover {
  background: #bae6fd;
}

.pf-btn--primary {
  background: var(--pf-emerald);
  color: #ffffff;
  box-shadow: 0 8px 26px rgba(16, 185, 129, 0.4);
}

.pf-btn--primary:hover {
  background: #047857;
}

.pf-btn--full {
  width: 100%;
}

/* ------------- AUTH BLOKI ------------- */

.pf-auth-buttons {
  display: none;
  align-items: center;
  gap: 8px;
}

/* ------------- MOBILNE MENU ------------- */

.pf-mobile-nav {
  display: none;
  position: relative;
  border-bottom: 1px solid var(--pf-border);
  background: #ffffff;
}

.pf-mobile-nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding-inline: 1rem;
  padding-block: 8px 10px;
}

.pf-mobile-nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pf-mobile-nav-item {
  border: none;
  width: 100%;
  background: transparent;
  border-radius: 10px;
  padding: 8px 12px;
  text-align: left;
  font-size: 15px;
  font-weight: 500;
  color: #3f3f46;
  cursor: pointer;
  transition: background var(--pf-transition-fast);
}

.pf-mobile-nav-item:hover {
  background: #f4f4f5;
}

.pf-mobile-auth-buttons {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ------------- MODAL WYLOGOWANIA ------------- */

.pf-logout-backdrop {
  position: fixed;
  inset: 56px 0 0 0;
  background: rgba(0, 0, 0, 0.4);
  display: none; /* JS doda .is-open */
  align-items: flex-start;
  justify-content: center;
  padding-top: 1.5rem;
  padding-inline: 1rem;
  z-index: 50;
}

.pf-logout-dialog {
  width: 100%;
  max-width: 480px;
  border-radius: 1.75rem;
  background: #ffffff;
  padding: 18px 18px 16px;
  box-shadow: 0 22px 80px rgba(15, 23, 42, 0.2);
}

.pf-logout-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.pf-logout-icon {
  width: 38px;
  height: 38px;
  border-radius: 18px;
  background: var(--pf-emerald-soft);
  display: grid;
  place-items: center;
}

.pf-logout-text {
  flex: 1;
}

.pf-logout-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--pf-text-main);
}

.pf-logout-desc {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--pf-text-muted);
}

.pf-logout-user {
  margin-top: 12px;
  border-radius: 18px;
  background: #f4f4f5;
  padding: 8px 10px;
}

.pf-logout-user-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--pf-text-soft);
}

.pf-logout-user-row {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pf-logout-user-text {
  min-width: 0;
}

.pf-logout-user-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--pf-text-main);
}

.pf-logout-user-org {
  font-size: 12px;
  color: var(--pf-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pf-logout-footnote {
  margin-top: 8px;
  font-size: 11px;
  color: var(--pf-text-muted);
}

.pf-logout-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ------------- RESPONSYWNOŚĆ ------------- */

/* Domyślnie (mobile) */
.pf-show-sm {
  display: flex;
}

.pf-hide-sm {
  display: none;
}

/* Mobile icon pair (hamburger / X) */
.pf-mobile-icon--close {
  display: none;
}

/* Desktop ≥ 640px */
@media (min-width: 640px) {
  #pf-topbar .pf-topbar-inner {
    padding-inline: 1rem;
  }

  .pf-main-nav {
    display: flex;
  }

  .pf-auth-buttons {
    display: flex;
  }

  .pf-show-sm {
    display: none;
  }

  .pf-hide-sm {
    display: block;
  }

  .pf-dropdown--apps.pf-hide-sm {
    display: block;
  }

  .pf-dropdown--profile.pf-hide-sm {
    display: block;
  }

  .pf-auth-mobile {
    display: none;
  }
}

/* ------------- STANY OTWARCIA (JS DODA KLASY) ------------- */

/* otwarty dropdown */
[data-pf-popover].is-open {
  display: block;
}

/* otwarte menu mobilne */
.pf-mobile-nav.is-open {
  display: block;
}

/* otwarty modal logout */
.pf-logout-backdrop.is-open {
  display: flex;
}

/* aktywny hamburger (po otwarciu menu) – JS: doda .is-open na #pf-mobile-toggle */
#pf-mobile-toggle.is-open .pf-mobile-icon--menu {
  display: none;
}
#pf-mobile-toggle.is-open .pf-mobile-icon--close {
  display: block;
}
#pf-mobile-toggle .pf-mobile-icon--menu {
  display: block;
}
#pf-mobile-toggle .pf-mobile-icon--close {
  display: none;
}

/* ------------- DROBNE ------------- */

.pf-section-links a,
.pf-profile-item,
.pf-section-link {
  outline: none;
}

.pf-section-links a:focus-visible,
.pf-profile-item:focus-visible,
.pf-main-nav-link:focus-visible,
.pf-logo-button:focus-visible,
.pf-icon-button:focus-visible {
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.8);
}

/* scrollbar w dropdownach */
.pf-scroll-y::-webkit-scrollbar {
  width: 6px;
}
.pf-scroll-y::-webkit-scrollbar-track {
  background: transparent;
}
.pf-scroll-y::-webkit-scrollbar-thumb {
  background: #e4e4e7;
  border-radius: 999px;
}
/* --- FIX: przyciski wylogowania w topbarze + w modalu --- */

/* wspólna baza dla naszych przycisków wewnątrz topbara */
#pf-topbar .pf-btn {
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
  border-width: 1px;
  border-style: solid;
  cursor: pointer;
}

/* "Anuluj" w modalu, ewentualne ghosty */
#pf-topbar .pf-logout-actions .pf-btn--ghost {
  border-color: #e5e7eb !important;  /* jasna ramka */
  background: #ffffff !important;    /* białe tło */
  color: #374151 !important;         /* ciemny tekst */
  box-shadow: none !important;
}

/* "Wyloguj się" w modalu + ikona wyloguj w topbarze, jeśli ma klasę primary */
#pf-topbar .pf-logout-actions .pf-btn--primary {
  border-color: #059669 !important;
  background: #059669 !important;
  color: #ffffff !important;
  box-shadow: 0 8px 26px rgba(16, 185, 129, 0.4) !important;
}

/* na hover jasno, ale nadal kontrast */
#pf-topbar .pf-logout-actions .pf-btn--primary:hover {
  background: #047857 !important;
  border-color: #047857 !important;
}
#pf-topbar .pf-logout-actions .pf-btn--ghost:hover {
  background: #f3f4f6 !important;
}
