/* ---------------------------------------------------
   TOP BAR
--------------------------------------------------- */
.top-bar {
  position: relative;
  flex: 0 0 70px;
  width: 100%;
  height: 70px;
  min-height: 56px;
  background: var(--theme-bg-top-bar);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 clamp(8px, 2vw, 16px);
  box-sizing: border-box;
  box-shadow: var(--theme-shadow-top-bar);
  border-bottom: 1px solid var(--theme-border-top-bar);
  z-index: 1001;
  flex-wrap: wrap;
  gap: 8px;
  align-content: center;
}

.top-bar h1 {
  color: var(--theme-text-heading);
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.top-search {
  flex: 1 1 200px;
  min-width: 0;
  max-width: min(380px, 100%);
  margin-left: auto;
  margin-right: 10px;
  position: relative;
  display: flex;
  align-items: center;
}

.header-search-input {
  width: 100%;
  padding-right: 34px;
  border-radius: 20px;
  background: var(--theme-bg-search-input);
  color: var(--theme-text-search-input);
  border: 1px solid var(--theme-border-search-input);
  box-sizing: border-box;
}

/* type=search adds a native clear control that overlaps our magnifying-glass icon */
.header-search-input::-webkit-search-cancel-button,
.header-search-input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

.header-search-input::-moz-search-clear {
  display: none;
}

.header-search-input::placeholder {
  color: var(--theme-text-search-placeholder);
}

.header-search-trailing {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.header-search-trailing-mag {
  font-size: 16px;
  color: var(--theme-text-icon-header);
}

.top-search.has-search-text .header-search-trailing-mag {
  display: none;
}

.header-search-clear-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--theme-text-icon-header);
  cursor: pointer;
  pointer-events: auto;
  font-size: 14px;
}

.top-search.has-search-text .header-search-clear-btn {
  display: flex;
}

.header-search-clear-btn:hover,
.header-search-clear-btn:focus-visible {
  background: var(--theme-bg-icon-hover);
  color: var(--theme-text-icon-hover);
  outline: none;
}

.header-search-results {
  position: absolute;
  top: 110%;
  left: 0;
  right: 0;
  background: var(--theme-bg-popover);
  border-radius: 8px;
  border: 1px solid var(--theme-border-default);
  box-shadow: var(--theme-shadow-popover);
  padding: 0;
  max-height: 0;
  overflow: hidden;
  margin-top: 4px;
  z-index: 1100;
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, max-height 0.2s ease, padding 0.2s ease;
}

.header-search-results.visible {
  padding: 8px;
  max-height: 300px;
  overflow-y: auto;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.nav-icons {
  display: flex;
  gap: 15px;
}

.header-signup-btn {
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--theme-border-signup);
  background: linear-gradient(
    180deg,
    var(--theme-gradient-signup-start),
    var(--theme-gradient-signup-end)
  );
  color: var(--theme-accent-on-accent);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  cursor: pointer;
  transition: filter 0.2s ease, transform 0.1s ease;
}

.header-signup-btn:hover,
.header-signup-btn:focus {
  filter: brightness(1.07);
  outline: none;
}

.header-signup-btn:active {
  transform: translateY(1px);
}

.icon {
  position: relative;
  background: transparent;
  border: none;
  padding: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--theme-text-icon);
  transition: all 0.2s ease;
}

.profile-notification-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--theme-bg-badge-danger);
  color: var(--theme-text-badge);
  font-size: 10px;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--theme-ring-badge);
}

.icon i {
  font-size: 18px;
}

.icon:hover,
.icon:focus {
  color: var(--theme-text-icon-hover);
  background: var(--theme-bg-icon-hover);
  outline: none;
}

.icon img {
  width: 28px;
  height: 28px;
  cursor: pointer;
}

.notification-toast-container {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: 90px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1500;
}

@media (max-width: 767.98px) {
  .notification-toast-container {
    left: max(12px, env(safe-area-inset-left, 0px));
    right: max(12px, env(safe-area-inset-right, 0px));
    width: auto;
    bottom: calc(78px + env(safe-area-inset-bottom, 0px));
  }
}

.notification-toast {
  min-width: 260px;
  max-width: 340px;
  background: var(--theme-bg-toast);
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: var(--theme-shadow-toast);
  border: 1px solid var(--theme-border-toast);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.notification-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.notification-toast-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--theme-text-toast-title);
  margin-bottom: 4px;
}

.notification-toast-body {
  font-size: 0.85rem;
  color: var(--theme-text-toast-body);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-logo {
  width: 60px;   /* adjust based on your design */
  height: 60px;
  object-fit: contain;
}

.brand h1 {
  margin: 0;
  font-size: 30px;
}

/* Group header rows on mobile; flattened on desktop via display: contents */
.top-bar-top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.top-bar-search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .top-bar-top,
  .top-bar-search-row,
  .top-bar-actions {
    display: contents;
  }
}

/* ---------------------------------------------------
   BOTTOM NAV
--------------------------------------------------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: calc(70px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-sizing: border-box;
  /* Above scrolling content + footer (.main-footer); below toasts (1500) and modals (10k+) */
  z-index: 1030;
  background: var(--theme-bg-nav);
  border-top: 1px solid var(--theme-border-nav);
  display: flex;
  justify-content: space-around;
  align-items: center;
  box-shadow: var(--theme-shadow-nav);
}

.nav-item {
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: inherit;
  padding: 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--theme-text-nav);
  cursor: pointer;
  transition: all 0.3s ease;
  opacity: 0.8;
  width: 100%;
  height: 100%;
  justify-content: center;
}

.nav-item:hover, .nav-item:focus {
  opacity: 1;
  color: var(--theme-text-heading);
  background: var(--theme-bg-nav-hover);
  outline: none;
}

.nav-item img {
  width: 22px; /* Smaller icon */
  height: 22px;
  margin-bottom: 3px; /* Tighter spacing */
  filter: brightness(0.8) contrast(1.2);
  transition: all 0.2s ease;
}

.nav-item span {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.5px;
}

@media (max-width: 767.98px) {
  .bottom-nav .nav-item span {
    font-size: 0.62rem;
    letter-spacing: 0.2px;
    line-height: 1.15;
    text-align: center;
    max-width: 64px;
  }
}

.nav-item.active, 
.nav-item[aria-selected="true"] {
  opacity: 1;
  color: var(--theme-text-nav-active);
}

.nav-item.active span {
  font-weight: 600;
  color: var(--theme-text-nav-active);
}

.nav-item.active img {
  filter: drop-shadow(0 0 6px rgba(75, 156, 211, 0.5)) brightness(1.2);
  transform: translateY(-2px);
}

/* Ripple effect */
.nav-item:active {
  background: var(--theme-bg-nav-active);
}

/* ---------------------------------------------------
   TAB CONTENT
--------------------------------------------------- */
.tab-content {
  display: flex;
  flex-direction: column;
  width: 100%;
  box-sizing: border-box;
  padding-bottom: 20px;
  padding-top: 20px;
  padding-left: clamp(12px, 4vw, 24px);
  padding-right: clamp(12px, 4vw, 24px);
  flex: 1;
  min-width: 0;
}

/* ---------------------------------------------------
   FOOTER
--------------------------------------------------- */
.main-footer {
  background-color: var(--theme-bg-nav);
  border-top: 1px solid var(--theme-border-nav);
  flex: 0 0 auto;
  padding: 32px clamp(12px, 4vw, 24px) 100px; /* Match .tab-content gutters; bottom clears fixed nav */
  margin-top: auto;
  color: var(--theme-text-footer);
  box-shadow: var(--theme-shadow-footer);
  font-size: 0.9rem;
  /* In-flow footer must not stack above fixed .bottom-nav (phones) */
  position: relative;
  z-index: 0;
}

.footer-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(20px, 4vw, 36px);
  align-items: start;
}

@media (min-width: 600px) {
  .footer-container {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 960px) {
  .footer-container {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    column-gap: clamp(24px, 4vw, 48px);
  }
}

.footer-section {
  min-width: 0;
}

.footer-section h4 {
  color: var(--theme-text-footer-heading);
  font-size: 1rem;
  margin: 0 0 15px 0;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.footer-section p {
  margin: 0;
  line-height: 1.6;
}

.footer-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-section ul li {
  margin-bottom: 8px;
}

.footer-section a {
  color: var(--theme-text-footer);
  text-decoration: none;
  transition: all 0.2s ease;
}

.footer-section a:hover {
  color: var(--theme-accent-primary);
  padding-left: 5px;
}

.social-links {
  display: flex;
  gap: 15px;
}

.social-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--theme-bg-social);
  border-radius: 50%;
  color: var(--theme-text-social);
  transition: all 0.3s ease;
}

.social-links a:hover {
  background: var(--theme-accent-primary);
  color: #fff;
  transform: translateY(-3px);
  padding-left: 0; /* Reset hover shift from generic link rule */
}

.social-links a.footer-social-link--inactive {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

.social-links a.footer-social-link--inactive:hover {
  background: var(--theme-bg-social);
  color: var(--theme-text-social);
  transform: none;
}

/* Phones: single-row header — brand left; search + settings + profile flush right */
@media (max-width: 767.98px) {
  .top-bar {
    flex: 0 0 auto;
    height: auto;
    min-height: calc(52px + env(safe-area-inset-top, 0px));
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    align-content: center;
    justify-content: flex-start;
    gap: 6px;
    padding-top: max(6px, env(safe-area-inset-top, 0px));
    padding-bottom: 6px;
    padding-left: max(8px, env(safe-area-inset-left, 0px));
    padding-right: max(8px, env(safe-area-inset-right, 0px));
  }

  .top-bar-top {
    flex: 0 1 auto;
    min-width: 0;
    max-width: min(38vw, 160px);
    justify-content: flex-start;
  }

  .top-bar-search-row {
    flex: 0 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    width: auto;
    margin-left: auto;
  }

  .top-search {
    flex: 0 1 auto;
    min-width: 0;
    max-width: min(200px, calc(100vw - 140px));
    margin-left: 0;
    margin-right: 0;
  }

  /* Sign up remains in profile / auth flows */
  .header-signup-btn {
    display: none;
  }

  .top-bar-actions {
    flex-shrink: 0;
    gap: 2px;
  }

  .nav-icons {
    gap: 2px;
    margin-left: 0;
  }

  .icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
  }

  .icon i {
    font-size: 16px;
  }

  .brand-logo {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
  }

  .top-bar h1 {
    font-size: 0.78rem;
    line-height: 1.15;
    letter-spacing: -0.02em;
    max-width: 11em;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-search-input {
    padding: 6px 28px 6px 8px;
    font-size: 0.75rem;
    line-height: 1.25;
    min-height: 34px;
    border-radius: 999px;
  }

  .header-search-trailing-mag {
    font-size: 13px;
  }

  .header-search-clear-btn {
    font-size: 13px;
  }
}

/* Fixed bottom nav (70px) — pad scroll area so tab content never sits under the bar */
@media (max-width: 767.98px) {
  #main-content {
    scroll-padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  }

  .tab-content {
    padding-bottom: calc(70px + 24px + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 600px) {
  .tab-content {
    padding-left: 12px;
    padding-right: 12px;
  }

  .footer-container {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .social-links {
    justify-content: center;
  }

  .footer-section a:hover {
    padding-left: 0;
  }
}

/* Very narrow phones: logo-first title strip */
@media (max-width: 380px) {
  .top-bar-top {
    max-width: min(40vw, 160px);
  }

  .top-bar h1 {
    font-size: 0.72rem;
    max-width: 9em;
  }

  .top-search {
    max-width: min(120px, 36vw);
  }
}

/* ---------------------------------------------------
   DESKTOP SIDEBAR (Responsive)
--------------------------------------------------- */
@media (min-width: 768px) {
  .top-bar {
    padding: 0 10px;
  }

  /* Transform Bottom Nav to Sidebar */
  .bottom-nav {
    top: 70px; /* Below top bar */
    left: 0;
    bottom: 0;
    width: 36px; /* Collapsed width (Icon 20px + Padding 25px*2) */
    height: calc(100% - 70px);
    padding-bottom: 0;
    flex-direction: column;
    justify-content: flex-start;
    border-top: none;
    border-right: 1px solid var(--theme-border-nav);
    padding-top: 0;
    align-items: stretch;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2);
    /* Below .top-bar (1100) and .main-footer (1040) so header/footer span edge-to-edge above the rail */
    z-index: 1020;
    
    /* Animation & Layout */
    transition: width 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    overflow-x: hidden;
    overflow-y: auto;
    white-space: nowrap; /* Prevent wrapping during transition */
    
    /* Scrollbar Styling */
    scrollbar-width: thin;
    scrollbar-color: rgba(136, 146, 176, 0.3) transparent;
  }

  /* Expand on Hover */
  .bottom-nav:hover {
    width: 280px; /* Expanded width to fit long labels */
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.4);
  }

  /* Hide scrollbar when collapsed to maintain clean look */
  .bottom-nav:not(:hover)::-webkit-scrollbar {
    display: none;
  }
  
  .bottom-nav::-webkit-scrollbar {
    width: 5px;
  }
  .bottom-nav::-webkit-scrollbar-track {
    background: transparent;
  }
  .bottom-nav::-webkit-scrollbar-thumb {
    background: rgba(136, 146, 176, 0.3);
    border-radius: 4px;
  }

  .nav-item {
    flex-direction: row;
    height: auto;
    min-height: 50px;
    padding: 2px 0px 0px 0px;
    justify-content: flex-start;
    gap: 15px;
    border-left: 8px solid transparent;
    width: auto;
    transition: background 0.2s ease, transform 0.2s ease;
  }

  .nav-item:hover, .nav-item:focus {
    background: var(--theme-bg-nav-hover-strong);
    /* No translation on hover to keep alignment steady during expand */
  }

  .nav-item.active, 
  .nav-item[aria-selected="true"] {
    background: var(--theme-bg-nav-active);
    color: var(--theme-text-nav-active);
  }

  .nav-item img,
  .nav-item i {
    margin-bottom: 0;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    font-size: 15px; /* For icons */
    text-align: center;
    line-height: 20px; /* Center vertically */
  }

  /* Text Label Animation */
  .nav-item span {
    font-size: 0.9rem;
    opacity: 0; /* Hidden by default */
    transform: translateX(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    transition-delay: 0s;
  }

  .bottom-nav:hover .nav-item span {
    opacity: 1;
    transform: translateX(0);
    transition-delay: 0.1s; /* Slight delay for smoothness */
  }

  .nav-item:active {
    transform: scale(0.99);
  }

  /* Adjust Content Area to Collapsed Width */
  .tab-content {
    margin-left: 36px;
    width: auto;
    padding-bottom: 40px;
  }

  /* Full-width footer band: extend background into the left margin under the sidebar rail.
     margin-left -36px shifts the band left; width must be 100vw + 36px or a 36px gap remains on the right. */
  .main-footer {
    margin-left: -36px;
    width: calc(100vw + 36px);
    max-width: none;
    padding: 32px clamp(12px, 4vw, 24px) 40px calc(36px + clamp(12px, 4vw, 24px));
    box-sizing: border-box;
    position: relative;
    z-index: 1040;
  }
}

/* ---------------------------------------------------
   SEARCH MODAL
--------------------------------------------------- */
.search-modal-content {
  width: 90%;
  max-width: 500px;
  text-align: left;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.search-results-list {
  margin-top: 15px;
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-result-item {
  background: var(--theme-bg-surface);
  padding: 10px;
  border-radius: 6px;
  border: 1px solid var(--theme-border-default);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  transition: background 0.2s;
}

.search-result-item:hover {
  background: var(--theme-bg-search-result-hover);
  border-color: var(--theme-border-search-result-hover);
}

.search-result-info {
  flex: 1;
  min-width: 0;
}

.search-result-info h4 {
  margin: 0;
  color: var(--theme-text-search-result-title);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.search-result-meta-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 10px;
  margin-top: 5px;
}

.search-result-path {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--theme-text-search-result-meta);
}

.search-result-dest {
  flex-shrink: 0;
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0;
  line-height: 1.2;
  white-space: nowrap;
}

.search-result-dest--pa {
  color: var(--theme-accent-primary);
}

.search-result-dest--trends {
  color: var(--theme-text-muted);
}

.search-result-arrow {
  color: var(--theme-accent-primary);
  font-weight: bold;
  flex-shrink: 0;
  margin-left: 4px;
  align-self: center;
  line-height: 1;
}
