/**
 * PropertyMetrix Navbar Styles
 * propertymetrix.co
 *
 * Companion stylesheet for pm-navbar.js
 * Import tokens file first, then this file.
 */

/* ── Base nav ───────────────────────────────────────────────────────────────── */

.pm-nav {
  position:         fixed;
  top:              0;
  left:             0;
  right:            0;
  z-index:          800;
  height:           64px;
  display:          flex;
  align-items:      center;
  gap:              0;
  background-color: #ffffff;
  border-bottom:    1px solid #e2e6f0;
  box-shadow:       0 1px 3px 0 rgb(19 24 40 / 0.08);
  padding:          0 1.5rem;
  font-family:      'Inter', 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.pm-nav__spacer {
  height: 64px;
  display: block;
}

/* ── Dark theme ─────────────────────────────────────────────────────────────── */

.pm-nav[data-theme="dark"] {
  background-color: #0a0d18;
  border-bottom:    1px solid #222845;
  box-shadow:       0 1px 3px 0 rgb(0 0 0 / 0.3);
}

.pm-nav[data-theme="dark"] .pm-nav__logo-name,
.pm-nav[data-theme="dark"] .pm-nav__user-name,
.pm-nav[data-theme="dark"] .pm-nav__switcher-btn {
  color: #f1f3f9;
}

.pm-nav[data-theme="dark"] .pm-nav__search {
  background-color: #131828;
  border-color:     #363f5e;
}

.pm-nav[data-theme="dark"] .pm-nav__search-input {
  background:  transparent;
  color:       #f1f3f9;
}

.pm-nav[data-theme="dark"] .pm-nav__search-input::placeholder {
  color: #6b7596;
}

/* ── Left section ───────────────────────────────────────────────────────────── */

.pm-nav__left {
  display:     flex;
  align-items: center;
  gap:         0.5rem;
  flex-shrink: 0;
  position:    relative;
}

/* ── Logo ───────────────────────────────────────────────────────────────────── */

.pm-nav__logo {
  display:         flex;
  align-items:     center;
  gap:             0.625rem;
  text-decoration: none;
  user-select:     none;
}

.pm-nav__logo-mark {
  width:     36px;
  height:    36px;
  flex-shrink: 0;
}

.pm-nav__logo-text {
  display:        flex;
  flex-direction: column;
  gap:            1px;
}

.pm-nav__logo-name {
  font-family:    'Plus Jakarta Sans', 'Segoe UI', system-ui, sans-serif;
  font-size:      1.0625rem;
  font-weight:    800;
  color:          #131828;
  line-height:    1;
  letter-spacing: -0.025em;
}

.pm-nav__logo-app {
  font-family:    'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size:      0.6875rem;
  font-weight:    500;
  color:          #6b7596;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height:    1;
}

/* ── App Switcher Button ────────────────────────────────────────────────────── */

.pm-nav__switcher-btn {
  display:          flex;
  align-items:      center;
  justify-content:  center;
  width:            36px;
  height:           36px;
  border:           none;
  background:       transparent;
  border-radius:    8px;
  cursor:           pointer;
  color:            #4e5877;
  padding:          0;
  transition:       background-color 0.15s, color 0.15s;
  margin-left:      0.25rem;
}

.pm-nav__switcher-btn:hover {
  background-color: #f1f3f9;
  color:            #2137b8;
}

.pm-nav__switcher-btn svg {
  width:  18px;
  height: 18px;
}

/* ── App Switcher Dropdown ──────────────────────────────────────────────────── */

.pm-nav__switcher-dropdown {
  position:         absolute;
  top:              calc(100% + 0.5rem);
  left:             0;
  width:            380px;
  background-color: #ffffff;
  border:           1px solid #e2e6f0;
  border-radius:    12px;
  box-shadow:       0 20px 25px -5px rgb(19 24 40 / 0.12), 0 8px 10px -6px rgb(19 24 40 / 0.08);
  overflow:         hidden;
  opacity:          0;
  transform:        translateY(-8px);
  transition:       opacity 0.2s, transform 0.2s;
  z-index:          100;
}

.pm-nav__switcher-dropdown.pm-nav__dropdown--open {
  opacity:   1;
  transform: translateY(0);
}

.pm-nav__switcher-header {
  padding:       1rem 1rem 0.75rem;
  border-bottom: 1px solid #f1f3f9;
}

.pm-nav__switcher-title {
  display:     block;
  font-size:   0.8125rem;
  font-weight: 700;
  color:       #131828;
}

.pm-nav__switcher-sub {
  display:     block;
  font-size:   0.6875rem;
  color:       #9aa3be;
  margin-top:  1px;
}

.pm-nav__app-grid {
  display:               grid;
  grid-template-columns: repeat(2, 1fr);
  gap:                   4px;
  padding:               0.625rem;
}

.pm-nav__app-item {
  display:         flex;
  align-items:     center;
  gap:             0.625rem;
  padding:         0.625rem 0.75rem;
  border-radius:   8px;
  text-decoration: none;
  transition:      background-color 0.15s;
}

.pm-nav__app-item:hover {
  background-color: #f8f9fc;
}

.pm-nav__app-item--active {
  background-color: #eef0fb;
}

.pm-nav__app-icon {
  display:          flex;
  align-items:      center;
  justify-content:  center;
  width:            32px;
  height:           32px;
  border-radius:    8px;
  background-color: color-mix(in srgb, var(--app-color, #2137b8) 12%, transparent);
  color:            var(--app-color, #2137b8);
  flex-shrink:      0;
}

.pm-nav__app-icon svg {
  width:  16px;
  height: 16px;
}

.pm-nav__app-text {
  display:        flex;
  flex-direction: column;
  gap:            1px;
  min-width:      0;
}

.pm-nav__app-name {
  font-size:   0.8125rem;
  font-weight: 600;
  color:       #222845;
  white-space: nowrap;
  overflow:    hidden;
  text-overflow: ellipsis;
}

.pm-nav__app-desc {
  font-size:   0.6875rem;
  color:       #9aa3be;
  white-space: nowrap;
  overflow:    hidden;
  text-overflow: ellipsis;
}

.pm-nav__app-item--active .pm-nav__app-name {
  color: #2137b8;
}

.pm-nav__switcher-footer {
  border-top: 1px solid #f1f3f9;
  padding:    0.625rem 1rem;
}

.pm-nav__switcher-all {
  font-size:       0.75rem;
  font-weight:     600;
  color:           #2137b8;
  text-decoration: none;
}

.pm-nav__switcher-all:hover {
  text-decoration: underline;
}

/* ── Center: Search ─────────────────────────────────────────────────────────── */

.pm-nav__center {
  flex:           1;
  max-width:      480px;
  margin:         0 1.5rem;
}

.pm-nav__search {
  display:          flex;
  align-items:      center;
  gap:              0.5rem;
  height:           38px;
  background-color: #f8f9fc;
  border:           1px solid #e2e6f0;
  border-radius:    9999px;
  padding:          0 0.875rem;
  transition:       border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.pm-nav__search:focus-within {
  border-color:     #2941cd;
  box-shadow:       0 0 0 3px rgb(41 65 205 / 0.12);
  background-color: #ffffff;
}

.pm-nav__search-icon {
  width:      16px;
  height:     16px;
  color:      #9aa3be;
  flex-shrink: 0;
}

.pm-nav__search-input {
  flex:         1;
  border:       none;
  background:   transparent;
  font-family:  'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size:    0.8125rem;
  color:        #131828;
  outline:      none;
  min-width:    0;
}

.pm-nav__search-input::placeholder {
  color: #9aa3be;
}

.pm-nav__search-shortcut {
  font-family:      'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size:        0.625rem;
  font-weight:      500;
  color:            #9aa3be;
  background-color: #e2e6f0;
  border:           1px solid #c8cedf;
  border-radius:    4px;
  padding:          1px 5px;
  flex-shrink:      0;
}

/* ── Right section ──────────────────────────────────────────────────────────── */

.pm-nav__right {
  display:     flex;
  align-items: center;
  gap:         0.5rem;
  flex-shrink: 0;
  margin-left: auto;
  position:    relative;
}

.pm-nav__icon-btn {
  display:          flex;
  align-items:      center;
  justify-content:  center;
  width:            36px;
  height:           36px;
  border:           none;
  background:       transparent;
  border-radius:    8px;
  cursor:           pointer;
  color:            #4e5877;
  padding:          0;
  transition:       background-color 0.15s, color 0.15s;
  position:         relative;
}

.pm-nav__icon-btn:hover {
  background-color: #f1f3f9;
  color:            #2137b8;
}

.pm-nav__icon-btn svg {
  width:  18px;
  height: 18px;
}

.pm-nav__notif-dot {
  position:         absolute;
  top:              6px;
  right:            6px;
  width:            8px;
  height:           8px;
  background-color: #ef4444;
  border:           2px solid #ffffff;
  border-radius:    50%;
}

/* ── User menu ──────────────────────────────────────────────────────────────── */

.pm-nav__user {
  display:      flex;
  align-items:  center;
  gap:          0.5rem;
  height:       40px;
  padding:      0 0.5rem 0 0.375rem;
  border-radius: 9999px;
  cursor:       pointer;
  border:       1px solid transparent;
  transition:   background-color 0.15s, border-color 0.15s;
  user-select:  none;
}

.pm-nav__user:hover {
  background-color: #f1f3f9;
  border-color:     #e2e6f0;
}

.pm-nav__avatar {
  width:            32px;
  height:           32px;
  border-radius:    50%;
  overflow:         hidden;
  background-color: #2137b8;
  display:          flex;
  align-items:      center;
  justify-content:  center;
  flex-shrink:      0;
}

.pm-nav__avatar--lg {
  width:  40px;
  height: 40px;
}

.pm-nav__avatar-img {
  width:      100%;
  height:     100%;
  object-fit: cover;
}

.pm-nav__avatar-initials {
  font-family:    'Plus Jakarta Sans', 'Segoe UI', system-ui, sans-serif;
  font-size:      0.6875rem;
  font-weight:    700;
  color:          #ffffff;
  letter-spacing: 0.05em;
  line-height:    1;
}

.pm-nav__avatar--lg .pm-nav__avatar-initials {
  font-size: 0.8125rem;
}

.pm-nav__user-info {
  display:        flex;
  flex-direction: column;
  gap:            1px;
}

.pm-nav__user-name {
  font-size:   0.8125rem;
  font-weight: 600;
  color:       #131828;
  line-height: 1;
  white-space: nowrap;
}

.pm-nav__user-role {
  font-size:   0.625rem;
  font-weight: 500;
  color:       #9aa3be;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1;
}

.pm-nav__chevron {
  width:      16px;
  height:     16px;
  color:      #9aa3be;
  transition: transform 0.2s;
}

.pm-nav__user[aria-expanded="true"] .pm-nav__chevron {
  transform: rotate(180deg);
}

/* ── User dropdown ──────────────────────────────────────────────────────────── */

.pm-nav__user-dropdown {
  position:         absolute;
  top:              calc(100% + 0.5rem);
  right:            0;
  width:            240px;
  background-color: #ffffff;
  border:           1px solid #e2e6f0;
  border-radius:    12px;
  box-shadow:       0 20px 25px -5px rgb(19 24 40 / 0.12), 0 8px 10px -6px rgb(19 24 40 / 0.08);
  overflow:         hidden;
  opacity:          0;
  transform:        translateY(-8px);
  transition:       opacity 0.2s, transform 0.2s;
  z-index:          100;
}

.pm-nav__user-dropdown.pm-nav__dropdown--open {
  opacity:   1;
  transform: translateY(0);
}

.pm-nav__dropdown-header {
  display:      flex;
  align-items:  center;
  gap:          0.75rem;
  padding:      1rem;
}

.pm-nav__dropdown-name {
  font-size:   0.875rem;
  font-weight: 600;
  color:       #131828;
  line-height: 1.25;
}

.pm-nav__dropdown-role {
  font-size:   0.6875rem;
  color:       #9aa3be;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top:  2px;
}

.pm-nav__dropdown-divider {
  height:           1px;
  background-color: #f1f3f9;
  margin:           4px 0;
}

.pm-nav__dropdown-item {
  display:         flex;
  align-items:     center;
  gap:             0.625rem;
  padding:         0.5625rem 1rem;
  font-size:       0.875rem;
  font-weight:     500;
  color:           #363f5e;
  text-decoration: none;
  background:      none;
  border:          none;
  width:           100%;
  text-align:      left;
  cursor:          pointer;
  transition:      background-color 0.12s, color 0.12s;
  font-family:     'Inter', 'Segoe UI', system-ui, sans-serif;
}

.pm-nav__dropdown-item svg {
  width:      16px;
  height:     16px;
  color:      #9aa3be;
  flex-shrink: 0;
}

.pm-nav__dropdown-item:hover {
  background-color: #f8f9fc;
  color:            #2137b8;
}

.pm-nav__dropdown-item:hover svg {
  color: #2137b8;
}

.pm-nav__dropdown-item--danger {
  color: #dc2626;
}

.pm-nav__dropdown-item--danger svg {
  color: #dc2626;
}

.pm-nav__dropdown-item--danger:hover {
  background-color: #fef2f2;
  color:            #b91c1c;
}

/* ── Auth actions (unauthenticated) ─────────────────────────────────────────── */

.pm-nav__auth-actions {
  display:     flex;
  align-items: center;
  gap:         0.5rem;
}

.pm-nav__btn {
  display:         inline-flex;
  align-items:     center;
  justify-content: center;
  height:          36px;
  padding:         0 1rem;
  border-radius:   8px;
  font-family:     'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size:       0.8125rem;
  font-weight:     600;
  letter-spacing:  0.015em;
  text-decoration: none;
  cursor:          pointer;
  border:          1px solid transparent;
  transition:      background-color 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
  white-space:     nowrap;
}

.pm-nav__btn--ghost {
  background:  transparent;
  color:       #363f5e;
  border-color: transparent;
}

.pm-nav__btn--ghost:hover {
  background-color: #f1f3f9;
  color:            #2137b8;
}

.pm-nav__btn--outline {
  background:   transparent;
  color:        #2137b8;
  border-color: #2137b8;
}

.pm-nav__btn--outline:hover {
  background-color: #eef0fb;
}

.pm-nav__btn--primary {
  background-color: #2137b8;
  color:            #ffffff;
  box-shadow:       0 2px 8px 0 rgb(41 65 205 / 0.25);
}

.pm-nav__btn--primary:hover {
  background-color: #192da3;
  box-shadow:       0 4px 12px 0 rgb(41 65 205 / 0.35);
  transform:        translateY(-1px);
}

.pm-nav__btn--primary:active {
  transform: translateY(0);
}

/* ── Mobile hamburger ───────────────────────────────────────────────────────── */

.pm-nav__mobile-btn {
  display:          none;
  align-items:      center;
  justify-content:  center;
  width:            36px;
  height:           36px;
  border:           none;
  background:       transparent;
  border-radius:    8px;
  cursor:           pointer;
  color:            #4e5877;
  padding:          0;
  margin-left:      auto;
  transition:       background-color 0.15s;
}

.pm-nav__mobile-btn svg {
  width:  20px;
  height: 20px;
}

.pm-nav__mobile-btn:hover {
  background-color: #f1f3f9;
}

/* ── Mobile drawer ──────────────────────────────────────────────────────────── */

.pm-nav__mobile-drawer {
  position:         fixed;
  top:              64px;
  left:             0;
  right:            0;
  bottom:           0;
  background-color: #ffffff;
  overflow-y:       auto;
  z-index:          799;
  padding:          1rem;
  border-top:       1px solid #e2e6f0;
}

.pm-nav__app-grid--mobile {
  grid-template-columns: repeat(2, 1fr);
  margin-bottom:    1rem;
}

.pm-nav__mobile-user {
  border-top:   1px solid #f1f3f9;
  padding-top:  1rem;
  margin-top:   1rem;
}

.pm-nav__mobile-auth {
  display:        flex;
  flex-direction: column;
  gap:            0.5rem;
  padding-top:    1rem;
  border-top:     1px solid #f1f3f9;
  margin-top:     1rem;
}

.pm-nav__mobile-auth .pm-nav__btn {
  width:           100%;
  height:          44px;
  justify-content: center;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .pm-nav {
    padding: 0 1rem;
    height:  56px;
  }

  .pm-nav__spacer {
    height: 56px;
  }

  .pm-nav__center {
    display: none;  /* Search hidden on mobile — appears in drawer */
  }

  .pm-nav__right .pm-nav__user-info,
  .pm-nav__right .pm-nav__chevron,
  .pm-nav__right .pm-nav__icon-btn {
    display: none;
  }

  .pm-nav__user {
    padding: 4px;
    border:  none;
  }

  .pm-nav__auth-actions {
    display: none;
  }

  .pm-nav__mobile-btn {
    display: flex;
  }

  .pm-nav__switcher-btn {
    display: none;
  }

  .pm-nav__mobile-drawer {
    top: 56px;
  }
}

@media (max-width: 480px) {
  .pm-nav__logo-app {
    display: none;
  }

  .pm-nav__app-grid--mobile {
    grid-template-columns: 1fr;
  }
}

/* ── Focus styles (accessibility) ───────────────────────────────────────────── */

.pm-nav__switcher-btn:focus-visible,
.pm-nav__icon-btn:focus-visible,
.pm-nav__mobile-btn:focus-visible,
.pm-nav__user:focus-visible,
.pm-nav__logo:focus-visible {
  outline:        2px solid #2941cd;
  outline-offset: 2px;
}

.pm-nav__dropdown-item:focus-visible,
.pm-nav__app-item:focus-visible {
  outline:          2px solid #2941cd;
  outline-offset:  -2px;
}

/* ── Reduced motion ─────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .pm-nav__switcher-dropdown,
  .pm-nav__user-dropdown,
  .pm-nav__btn,
  .pm-nav__icon-btn,
  .pm-nav__switcher-btn,
  .pm-nav__user,
  .pm-nav__chevron {
    transition: none;
  }
}
