/* ── SHARED NAV ─────────────────────────────────────────── */
/* Unified navigation bar for all authenticated pages       */
/* Overrides any per-page nav styles with #shared-nav scope */

/* Hide old inline navs immediately to prevent FOUC */
body > nav:not(#shared-nav):not(#sn-dispatch-sub) { display: none !important; }

#shared-nav {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 9000;
  padding: 0 1.5rem;
  height: 52px;
  display: flex;
  align-items: center;
  background: rgba(10, 15, 26, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-family: 'Poppins', sans-serif;
  box-sizing: border-box;
}

#shared-nav *,
#shared-nav *::before,
#shared-nav *::after {
  box-sizing: border-box;
}

/* ── Inner container ────────────────────────────────────── */
.sn-inner {
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* ── Left: logo + links ────────────────────────────────── */
.sn-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-shrink: 0;
}

.sn-logo {
  font-weight: 700;
  font-size: 1.15rem;
  color: #f8fafc;
  letter-spacing: -0.02em;
  text-decoration: none;
  white-space: nowrap;
}
.sn-logo span { color: #184A9E; }

.sn-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.sn-links::-webkit-scrollbar { display: none; }

.sn-link {
  font-size: 0.8rem;
  color: #94a3b8;
  text-decoration: none;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
  white-space: nowrap;
  position: relative;
}
.sn-link:hover { color: #f8fafc; background: rgba(255,255,255,0.05); }
.sn-link.active { color: #184A9E; font-weight: 600; background: rgba(24, 74, 158, 0.1); }

/* Email badge */
.sn-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  background: #ef4444;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  border-radius: 8px;
  padding: 0 4px;
  display: none;
}
.sn-badge.visible { display: block; }

/* ── Right: notification + user ─────────────────────────── */
.sn-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* Notification bell */
.sn-notif-wrap {
  position: relative;
}
.sn-notif-btn {
  position: relative;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 6px 8px;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  font-family: 'Poppins', sans-serif;
}
.sn-notif-btn:hover { background: rgba(255,255,255,0.1); color: #f8fafc; }
.sn-notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 14px;
  height: 14px;
  line-height: 14px;
  text-align: center;
  border-radius: 7px;
  padding: 0 3px;
  display: none;
}
.sn-notif-badge.visible { display: block; }

/* Notification dropdown */
.sn-notif-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  max-height: 400px;
  background: #1a2332;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 9100;
  overflow: hidden;
}
.sn-notif-dropdown.open { display: block; }
.sn-notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 0.82rem;
  font-weight: 600;
  color: #f8fafc;
}
.sn-notif-mark-all {
  background: none;
  border: none;
  color: #184A9E;
  font-size: 0.72rem;
  cursor: pointer;
  font-family: 'Poppins', sans-serif;
}
.sn-notif-mark-all:hover { text-decoration: underline; }
.sn-notif-list {
  max-height: 300px;
  overflow-y: auto;
}
.sn-notif-item {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 0.78rem;
  color: #94a3b8;
  cursor: pointer;
  transition: background 0.15s;
}
.sn-notif-item:hover { background: rgba(255,255,255,0.03); }
.sn-notif-item.unread { color: #e2e8f0; background: rgba(24, 74, 158, 0.06); }
.sn-notif-item .sn-notif-time { font-size: 0.68rem; color: #64748b; margin-top: 2px; }
.sn-notif-empty { padding: 20px 14px; text-align: center; font-size: 0.78rem; color: #64748b; }
.sn-notif-footer {
  padding: 8px 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
  text-align: center;
}
.sn-notif-footer a {
  font-size: 0.72rem;
  color: #184A9E;
  text-decoration: none;
}
.sn-notif-footer a:hover { text-decoration: underline; }

/* ── User button + dropdown ─────────────────────────────── */
.sn-user-wrap {
  position: relative;
}
.sn-user-btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 0.3rem 0.65rem;
  color: #94a3b8;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Poppins', sans-serif;
  white-space: nowrap;
}
.sn-user-btn:hover { background: rgba(255,255,255,0.1); color: #f8fafc; }
.sn-user-btn.open { background: rgba(255,255,255,0.1); color: #f8fafc; }

.sn-user-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(24, 74, 158, 0.3);
  border: 1px solid rgba(24, 74, 158, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #94a3b8;
}

.sn-role-badge {
  font-size: 0.6rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.4;
}
.sn-role-badge.role-admin        { background: rgba(234,179,8,0.2);  color: #fbbf24; }
.sn-role-badge.role-broker_agent { background: rgba(59,130,246,0.2); color: #60a5fa; }
.sn-role-badge.role-carrier      { background: rgba(16,185,129,0.2); color: #34d399; }
.sn-role-badge.role-customer     { background: rgba(168,85,247,0.2); color: #a78bfa; }

.sn-chevron {
  font-size: 0.6rem;
  transition: transform 0.2s;
  color: #64748b;
}
.sn-user-btn.open .sn-chevron { transform: rotate(180deg); }

/* User dropdown */
.sn-user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #1a2332;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 6px;
  min-width: 200px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 9100;
}
.sn-user-dropdown.open { display: block; }

.sn-dd-section-label {
  padding: 6px 10px 4px;
  font-size: 0.65rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.sn-dd-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.7rem;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 0.8rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
  font-family: 'Poppins', sans-serif;
}
.sn-dd-item:hover { background: rgba(255,255,255,0.06); color: #f8fafc; }
.sn-dd-item.danger { color: #ef4444; }
.sn-dd-item.danger:hover { background: rgba(239,68,68,0.1); }

.sn-dd-divider {
  height: 1px;
  background: rgba(255,255,255,0.06);
  margin: 4px 0;
}

/* ── Dispatch sub-nav ───────────────────────────────────── */
#sn-dispatch-sub {
  position: fixed;
  top: 52px;
  left: 0;
  width: 100%;
  z-index: 8999;
  padding: 0 1.5rem;
  height: 38px;
  display: flex;
  align-items: center;
  background: rgba(10, 15, 26, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-family: 'Poppins', sans-serif;
}

.sn-sub-inner {
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.2rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.sn-sub-inner::-webkit-scrollbar { display: none; }

.sn-sub-link {
  font-size: 0.72rem;
  color: #94a3b8;
  text-decoration: none;
  padding: 0.25rem 0.55rem;
  border-radius: 5px;
  transition: color 0.2s, background 0.2s;
  white-space: nowrap;
}
.sn-sub-link:hover { color: #f8fafc; background: rgba(255,255,255,0.05); }
.sn-sub-link.active { color: #184A9E; font-weight: 600; background: rgba(24, 74, 158, 0.1); }

/* ── Body padding adjustment ────────────────────────────── */
body.sn-has-nav { padding-top: 52px !important; }
body.sn-has-subnav { padding-top: 90px !important; }

/* ── Change Password Modal ──────────────────────────────── */
.sn-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  font-family: 'Poppins', sans-serif;
}
.sn-modal-overlay.open { display: flex; }

.sn-modal {
  background: #1a2332;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}
.sn-modal h3 { color: #f8fafc; margin-bottom: 20px; font-size: 1.1rem; }
.sn-modal-field { margin-bottom: 16px; }
.sn-modal-field label { display: block; font-size: 0.8rem; color: #94a3b8; margin-bottom: 6px; }
.sn-modal-field input {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: #f8fafc;
  font-size: 0.9rem;
  font-family: 'Poppins', sans-serif;
  transition: border-color 0.2s;
}
.sn-modal-field input:focus { outline: none; border-color: #184A9E; }
.sn-modal-msg { font-size: 0.82rem; padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; display: none; }
.sn-modal-msg.error { background: rgba(239,68,68,0.1); color: #f87171; display: block; }
.sn-modal-msg.success { background: rgba(16,185,129,0.1); color: #34d399; display: block; }
.sn-modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.sn-modal-btn {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Poppins', sans-serif;
}
.sn-modal-btn.primary { background: #184A9E; color: #fff; }
.sn-modal-btn.primary:hover { background: #1a5ac8; }
.sn-modal-btn.secondary { background: rgba(255,255,255,0.06); color: #94a3b8; }
.sn-modal-btn.secondary:hover { background: rgba(255,255,255,0.1); color: #f8fafc; }

/* ── Hamburger toggle (hidden on desktop) ─────────────── */
.sn-hamburger {
  display: none;
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  line-height: 0;
  transition: color 0.2s;
}
.sn-hamburger:hover { color: #f8fafc; }
.sn-hamburger svg { display: block; }

/* ── Mobile menu overlay ──────────────────────────────── */
.sn-mobile-menu {
  display: none;
  position: fixed;
  top: 52px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 15, 26, 0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 8998;
  padding: 1rem;
  overflow-y: auto;
  font-family: 'Poppins', sans-serif;
}
.sn-mobile-menu.open { display: block; }

.sn-mobile-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.95rem;
  border-radius: 10px;
  transition: color 0.2s, background 0.2s;
}
.sn-mobile-link:hover { color: #f8fafc; background: rgba(255,255,255,0.05); }
.sn-mobile-link.active { color: #184A9E; font-weight: 600; background: rgba(24, 74, 158, 0.1); }

.sn-mobile-divider {
  height: 1px;
  background: rgba(255,255,255,0.06);
  margin: 0.5rem 0;
}

.sn-mobile-section-label {
  font-size: 0.68rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  padding: 0.75rem 1rem 0.25rem;
}

/* ── Dispatch sub-nav scroll indicator ────────────────── */
#sn-dispatch-sub { position: relative; }
#sn-dispatch-sub::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 40px;
  background: linear-gradient(to right, transparent, rgba(10, 15, 26, 0.88));
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.3s;
}
#sn-dispatch-sub.scrolled-end::after { opacity: 0; }

/* ── Mobile responsive ──────────────────────────────────── */
@media (max-width: 768px) {
  #shared-nav { padding: 0 0.75rem; }

  /* Hide desktop nav links, show hamburger */
  .sn-links { display: none; }
  .sn-hamburger { display: flex; }

  .sn-user-btn { padding: 0.25rem 0.5rem; font-size: 0.72rem; }
  .sn-user-icon { display: none; }
  .sn-user-name { display: none; }
  .sn-role-badge { display: none; }
  .sn-notif-dropdown { width: 280px; right: -40px; }
}

@media (max-width: 480px) {
  .sn-left { gap: 0.5rem; }
  .sn-logo { font-size: 0.95rem; }
  .sn-right { gap: 0.5rem; }
  .sn-user-dropdown { min-width: 180px; }
  #sn-dispatch-sub { padding: 0 0.75rem; }
  .sn-sub-link { font-size: 0.68rem; padding: 0.2rem 0.4rem; }
}
