/* ═══════════════════════════════════════════════════════════
   TTDX Nav — Premium Trustable · Sapphire & Slate
   ═══════════════════════════════════════════════════════════ */

:root {
  --nav-h: 52px;
  --nav-h-mob: 52px;

  --blue: #005cbf;
  --blue-hover: #004a99;
  --blue-soft: #f0f4f8;
  --slate: #475569;
  --slate-dark: #1e293b;

  --bg: rgba(251, 251, 253, 0.72);
  --surface: #ffffff;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --border: rgba(0, 0, 0, 0.06);

  --brand: var(--blue);
  --brand-d: #004a99;
  --brand-pale: var(--blue-soft);
  --brand-accent: var(--slate);
  --txt: var(--text);
  --txt-mid: var(--text);
  --txt-muted: var(--text-secondary);

  --shadow-nav: 0 4px 24px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-drop: 0 20px 48px rgba(0, 0, 0, 0.12), 0 8px 16px rgba(0, 0, 0, 0.06);
  --shadow-srch: 0 20px 48px rgba(0, 0, 0, 0.12), 0 8px 16px rgba(0, 0, 0, 0.06);
  --pill: 980px;
  --drop-r: 14px;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', sans-serif;
  --success: #34c759;
  --error: #ff3b30;
}

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

.ttdx-nav a { text-decoration: none; }
.ttdx-nav ul { list-style: none; margin: 0; padding: 0; }

.ttdx-nav {
  position: sticky;
  top: 0;
  z-index: 500;
  background: var(--bg);
  backdrop-filter: saturate(200%) blur(24px);
  -webkit-backdrop-filter: saturate(200%) blur(24px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-nav);
  font-family: var(--font);
}

.nav-inner {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.nav-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

/* Logo */
.nav-logo-desktop {
  display: inline-flex;
  align-items: baseline;
  flex-shrink: 0;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.05em;
  background: linear-gradient(135deg, var(--slate-dark) 0%, var(--blue) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  transition: transform 0.2s var(--ease), opacity 0.2s;
}

.nav-logo-desktop:hover {
  transform: scale(1.02);
  opacity: 0.9;
}

.nav-logo-mobile {
  display: none;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.2);
}

.nav-logo-mobile img { width: 100%; height: 100%; display: block; }

/* Search */
.nav-search-wrapper {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  z-index: 10;
}

.nav-search-input {
  width: 100%;
  height: 38px;
  padding: 0 72px 0 36px;
  border-radius: var(--pill);
  border: 1px solid rgba(0, 0, 0, 0.04);
  background: rgba(0, 0, 0, 0.04);
  outline: none;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.nav-search-input::placeholder {
  color: var(--text-tertiary);
}

.nav-search-input:focus {
  background: var(--surface);
  border-color: rgba(0, 113, 227, 0.35);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
}

.nav-search-wrapper::before {
  content: '\f002';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  font-size: 12px;
  pointer-events: none;
}

.nav-search-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  padding: 0;
  font-size: 12px;
  transition: color 0.15s;
}

.nav-search-btn:hover { color: var(--blue); }

.nav-search-clear {
  position: absolute;
  right: 36px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.08);
  border: none;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-secondary);
  transition: background 0.14s;
}

.nav-search-clear:hover { background: rgba(0, 0, 0, 0.14); }
.nav-search-wrapper.has-text .nav-search-clear { display: flex; }

/* Search dropdown */
.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--drop-r);
  box-shadow: var(--shadow-srch);
  overflow: hidden;
  z-index: 600;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 0.2s var(--ease-out), transform 0.2s var(--ease-out);
  min-width: 320px;
  max-height: 58vh;
  overflow-y: auto;
}

.search-dropdown.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

.sd-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 16px 6px;
}

.sd-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  text-decoration: none;
  color: inherit;
  transition: background 0.12s;
  border-bottom: 1px solid var(--border);
}

.sd-item:last-of-type { border-bottom: none; }
.sd-item:hover,
.sd-item.focused { background: var(--blue-soft); }
.sd-item:hover .sd-title,
.sd-item.focused .sd-title { color: var(--blue); }

.sd-thumb {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.sd-thumb img { width: 100%; height: 100%; object-fit: cover; }

.sd-body { flex: 1; min-width: 0; }

.sd-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.sd-title mark {
  background: rgba(0, 113, 227, 0.12);
  color: var(--blue);
  border-radius: 3px;
  padding: 0 2px;
  font-style: normal;
}

.sd-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-tertiary);
}

.sd-meta-dot {
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
}

.sd-badge-new {
  font-size: 10px;
  font-weight: 600;
  background: rgba(52, 199, 89, 0.12);
  color: var(--success);
  padding: 2px 7px;
  border-radius: var(--pill);
}

.sd-badge-used {
  font-size: 10px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-secondary);
  padding: 2px 7px;
  border-radius: var(--pill);
}

.sd-price {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.sd-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sd-see-all {
  font-size: 13px;
  font-weight: 500;
  color: var(--blue);
  text-decoration: none;
}

.sd-see-all:hover { opacity: 0.75; }
.sd-kbd { font-size: 11px; color: var(--text-tertiary); }
.sd-loading { padding: 24px; text-align: center; }

.sd-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(0, 113, 227, 0.12);
  border-top-color: var(--blue);
  animation: navSpin 0.6s linear infinite;
  display: inline-block;
}

@keyframes navSpin { to { transform: rotate(360deg); } }

.sd-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
}

.sd-empty-ico { font-size: 24px; margin-bottom: 8px; opacity: 0.5; }

/* Premium Buttons */
.nav-btn-premium {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--pill);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  background: linear-gradient(135deg, var(--slate-dark) 0%, var(--blue) 100%);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), filter 0.2s;
  white-space: nowrap;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.nav-btn-premium:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 14px rgba(0, 92, 191, 0.25);
  filter: brightness(1.1);
}

.nav-btn-premium:active { transform: scale(0.98); }

.nav-btn-login {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  color: var(--text-secondary);
  background: transparent;
  border-radius: var(--pill);
  border: none;
  cursor: pointer;
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
  letter-spacing: -0.01em;
  text-decoration: none;
}

.nav-btn-login:hover {
  color: var(--blue);
  background: rgba(0, 113, 227, 0.08);
}

/* Icon buttons */
.nav-icon-wrap { position: relative; }

.nav-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid rgba(0, 0, 0, 0.04);
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
}

.nav-icon-btn:hover {
  background: var(--surface);
  border-color: rgba(0, 113, 227, 0.2);
  box-shadow: 0 4px 12px rgba(0, 113, 227, 0.12);
  transform: scale(1.08) translateY(-1px);
}

.nav-icon-btn i {
  transition: color 0.2s var(--ease);
}

.nav-icon-btn:hover i {
  background: linear-gradient(135deg, var(--slate-dark) 0%, var(--blue) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nav-icon-btn.has-items { color: var(--blue); }

.nav-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--pink);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  border-radius: var(--pill);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--surface);
  pointer-events: none;
}

/* Profile Trigger */
.profile-trigger {
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.08);
}
.profile-trigger img { width: 100%; height: 100%; object-fit: cover; }
.profile-trigger .chip-av-txt {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  background: linear-gradient(135deg, var(--blue-soft), var(--pink-soft));
  color: var(--blue);
}

/* Dropdowns */
.nav-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--drop-r);
  box-shadow: var(--shadow-drop);
  z-index: 1000;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 0.2s var(--ease-out), transform 0.2s var(--ease-out);
}

.nav-dropdown.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

.profile-dropdown { right: 0; width: 240px; padding: 6px; }

.pdrop-hd {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.pdrop-av {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-soft), var(--pink-soft));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--blue);
  flex-shrink: 0;
  overflow: hidden;
}

.pdrop-av img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.pdrop-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.pdrop-plan { font-size: 11px; color: var(--text-tertiary); }

.pdrop-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  transition: background 0.12s;
  letter-spacing: -0.01em;
}

.pdrop-link i {
  width: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-tertiary);
}

.pdrop-link:hover {
  background: var(--blue-soft);
  color: var(--blue);
}

.pdrop-link:hover i { color: var(--blue); }
.pdrop-link.logout { color: var(--error); }
.pdrop-link.logout i { color: var(--error); }
.pdrop-link.logout:hover { background: #fff0f0; }

.pdrop-div {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.chat-dropdown { right: 0; width: 320px; }

.cdrop-hd {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.cdrop-hd h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.cdrop-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: background 0.12s;
}

.cdrop-item:last-of-type { border-bottom: none; }
.cdrop-item:hover { background: rgba(0, 0, 0, 0.02); }

.cdrop-item.unread {
  background: var(--blue-soft);
  border-left: 2px solid var(--blue);
}

.cdrop-thumb {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.cdrop-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cdrop-body { flex: 1; min-width: 0; }

.cdrop-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cdrop-preview {
  font-size: 11px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cdrop-time { font-size: 10px; color: var(--text-tertiary); margin-top: 2px; }

.cdrop-udot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--pink);
  flex-shrink: 0;
  margin-top: 4px;
}

.cdrop-empty {
  text-align: center;
  padding: 28px;
  color: var(--text-tertiary);
  font-size: 13px;
}

.cdrop-empty i { font-size: 20px; margin-bottom: 8px; display: block; opacity: 0.35; }

.cdrop-foot {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 16px; font-size: 12px; font-weight: 600;
  color: var(--blue); text-decoration: none;
  border-top: 1px solid var(--border);
  transition: background 0.12s;
}
.cdrop-foot:hover { background: var(--blue-soft); }

/* Payment indicator */
.npi-wrap { display: flex; align-items: center; }

.nav-pay-ind {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  white-space: nowrap;
  font-family: var(--font);
  border-radius: var(--pill);
}

.npi-wrap.dismissable .nav-pay-ind { border-radius: var(--pill) 0 0 var(--pill); }

.nav-pay-ind.npi-pending {
  background: rgba(255, 149, 0, 0.1);
  color: #c93400;
  border-color: rgba(255, 149, 0, 0.2);
}

.nav-pay-ind.npi-approved {
  background: rgba(52, 199, 89, 0.1);
  color: #248a3d;
  border-color: rgba(52, 199, 89, 0.2);
}

.nav-pay-ind.npi-rejected {
  background: rgba(255, 59, 48, 0.1);
  color: var(--error);
  border-color: rgba(255, 59, 48, 0.2);
}

.npi-dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.npi-pending .npi-dot { background: #ff9500; }
.npi-approved .npi-dot { background: var(--success); }
.npi-rejected .npi-dot { background: var(--error); }

.npi-dis {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  border-radius: 0 var(--pill) var(--pill) 0;
  border: 1px solid var(--border);
  border-left: none;
  background: rgba(0, 0, 0, 0.03);
  cursor: pointer;
  font-size: 9px;
  color: var(--text-tertiary);
  min-height: 26px;
  padding: 0;
}

/* Mobile */
@media (max-width: 768px) {
  .nav-links,
  .nav-logo-desktop,
  .nav-btn-premium,
  .nav-btn-login { display: none !important; }

  .nav-logo-mobile { display: block; }

  .nav-inner {
    height: var(--nav-h-mob);
    padding: 0 14px;
    gap: 10px;
  }

  .nav-actions { margin-left: 0; gap: 0; }

  .nav-search-wrapper {
    position: relative;
    left: auto;
    transform: none;
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
  }

  .nav-search-input {
    height: 36px;
    font-size: 14px;
    padding-left: 34px;
  }

  .nav-search-wrapper::before { left: 12px; font-size: 11px; }
  .nav-search-btn { display: none; }

  .search-dropdown {
    min-width: unset;
    left: -14px;
    right: -14px;
    border-radius: 0 0 14px 14px;
    max-height: 50vh;
  }

  .npi-label { display: none; }

  .nav-icon-btn {
    width: 36px;
    height: 36px;
    font-size: 17px;
  }

  .chip-info,
  .chip-chev { display: none; }

  .profile-chip {
    padding: 3px;
    background: transparent;
    border-color: transparent;
  }

  .profile-chip:hover { background: rgba(0, 0, 0, 0.04); }

  .chat-dropdown { width: min(300px, calc(100vw - 20px)); right: -4px; }
  .profile-dropdown { width: min(220px, calc(100vw - 20px)); right: 0; }

  #profileChipWrap .profile-trigger { display: none; }

  #mbProfileTrigger {
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    width: 100%;
  }

  .profile-dropdown {
    position: fixed;
    bottom: calc(64px + 8px);
    right: 12px;
    left: auto;
    top: auto;
    width: min(200px, calc(100vw - 24px));
    z-index: 800;
    border-radius: 16px;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.12), 0 8px 40px rgba(0,0,0,0.10);
    transform: translateY(6px);
    overflow: visible;
  }

  .profile-dropdown.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: all;
  }

  #mbProfileTrigger {
    -webkit-tap-highlight-color: rgba(0,113,227,0.15);
    touch-action: manipulation;
  }
}

@media (min-width: 769px) {
  .nav-logo-mobile { display: none; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .nav-search-wrapper { max-width: 260px; }
  .nav-links a { padding: 6px 8px; font-size: 12px; }
}

/* Bottom nav */
.mobile-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 700;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: rgba(251, 251, 253, 0.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--border);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}

.mb-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 2px;
  min-height: 44px;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-tertiary);
  text-decoration: none;
  border-radius: 10px;
  transition: color 0.2s;
  position: relative;
  letter-spacing: -0.01em;
}

.mb-nav-item i { font-size: 18px; }
.mb-nav-item.active { color: var(--blue); }

.mb-nav-item:nth-child(3) {
  background: var(--blue);
  color: #fff;
  border-radius: 14px;
  margin: -8px 4px 0;
  min-height: 48px;
  box-shadow: 0 4px 16px rgba(0, 113, 227, 0.3);
}

.mb-nav-item:nth-child(3).active { color: #fff; }
.mb-nav-item:nth-child(3) i { font-size: 19px; }

@media (min-width: 769px) {
  .mobile-bottom-nav { display: none; }
}

@media (max-width: 768px) {
  body { padding-bottom: 64px; }
}
