/* Responsive overrides, floating actions, chat widget, and lead capture UI. */
/* Responsive Mobile Layout */
.menu-btn {
  font-size: 1.5rem;
  width: 40px;
  height: 40px;
  justify-content: center;
  align-items: center;
  border: none;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  color: var(--text);
  padding: 0;
  display: flex;
  cursor: pointer;
}

.mobile-app-title,
.mobile-bottom-nav {
  display: none;
}

.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 999;
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s;
}

@media (max-width: 1024px) {
  .mobile-overlay.show {
    display: block;
    opacity: 1;
  }

  .sidebar {
    position: fixed;
    left: -320px;
    top: 0;
    bottom: 0;
    margin-left: 0 !important;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
  }

  .sidebar.show {
    left: 0;
  }

  .header {
    height: 58px;
    flex-wrap: nowrap;
    padding: 0 12px;
    gap: 10px;
    justify-content: flex-start;
    position: sticky;
    top: 0;
    z-index: 30;
    background: color-mix(in srgb, var(--surface-solid) 92%, transparent);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
  }

  .header .menu-btn {
    order: 1;
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 14px;
  }

  .mobile-app-title {
    order: 2;
    min-width: 0;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    justify-content: center;
    line-height: 1.05;
  }

  .mobile-app-title span {
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .mobile-app-title strong {
    color: var(--text);
    font-size: 1rem;
    font-weight: 850;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .header-nav {
    display: none;
  }

  .header-nav::-webkit-scrollbar {
    display: none;
  }

  .nav-link {
    font-size: 0.8rem;
    padding: 6px 10px;
  }

  .nav-link svg {
    display: none;
  }

  .header-right {
    order: 3;
    flex-shrink: 0;
    gap: 8px;
  }

  .header-stats {
    display: none;
  }

  .live-scan {
    display: none;
  }

  .user-menu-trigger {
    max-width: 44px;
    min-width: 44px;
    width: 44px;
    height: 42px;
    padding: 0;
    border-radius: 14px;
    justify-content: center;
    overflow: hidden;
  }

  .user-menu-trigger span:not(.user-avatar) {
    display: none;
  }

  .btn-auth-cta {
    min-height: 42px;
    padding: 0 12px;
    border-radius: 14px;
    font-size: 0.78rem;
    white-space: nowrap;
  }

  .header-icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 14px;
  }

  .content {
    padding: 12px 12px calc(86px + env(safe-area-inset-bottom));
  }

  .cards-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .insights-wrap {
    grid-template-columns: 1fr;
  }

  .market-indicator-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .market-indicator-table {
    min-width: 680px;
  }

  .sort-bar {
    gap: 8px;
  }

  .sort-label {
    display: none;
  }

  .sort-pill {
    padding: 6px 12px;
    font-size: 0.75rem;
  }

  .command-bar {
    position: sticky;
    top: 0;
    z-index: 12;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin: -2px -2px 12px;
    padding: 8px;
    border-radius: 16px;
    min-height: 56px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .command-bar::-webkit-scrollbar {
    display: none;
  }

  .command-bar-left {
    width: auto;
    flex: 1 0 auto;
    flex-wrap: nowrap;
    gap: 8px;
  }

  .command-bar-right {
    width: auto;
    margin-left: 0;
    justify-content: flex-start;
    flex: 0 0 auto;
  }

  .command-super-signal.super-signal-btn {
    min-width: 0;
    width: 100%;
  }

  .command-mos {
    min-width: 0;
    width: 190px;
    max-width: 190px;
    flex: 0 0 190px;
    gap: 5px;
  }

  .command-mos-label {
    font-size: 0.7rem;
  }

  .command-mos-track #mosSlider {
    height: 5px;
  }

  .command-mos-markers {
    display: none;
  }

  .command-drop-toggle span {
    min-width: 0;
    padding: 9px 11px;
    font-size: 0.68rem;
  }

  .command-sort {
    width: auto;
    justify-content: space-between;
    gap: 6px;
  }

  .command-sort-label {
    display: none;
  }

  .command-sort-select {
    flex: 0 0 auto;
    width: 136px;
    min-width: 0;
    padding: 9px 28px 9px 10px;
    border-radius: 12px;
    font-size: 0.72rem;
  }

  .chart-container {
    height: 350px;
    padding: 16px;
    margin-bottom: 24px;
  }

  .section-title {
    font-size: 1.2rem;
  }

  .table-wrap {
    border-radius: 12px;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  th,
  td {
    padding: 12px 16px;
  }
}

@media (max-width: 1024px) {
  .mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 998;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 7px 12px calc(7px + env(safe-area-inset-bottom));
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-bottom: 0;
    border-radius: 22px 22px 0 0;
    background: color-mix(in srgb, var(--surface-solid) 92%, transparent);
    box-shadow: 0 -12px 42px rgba(15, 23, 42, 0.18);
    backdrop-filter: blur(18px);
  }

  .mobile-bottom-nav:has(.bottom-nav-item:nth-child(4)) {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .bottom-nav-item {
    position: relative;
    min-width: 0;
    min-height: 56px;
    border: 0;
    border-radius: 17px;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 0.68rem;
    font-weight: 800;
    cursor: pointer;
    touch-action: manipulation;
  }

  .bottom-nav-item svg {
    flex: 0 0 auto;
  }

  .bottom-nav-item span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .bottom-nav-item small {
    position: absolute;
    top: 5px;
    right: 14%;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.18);
    color: var(--text-muted);
    font-size: 0.62rem;
    line-height: 18px;
    font-weight: 850;
  }

  .bottom-nav-item.active {
    background: rgba(99, 102, 241, 0.13);
    color: var(--primary);
  }

  .bottom-nav-item.active small {
    background: var(--primary);
    color: #fff;
  }
}

/* Floating Buttons */
.floating-actions {
  position: fixed;
  bottom: 32px;
  right: 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 1000;
}

@media (max-width: 1024px) {
  .floating-actions {
    right: 14px;
    bottom: calc(82px + env(safe-area-inset-bottom));
    z-index: 997;
  }

  .fab {
    width: 52px;
    height: 52px;
    font-size: 20px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.28);
  }

  .fab::after {
    display: none;
  }

  body.chat-open .floating-actions {
    display: none;
  }
}

.fab {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border: none;
  text-decoration: none;
  font-size: 28px;
  position: relative;
}

.fab:hover {
  transform: scale(1.15) rotate(5deg);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.fab:active {
  transform: scale(0.95);
}

.fab-ai {
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  animation: pulse-ai 2s infinite;
}

/* Pulsing Animations */
@keyframes pulse-ai {
  0% {
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7);
  }

  70% {
    box-shadow: 0 0 0 20px rgba(99, 102, 241, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);
  }
}

/* Tooltip on hover */
.fab::after {
  content: attr(title);
  position: absolute;
  right: 80px;
  background: var(--surface-solid);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: 0.3s;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
}

.fab:hover::after {
  opacity: 1;
  right: 74px;
}

@media (max-width: 1024px) {
  .fab {
    width: 52px;
    height: 52px;
    font-size: 20px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.28);
  }

  .fab::after {
    display: none;
  }
}

/* Chatbot Window */
.chat-window {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 350px;
  height: 500px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: none;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  z-index: 1001;
  backdrop-filter: blur(20px);
  overflow: hidden;
  animation: slideUp 0.3s ease-out;
}

@media (max-width: 720px) {
  .chat-window {
    inset: auto 10px calc(88px + env(safe-area-inset-bottom)) 10px;
    width: auto;
    height: min(72vh, 560px);
    border-radius: 22px;
    z-index: 1002;
  }

  .chat-header {
    padding: 14px 16px;
  }

  .chat-messages {
    padding: 14px;
  }

  .chat-input-area {
    padding: 10px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .chat-input {
    min-height: 44px;
    border-radius: 14px;
  }

  .chat-send {
    min-width: 58px;
    border-radius: 14px;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-header {
  padding: 16px;
  background: var(--primary);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-input-area {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}

.chat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  outline: none;
}

.chat-send {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0 16px;
  cursor: pointer;
}

.message {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.message.bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-bottom-left-radius: 2px;
  text-align: justify;
  text-align-last: left;
  text-justify: inter-word;
}

.message.user {
  align-self: flex-end;
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 2px;
}

/* Lead Capture Modal */
.lead-capture-modal {
  max-width: 460px;
  width: calc(100% - 28px);
  padding: 22px 20px;
  border-radius: 16px;
}

.lead-title {
  margin: 0 0 6px;
  font-size: 1.1rem;
  color: var(--text);
  font-weight: 800;
}

.lead-sub {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: justify;
  text-align-last: left;
  text-justify: inter-word;
}

.lead-input {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 0.95rem;
  outline: none;
}

.lead-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}

.lead-error {
  min-height: 18px;
  margin-top: 8px;
  color: #ef4444;
  font-size: 0.82rem;
}

.lead-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.lead-btn {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.lead-btn-primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.lead-btn-primary:hover {
  filter: brightness(1.05);
}

.lead-btn-ghost {
  background: transparent;
  color: var(--text);
}

.lead-btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
}
