/* ============================================
   WEBVIEW BOTTOM NAVIGATION MENU
   ============================================ */

/* Hide bottom nav on desktop unless in webview mode or on mobile/iPad */
.webview-bottom-nav {
  display: none !important;
}

body.webview-mode .webview-bottom-nav {
  display: block !important;
}

@media (max-width: 1024px) {
  .webview-bottom-nav {
    display: block !important;
  }
}

.webview-bottom-nav {
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  background: linear-gradient(180deg, rgba(10, 14, 39, 0.95) 0%, rgba(10, 14, 39, 0.98) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 9999 !important;
  padding-bottom: 0 !important;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
  /* Prevent menu from moving when scrolling */
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  will-change: transform;
  /* Remove any margins that could cause the menu to lift */
  margin-bottom: 0 !important;
  margin-top: 0 !important;
}

.webview-nav-container {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0.5rem 0.25rem;
  max-width: 100%;
  gap: 0.25rem;
}

/* Ensure AI button container doesn't stretch */
.webview-nav-container > .webview-nav-item-ai {
  flex: 0 0 auto !important;
}

.webview-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0; /* No gap since labels are hidden */
  padding: 0.75rem 0.5rem; /* More padding for better touch target */
  min-width: 60px;
  max-width: 80px;
  flex: 1;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  transition: all 0.2s ease;
  position: relative;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.webview-nav-item i {
  font-size: 1.4rem; /* Slightly larger since no labels */
  line-height: 1;
  transition: all 0.2s ease;
}

.webview-nav-label {
  display: none !important; /* Hide labels in webview - icons only */
  font-size: 0.65rem;
  font-weight: 500;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  transition: all 0.2s ease;
}

.webview-nav-item.active {
  color: #00d4aa;
  position: relative;
}

.webview-nav-item.active::before {
  content: '';
  position: absolute;
  bottom: -0.25rem;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  background: #00d4aa;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(0, 212, 170, 0.8);
}

.webview-nav-item.active i {
  color: #00d4aa;
  transform: scale(1.15);
  filter: drop-shadow(0 0 4px rgba(0, 212, 170, 0.6));
}

.webview-nav-item.active .webview-nav-label {
  color: #00d4aa;
  font-weight: 600;
}

.webview-nav-item:active {
  transform: scale(0.95);
  opacity: 0.8;
}

/* AI Agent item - button style to distinguish from navigation items */
.webview-nav-item-ai {
  background: linear-gradient(135deg, rgba(0, 212, 170, 0.12) 0%, rgba(0, 168, 255, 0.12) 100%);
  border-radius: 50% !important;
  border: 2px solid rgba(0, 212, 170, 0.25);
  width: 50px !important;
  height: 50px !important;
  min-width: 50px !important;
  max-width: 50px !important;
  min-height: 50px !important;
  max-height: 50px !important;
  padding: 0 !important;
  margin: 0 !important;
  box-shadow: 0 2px 8px rgba(0, 212, 170, 0.15);
  position: relative;
  overflow: visible;
  aspect-ratio: 1 / 1 !important; /* Ensure perfect circle */
  flex: 0 0 50px !important; /* Don't grow or shrink */
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.webview-nav-item-ai::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-radius: 50%;
  border: 1px solid rgba(0, 212, 170, 0.4);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.webview-nav-item-ai:hover::after,
.webview-nav-item-ai:active::after {
  opacity: 1;
}

.webview-nav-item-ai i {
  color: rgba(0, 212, 170, 0.7); /* Less bright than active, but more than inactive */
  font-size: 1.3rem;
}

.webview-nav-item-ai .webview-nav-label {
  display: none; /* Always hide label for AI button */
  color: rgba(255, 255, 255, 0.8);
}

.webview-nav-item-ai.active {
  background: linear-gradient(135deg, rgba(0, 212, 170, 0.25) 0%, rgba(0, 168, 255, 0.25) 100%);
  border-color: rgba(0, 212, 170, 0.5);
  box-shadow: 0 2px 12px rgba(0, 212, 170, 0.4);
}

/* Badges */
.webview-nav-badge {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  background: #ff6b6b;
  color: white;
  border-radius: 10px;
  min-width: 18px;
  height: 18px;
  font-size: 0.65rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.25rem;
  box-shadow: 0 2px 6px rgba(255, 107, 107, 0.4);
  line-height: 1;
  z-index: 10;
}

/* Badge positioning for circular AI button */
.webview-nav-item-ai .webview-nav-badge {
  top: -4px;
  right: -4px;
}

.webview-nav-badge-requests {
  background: #ff6b6b;
}

.webview-nav-badge-locked {
  background: #ffa726;
  color: #0a0e27;
  width: 18px;
  height: 18px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.webview-nav-badge-locked i {
  font-size: 0.7rem;
  color: #0a0e27;
}

/* Beta badge */
.webview-nav-badge-beta {
  position: absolute;
  top: 0.15rem;
  right: 0.15rem;
  background: linear-gradient(135deg, #a855f7 0%, #8b5cf6 100%);
  color: white;
  border-radius: 6px;
  min-width: 14px;
  height: 14px;
  font-size: 0.5rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.2rem;
  box-shadow: 0 2px 6px rgba(168, 85, 247, 0.4);
  line-height: 1;
  z-index: 10;
}

/* Add padding to main content to prevent overlap with bottom nav */
body.webview-mode #main-content {
  padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 1024px) {
  #main-content {
    padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  }
}

/* ============================================
   TABLET / IPAD ADJUSTMENTS
   ============================================ */

/* iPad Portrait (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
  .webview-nav-container {
    padding: 0.75rem 1rem;
    gap: 0.5rem;
    max-width: 600px;
    margin: 0 auto;
  }

  .webview-nav-item {
    min-width: 80px;
    max-width: 100px;
    padding: 0.75rem 1rem;
    gap: 0.35rem;
  }

  .webview-nav-item i {
    font-size: 1.5rem;
  }

  .webview-nav-label {
    font-size: 0.75rem;
  }

  .webview-nav-badge {
    min-width: 20px;
    height: 20px;
    font-size: 0.7rem;
    top: 0.35rem;
    right: 0.35rem;
  }

  body.webview-mode #main-content {
    padding-bottom: calc(85px + env(safe-area-inset-bottom, 0px));
  }
}

/* iPad Landscape (1024px - 1366px) */
@media (min-width: 1024px) and (max-width: 1366px) {
  .webview-nav-container {
    padding: 0.75rem 1.5rem;
    gap: 0.75rem;
    max-width: 800px;
    margin: 0 auto;
  }

  .webview-nav-item {
    min-width: 90px;
    max-width: 120px;
    padding: 0.75rem 1.25rem;
    gap: 0.4rem;
  }

  .webview-nav-item i {
    font-size: 1.6rem;
  }

  .webview-nav-label {
    font-size: 0.8rem;
  }

  .webview-nav-badge {
    min-width: 22px;
    height: 22px;
    font-size: 0.75rem;
    top: 0.4rem;
    right: 0.4rem;
  }

  body.webview-mode #main-content {
    padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  }
}

/* ============================================
   MOBILE SMALL (< 576px)
   ============================================ */

@media (max-width: 575px) {
  .webview-nav-container {
    padding: 0.4rem 0.15rem;
    gap: 0.15rem;
  }

  .webview-nav-item {
    min-width: 50px;
    max-width: 70px;
    padding: 0.4rem 0.5rem;
    gap: 0.2rem;
  }

  .webview-nav-item i {
    font-size: 1.1rem;
  }

  .webview-nav-label {
    font-size: 0.6rem;
  }

  .webview-nav-badge {
    min-width: 16px;
    height: 16px;
    font-size: 0.6rem;
    top: 0.2rem;
    right: 0.2rem;
    padding: 0 0.2rem;
  }

  .webview-nav-badge-locked {
    width: 16px;
    height: 16px;
  }

  .webview-nav-badge-locked i {
    font-size: 0.6rem;
  }

  body.webview-mode #main-content {
    padding-bottom: 0 !important;
    /* padding-bottom: calc(2px + env(safe-area-inset-bottom, 0px)); */
  }
}

/* ============================================
   DROP-UP MENU (Stock Market sub-menu)
   ============================================ */

.webview-nav-dropup {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.webview-nav-dropup-trigger {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0.75rem 0.5rem;
  min-width: 60px;
  max-width: 80px;
  width: 100%;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  transition: all 0.2s ease;
  position: relative;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.webview-nav-dropup-trigger i {
  font-size: 1.4rem;
  line-height: 1;
  transition: all 0.2s ease;
}

.webview-nav-dropup-trigger .webview-nav-label {
  display: none !important;
}

.webview-nav-dropup-trigger .webview-nav-badge {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
}

/* Active state for dropup trigger */
.webview-nav-dropup.active .webview-nav-dropup-trigger,
.webview-nav-dropup .webview-nav-item.active {
  color: #00d4aa;
}

.webview-nav-dropup.active .webview-nav-dropup-trigger i {
  color: #00d4aa;
  transform: scale(1.15);
  filter: drop-shadow(0 0 4px rgba(0, 212, 170, 0.6));
}

.webview-nav-dropup.active::before {
  content: '';
  position: absolute;
  bottom: -0.25rem;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  background: #00d4aa;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(0, 212, 170, 0.8);
}

/* Drop-up menu panel */
.webview-dropup-menu {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  transform: translateY(10px);
  background: linear-gradient(180deg, rgba(20, 25, 60, 0.98) 0%, rgba(15, 20, 50, 0.98) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 12px;
  padding: 0.5rem;
  min-width: 160px;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5), 0 0 1px rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  z-index: 10000;
}

.webview-dropup-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Drop-up menu items */
.webview-dropup-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.2s ease;
  position: relative;
}

.webview-dropup-item:hover,
.webview-dropup-item:active {
  background: rgba(0, 212, 170, 0.15);
  color: #00d4aa;
}

.webview-dropup-item.active {
  background: rgba(0, 212, 170, 0.1);
  color: #00d4aa;
}

.webview-dropup-item i {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}

.webview-dropup-item span {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
}

/* Badge in drop-up menu */
.webview-dropup-badge {
  background: #ff6b6b;
  color: white;
  border-radius: 10px;
  min-width: 18px;
  height: 18px;
  font-size: 0.65rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.25rem;
  margin-left: auto;
}

/* Small arrow pointing down from menu */
.webview-dropup-menu::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 20px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid rgba(20, 25, 60, 0.98);
}

/* Mobile adjustments */
@media (max-width: 575px) {
  .webview-nav-dropup-trigger {
    min-width: 50px;
    max-width: 70px;
    padding: 0.4rem 0.5rem;
  }

  .webview-nav-dropup-trigger i {
    font-size: 1.1rem;
  }

  .webview-dropup-menu {
    min-width: 140px;
    padding: 0.4rem;
  }

  .webview-dropup-item {
    padding: 0.6rem 0.75rem;
    gap: 0.5rem;
  }

  .webview-dropup-item i {
    font-size: 1rem;
  }

  .webview-dropup-item span {
    font-size: 0.85rem;
  }
}

/* ============================================
   HIDE CHATBOT TOGGLE BUTTON IN WEBVIEW MODE
   ============================================ */

.webview-mode .chatbot-widget-container .chatbot-toggle-btn {
  display: none !important;
}

/* Show chatbot window when opened from bottom nav */
.webview-mode .chatbot-window {
  z-index: 10001;
}

