/* GXUAI Floating Navigation v8 — draggable FAB */

:root {
  --gxuai-fab-size: 48px;
  --gxuai-fab-bg: #6c63ff;
  --gxuai-fab-hover: #8b83ff;
  --gxuai-drawer-bg: #1a1a2e;
  --gxuai-drawer-text: #e0e0e0;
  --gxuai-drawer-accent: #6c63ff;
  --gxuai-drawer-active: #ffffff;
  --gxuai-drawer-divider: rgba(255, 255, 255, 0.1);
  --gxuai-z: 99999;
}

/* Floating Action Button */
#gxuai-fab {
  position: fixed;
  /* bottom/right set by JS; fallback for no-JS */
  bottom: 24px;
  right: 24px;
  width: var(--gxuai-fab-size);
  height: var(--gxuai-fab-size);
  border-radius: 50%;
  background: var(--gxuai-fab-bg);
  color: #fff;
  border: none;
  cursor: grab;
  box-shadow: 0 4px 12px rgba(108, 99, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--gxuai-z);
  transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#gxuai-fab:hover {
  background: var(--gxuai-fab-hover);
  box-shadow: 0 6px 20px rgba(108, 99, 255, 0.5);
}

#gxuai-fab:active,
#gxuai-fab.gxuai-dragging {
  cursor: grabbing;
  transform: scale(0.95);
  box-shadow: 0 8px 24px rgba(108, 99, 255, 0.5);
}

#gxuai-fab.gxuai-open {
  transform: rotate(45deg);
  background: #e74c3c;
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
}

#gxuai-fab svg {
  width: 22px;
  height: 22px;
  transition: transform 0.2s;
}

/* Backdrop overlay */
#gxuai-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: calc(var(--gxuai-z) - 2);
  opacity: 0;
  transition: opacity 0.25s;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

#gxuai-backdrop.gxuai-show {
  display: block;
  opacity: 1;
}

/* Drawer panel */
#gxuai-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--gxuai-drawer-bg);
  color: var(--gxuai-drawer-text);
  z-index: calc(var(--gxuai-z) - 1);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.3);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  max-height: 80vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

#gxuai-drawer.gxuai-show {
  transform: translateY(0);
}

/* Drawer handle bar */
#gxuai-drawer .gxuai-handle {
  display: flex;
  justify-content: center;
  padding: 10px 0 4px;
}

#gxuai-drawer .gxuai-handle-bar {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.2);
}

/* Drawer header */
#gxuai-drawer .gxuai-drawer-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px 12px;
}

#gxuai-drawer .gxuai-drawer-header svg {
  width: 24px;
  height: 24px;
  color: var(--gxuai-drawer-accent);
}

#gxuai-drawer .gxuai-drawer-header span {
  font-size: 16px;
  font-weight: 600;
  color: var(--gxuai-drawer-active);
}

/* Navigation links grid — 2 columns on mobile */
#gxuai-drawer .gxuai-nav-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 16px 12px;
}

#gxuai-drawer .gxuai-nav-item:last-child:nth-child(odd) {
  grid-column: 1 / -1;
  max-width: 50%;
  justify-self: center;
}

#gxuai-drawer .gxuai-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--gxuai-drawer-text);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

#gxuai-drawer .gxuai-nav-item:active {
  background: rgba(255, 255, 255, 0.1);
}

#gxuai-drawer .gxuai-nav-item.gxuai-current {
  background: rgba(108, 99, 255, 0.15);
  color: var(--gxuai-drawer-accent);
}

#gxuai-drawer .gxuai-nav-item svg {
  width: 24px;
  height: 24px;
  opacity: 0.8;
}

#gxuai-drawer .gxuai-nav-item.gxuai-current svg {
  opacity: 1;
}

#gxuai-drawer .gxuai-nav-item span {
  font-size: 13px;
}

/* Divider */
#gxuai-drawer .gxuai-divider {
  height: 1px;
  background: var(--gxuai-drawer-divider);
  margin: 4px 16px;
}

/* Auth section */
#gxuai-drawer .gxuai-auth {
  padding: 8px 16px 20px;
}

/* Safe area for iPhone notch */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  #gxuai-drawer .gxuai-auth {
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
}

#gxuai-drawer .gxuai-auth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: none;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}

#gxuai-drawer .gxuai-auth-btn svg {
  width: 18px;
  height: 18px;
}

#gxuai-drawer .gxuai-login-btn {
  background: var(--gxuai-drawer-accent);
  color: #fff;
}

#gxuai-drawer .gxuai-login-btn:active {
  background: var(--gxuai-fab-hover);
}

#gxuai-drawer .gxuai-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px 10px;
  color: var(--gxuai-drawer-text);
  font-size: 13px;
}

#gxuai-drawer .gxuai-user-info svg {
  width: 18px;
  height: 18px;
  opacity: 0.7;
}

#gxuai-drawer .gxuai-logout-btn {
  background: rgba(255, 255, 255, 0.06);
  color: var(--gxuai-drawer-text);
}

#gxuai-drawer .gxuai-logout-btn:active {
  background: rgba(255, 255, 255, 0.12);
}

/* Desktop: popup card instead of bottom sheet */
@media (min-width: 641px) {
  #gxuai-drawer {
    /* position set by JS when opening; fallback */
    left: auto;
    right: 24px;
    bottom: 90px;
    border-radius: 16px;
    max-width: 340px;
    max-height: 70vh;
  }

  #gxuai-drawer .gxuai-handle {
    display: none;
  }

  #gxuai-drawer .gxuai-nav-grid {
    gap: 10px;
    padding: 0 14px 14px;
  }

  #gxuai-drawer .gxuai-nav-item {
    padding: 14px 8px;
  }
}

/* Small phones */
@media (max-width: 360px) {
  #gxuai-fab {
    width: 44px;
    height: 44px;
  }

  #gxuai-fab svg {
    width: 20px;
    height: 20px;
  }

  #gxuai-drawer .gxuai-nav-item {
    padding: 12px 6px;
  }
}
