/* layout.css – global resets, sidebar, main panel, modals, etc. */
/* grain overlay */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMDAiIGhlaWdodD0iMzAwIj48ZmlsdGVyIGlkPSJmIj48ZmVUdXJidWxlbmNlIHR5cGU9ImZyYWN0YWxOb2lzZSIgYmFzZUZyZXF1ZW5jeT0iLjc1IiBudW1PY3RhdmVzPSIzIiAvPjwvZmlsdGVyPjxyZWN0IHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbHRlcj0idXJsKCNmKSIgb3BhY2l0eT0iMC4wMjUiIC8+PC9zdmc+');
  pointer-events: none;
  opacity: 0.15;
  z-index: 1;
}

#particle-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* thinking pulse overlays */
body.thinking-active::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, rgba(96,165,250,0.08), transparent 70%);
  animation: pulseGlow 2.2s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
}

body.ai-processing::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(
    circle at center,
    rgba(96,165,250,0.12),
    transparent 70%
  );
  animation: subtlePulse 2.4s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
}

@keyframes subtlePulse {
  0%,100% { opacity: 0.4; }
  50% { opacity: 1; }
}

@keyframes pulseGlow {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.8; }
}

/* main app container */
.app {
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

/* ----- sidebar ----- */
.sidebar {
  width: 280px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #0f0f0f;
  border-right: none;
  box-shadow: 8px 0 40px rgba(0,0,0,0.5);
  position: relative;
  transition: width 0.3s ease;
}

.sidebar.collapsed {
  width: 72px;
}

.sidebar.collapsed .nav-text,
.sidebar.collapsed .search-area span:not(.nav-icon),
.sidebar.collapsed .profile-text,
.sidebar.collapsed .history-item .title,
.sidebar.collapsed .history-item .timestamp,
.sidebar.collapsed .nav-title {
  opacity: 0;
  width: 0;
  overflow: hidden;
  transition: opacity 0.2s, width 0.2s;
}

.sidebar.collapsed .nav-item,
.sidebar.collapsed .history-item,
.sidebar.collapsed .profile-area {
  justify-content: center;
  padding: 10px 0;
}

.sidebar.collapsed .nav-icon {
  font-size: 18px;
}

.sidebar.collapsed .logo-area {
  justify-content: center;
  padding: 16px 0;
}

.sidebar.collapsed .logo-area span {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar.collapsed .nav-section:nth-of-type(2) {
  display: none;
}

.toggle-sidebar {
  position: absolute;
  left: 280px;
  top: 24px;
  width: 32px;
  height: 32px;
  background: rgba(10, 10, 10, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ccc;
  cursor: pointer;
  z-index: 20;
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.1s, color 0.1s;
}

.sidebar.collapsed + .toggle-sidebar {
  left: 72px;
}

.toggle-sidebar:hover {
  background: rgba(20, 20, 20, 0.8);
  color: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  font-size: 22px;
  font-weight: 600;
  color: white;
  transition: padding 0.2s;
}

.logo-area i {
  font-size: 28px;
}

.search-area {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 12px;
  padding: 8px 16px;
  background: rgba(20, 20, 20, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 40px;
  color: #aaa;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s, transform 0.1s;
}

.search-area:hover {
  background: rgba(30, 30, 30, 0.5);
  transform: translateY(-1px);
}

.search-shortcut {
  font-size: 11px;
  padding: 3px 6px;
  background: rgba(30, 30, 30, 0.5);
  border-radius: 6px;
}

.nav-section {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.nav-section:last-of-type {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.nav-title {
  font-size: 10px;
  color: #777;
  padding: 8px 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: opacity 0.2s;
}

.nav-item, .history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  margin: 2px 8px;
  border-radius: 8px;
  color: #ddd;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  font-size: 11px;
}

.nav-item.active, .history-item.active {
  background: rgba(30, 30, 30, 0.8);
  color: white;
}

.nav-item:hover, .history-item:hover {
  background: rgba(30, 30, 30, 0.8);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-icon {
  font-size: 16px;
  width: 22px;
  text-align: center;
}

.history-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
  overscroll-behavior: contain;
}

.history-list::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.history-item .title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item .timestamp {
  font-size: 10px;
  color: #666;
  margin-left: auto;
  white-space: nowrap;
  opacity: 0.6;
}

.history-item .menu-btn {
  opacity: 0;
  margin-left: 8px;
  padding: 4px 8px;
  color: #888;
  transition: opacity 0.15s;
}

.history-item:hover .menu-btn {
  opacity: 1;
}

.menu-btn:hover {
  color: white;
}

.profile-area {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  margin: 8px;
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  color: #ddd;
  transition: background 0.15s ease, transform 0.15s ease;
  font-size: 12px;
  flex-shrink: 0;
  margin-top: auto;
}

.profile-area:hover {
  background: rgba(30, 30, 30, 0.8);
  transform: translateY(-1px);
}

.profile-icon {
  font-size: 22px;
  width: 28px;
  text-align: center;
}

.profile-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-menu-btn {
  opacity: 0.6;
  transition: opacity 0.15s;
}

.profile-area:hover .profile-menu-btn {
  opacity: 1;
}

/* dropdown menus */
.dropdown-menu {
  position: absolute;
  background: rgba(15, 15, 15, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 14px;
  padding: 6px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.6);
  z-index: 100;
  min-width: 160px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
}

.dropdown-menu.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.dropdown-item {
  padding: 10px 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: #ccc;
  transition: background 0.1s, color 0.1s;
  font-size: 13px;
}

.dropdown-item:hover {
  background: rgba(30, 30, 30, 0.8);
  color: white;
}

.dropdown-item.active {
  background: rgba(30, 30, 30, 0.8);
  color: white;
}

.profile-menu {
  bottom: calc(100% + 8px);
  left: 8px;
  width: 200px;
}

.chat-menu {
  position: fixed;
  z-index: 200;
}

.credit {
  padding: 8px 16px;
  font-size: 11px;
  color: #666;
  text-align: center;
  flex-shrink: 0;
}

.sidebar.collapsed .credit {
  display: none;
}

/* ----- main panel ----- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: transparent;
  position: relative;
  height: 100%;
  overflow: hidden;
}

.grok-bar {
  padding: 18px 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(10, 10, 10, 0.4);
  backdrop-filter: blur(4px);
  flex-shrink: 0;
}

.grok-title {
  font-size: 26px;
  font-weight: 600;
  color: white;
}

.back-btn {
  display: none;
  font-size: 24px;
  cursor: pointer;
  color: #aaa;
  transition: color 0.1s;
}

.back-btn:hover {
  color: white;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 5;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ----- views (chat / explore / settings) ----- */
.view-chat,
.view-explore,
.view-settings {
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.view-chat {
  overflow: hidden; /* chat has its own scrolling container */
}

.view-explore,
.view-settings {
  padding: 24px;
}

.view-content {
  max-width: 980px;
  margin: 0 auto;
  width: 100%;
}

/* explore */
.explore-search {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(20, 20, 20, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 60px;
  padding: 12px 20px;
  margin-bottom: 28px;
}

.explore-search input {
  flex: 1;
  background: transparent;
  border: none;
  color: white;
  font-size: 16px;
  outline: none;
}

.explore-feed {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.feed-item {
  background: rgba(20, 20, 20, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 20px;
}

/* settings */
.settings-tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.tab-btn {
  background: rgba(20, 20, 20, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: #aaa;
  padding: 8px 20px;
  border-radius: 40px;
  cursor: pointer;
  transition: background 0.1s;
}

.tab-btn.active {
  background: rgba(30, 30, 30, 0.8);
  color: white;
  border-color: rgba(255, 255, 255, 0.1);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.settings-form {
  background: rgba(20, 20, 20, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  color: #aaa;
  font-size: 14px;
}

.form-group input,
.form-group select {
  background: rgba(30, 30, 30, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 12px 16px;
  color: white;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  border-color: #60a5fa;
}

.save-btn {
  background: #16a34a;
  border: none;
  color: white;
  padding: 14px;
  border-radius: 40px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.1s;
}

.save-btn:hover {
  background: #1fbb5a;
}

/* toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 30, 30, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
  padding: 10px 24px;
  border-radius: 40px;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
}

/* history modal (full view) */
.history-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.history-modal-content {
  width: 80%;
  max-width: 1000px;
  height: 80%;
  background: #111;
  border-radius: 20px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.05);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  color: white;
}

.history-full-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-full-list .history-item {
  margin: 2px 0;
}

.close-history {
  font-size: 28px;
  cursor: pointer;
  color: #aaa;
  transition: color 0.1s;
}

.close-history:hover {
  color: white;
}

/* login modal */
.modal {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.modal.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: rgba(20,20,20,0.95);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 24px;
  padding: 30px;
  width: 90%;
  max-width: 400px;
  color: white;
}

.modal-content h2 {
  margin-bottom: 20px;
  font-weight: 500;
}

.modal-content input {
  width: 100%;
  padding: 14px;
  margin: 8px 0;
  background: rgba(30,30,30,0.8);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 40px;
  color: white;
  outline: none;
}

.modal-content button {
  width: 100%;
  padding: 14px;
  margin: 8px 0;
  border: none;
  border-radius: 40px;
  background: #16a34a;
  color: white;
  font-weight: 600;
  cursor: pointer;
}

.modal-content .google-btn {
  background: #1e3a8a;
}

.modal-content .anonymous-btn {
  background: #4b5563;
}

.close-modal {
  float: right;
  cursor: pointer;
  font-size: 24px;
}

.error-message {
  color: #f87171;
  font-size: 13px;
  margin-top: 5px;
}

.search-area {
  gap: 8px;
}

#chatSearchInput {
  flex: 1;
  background: transparent;
  border: none;
  color: white;
  outline: none;
  font-size: 13px;
}

#chatSearchInput::placeholder {
  color: #555;
}

/* helper classes */
.hidden {
  display: none !important;
}

.rename-input {
  background: transparent;
  border: none;
  color: #ddd;
  font-size: inherit;
  outline: none;
  width: 100%;
}

/* ----- responsive ----- */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: 82%;
    max-width: 320px;
    height: 100%;
    z-index: 50;
    transition: left 0.28s ease;
    box-shadow: 8px 0 40px rgba(0,0,0,0.6);
  }

  .sidebar.mobile-visible {
    left: 0;
  }

  .toggle-sidebar {
    display: none;
  }

  .main {
    margin-left: 0 !important;
  }

  .grok-bar {
    padding: 12px 16px;
    background: rgba(10,10,10,0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    position: relative;
  }

  .grok-title {
    font-size: 18px;
    font-weight: 600;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
  }

  .back-btn {
    font-size: 20px;
  }

}

  .history-modal {
    width: 100%;
    right: -100%;
  }

  .history-modal.open {
    right: 0;
  }

  .history-modal-content {
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  .nav-item,
  .history-item {
    padding: 14px 16px;
    font-size: 14px;
  }

  .profile-area {
    padding: 16px;
  }

  body::after {
    opacity: 0.05;
  }

  #particle-canvas {
    opacity: 0.3;
  }

@media (max-width: 480px) {
  .input-wrapper {
    background: rgba(15,15,15,0.9);
    border: 1px solid rgba(96,165,250,0.15);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  }
  .input-wrapper.focused {
    box-shadow:
      0 0 0 2px rgba(96,165,250,0.25),
      0 20px 60px rgba(0,0,0,0.6);
  }

  .message-input {
    font-size: 16px;
  }

  .send-btn,
  .stop-btn {
    padding: 12px 16px;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .sidebar {
    width: 220px;
  }

  .sidebar.collapsed {
    width: 64px;
  }

  .grok-title {
    font-size: 22px;
  }
}

/* Admin link hidden by default */
.admin-link {
  opacity: 0;
  transform: translateX(-10px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

/* Visible state */
.admin-link.visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
.admin-badge {
  background: rgba(255,255,255,0.1);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 6px;
  margin-left: 6px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.admin-badge.visible {
  opacity: 1;
}
.sidebar {
  backdrop-filter: blur(14px);
  background: rgba(15, 15, 15, 0.75);
}

.grok-bar {
  backdrop-filter: blur(10px);
  background: rgba(10, 10, 10, 0.6);
}
.nav-item, .history-item {
  transition: all 0.18s ease;
}
.main {
  box-shadow: -10px 0 40px rgba(0,0,0,0.4);
}
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.2);
}
body {
  background: radial-gradient(
    circle at 30% 20%,
    rgba(96,165,250,0.06),
    transparent 40%
  ),
  radial-gradient(
    circle at 80% 80%,
    rgba(59,130,246,0.05),
    transparent 50%
  ),
  #050505;
}
html {
  scroll-behavior: smooth;
}

.chat-container {
  scrollbar-width: thin;
}

.chat-container::-webkit-scrollbar {
  width: 6px;
}

.chat-container::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
}
.logo-img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  filter: drop-shadow(0 0 6px rgba(96,165,250,0.4));
}