/* ===== CSS Variables ===== */
:root {
  --bg: #0a0c10;
  --bg-card: #12151c;
  --bg-input: #181c25;
  --text: #f0f2f5;
  --text-muted: #6b7280;
  --primary: #22d3ee;
  --primary-hover: #67e8f9;
  --primary-dark: #0891b2;
  --border: #2a2f3a;
  --border-focus: rgba(34, 211, 238, 0.5);
}

/* ===== Reset ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(100, 150, 200, 0.2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(100, 150, 200, 0.3); }

/* ===== Utilities ===== */
.hidden { display: none !important; }
.page { min-height: 100vh; }

/* ===== User Button (Home) ===== */
.user-btn {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  padding: 0.75rem;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-btn:hover {
  color: var(--text);
  border-color: var(--border-focus);
}

.user-btn svg {
  width: 20px;
  height: 20px;
}

/* ===== Home Page ===== */
#home-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  padding-bottom: 6rem;
  position: relative;
}

.logo {
  font-size: 4rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.tagline {
  color: var(--text-muted);
  margin-bottom: 2.5rem;
}

.search-container {
  width: 100%;
  max-width: 36rem;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1rem 1.25rem;
  transition: all 0.2s;
}

.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary), 0 0 20px rgba(34, 211, 238, 0.15);
}

.search-box svg,
.search-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.search-box input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 1.125rem;
  color: var(--text);
}

.search-box input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.search-box input:-webkit-autofill,
.search-box input:-webkit-autofill:hover,
.search-box input:-webkit-autofill:focus,
.search-box input:-webkit-autofill:active {
  background-color: transparent;
  -webkit-box-shadow: 0 0 0 1000px transparent inset !important; /* Match your desired background */
  -webkit-text-fill-color: var(--text) !important; /* Set text color */
  transition: background-color 5000s ease-in-out 0s; /* Prevents flicker */
}

.submit-btn {
  padding: 0.625rem;
  border-radius: 0.75rem;
  border: none;
  background: var(--bg-input);
  color: var(--text-muted);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.submit-btn:hover {
  background: var(--primary);
  color: var(--bg);
  transform: scale(1.05);
}

.submit-btn svg {
  width: 20px;
  height: 20px;
}

/* Mode Toggle */
.mode-toggle {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: 9999px;
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-weight: 500;
  background: transparent;
  color: var(--text-muted);
  transition: all 0.2s;
}

.mode-btn:hover {
  background: var(--bg-input);
}

.mode-btn.active {
  background: rgba(34, 211, 238, 0.15);
  color: var(--primary);
  border-color: rgba(34, 211, 238, 0.3);
}

.mode-btn svg {
  width: 16px;
  height: 16px;
}

/* Recent Searches */
.recent-section {
  margin-top: 0.5rem;
}

.recent-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.recent-label svg {
  width: 12px;
  height: 12px;
}

.recent-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.recent-tag {
  padding: 0.5rem 1rem;
  background: var(--bg-input);
  border: none;
  border-radius: 9999px;
  font-size: 0.875rem;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
}

.recent-tag:hover {
  background: var(--bg-card);
}

/* ===== Search Page ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 12, 16, 0.95);
  backdrop-filter: blur(12px);
  padding: 0.75rem 1rem;
}

.header-inner {
  max-width: 48rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
  transition: color 0.2s;
}

.header-logo:hover {
  color: var(--primary-hover);
}

.header-search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 0.625rem 1rem;
  transition: border-color 0.2s;
}

.header-search:focus-within {
  border-color: var(--border-focus);
}

.header-search svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.header-search input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 0.875rem;
  color: var(--text);
  min-width: 0;
}

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

.header-toggle {
  display: flex;
  background: var(--bg-input);
  border-radius: 9999px;
  padding: 0.25rem;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.header-toggle button {
  padding: 0.5rem;
  border-radius: 9999px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-toggle button svg {
  width: 16px;
  height: 16px;
}

.header-toggle button.active {
  background: var(--primary);
  color: var(--bg);
}

.header-toggle button:not(.active):hover {
  color: var(--text);
}

.header-user-btn {
  padding: 0.625rem;
  border-radius: 50%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.header-user-btn:hover {
  color: var(--text);
  border-color: var(--border-focus);
}

.header-user-btn svg {
  width: 16px;
  height: 16px;
}

/* Main Content */
.main-content {
  max-width: 48rem;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* Results */
.results-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.result-item {
  margin-bottom: 1.5rem;
  cursor: pointer;
}

.result-item:hover .result-title {
  text-decoration: underline;
}

.result-url {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.result-title {
  font-size: 1.125rem;
  color: var(--primary);
  font-weight: 500;
}

.result-desc {
  font-size: 0.875rem;
  color: #9ca3af;
  margin-top: 0.25rem;
  line-height: 1.6;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 2rem 0 1rem;
}

.page-btn {
  min-width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  border: none;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  gap: 0.25rem;
  padding: 0 0.75rem;
  background: transparent;
}

.page-btn.nav {
  color: var(--primary);
}

.page-btn.nav:hover:not(:disabled) {
  background: rgba(34, 211, 238, 0.1);
}

.page-btn.nav:disabled {
  color: #374151;
  cursor: not-allowed;
}

.page-btn.number {
  color: var(--text-muted);
}

.page-btn.number:hover {
  background: var(--bg-input);
  color: var(--text);
}

.page-btn.number.active {
  background: var(--primary);
  color: var(--bg);
}

.page-ellipsis {
  padding: 0 0.5rem;
  color: var(--text-muted);
}

.page-btn svg {
  width: 16px;
  height: 16px;
}

/* AI Chat */
.ai-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 0;
}

.message {
  display: flex;
  margin-bottom: 1rem;
}

.message.user {
  justify-content: flex-end;
}

.message.ai {
  justify-content: flex-start;
}

.message-bubble {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  font-size: 0.875rem;
  line-height: 1.6;
}

.message.user .message-bubble {
  background: var(--primary);
  color: var(--bg);
}

.message.ai .message-bubble {
  background: rgba(30, 35, 45, 0.5);
  border: 1px solid var(--border);
}

.chat-input-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(30, 35, 45, 0.5);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  margin-top: auto;
}

.chat-input-box input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 0.875rem;
  color: var(--text);
}

.chat-input-box input::placeholder {
  color: var(--text-muted);
}

.chat-send-btn {
  padding: 0.5rem;
  border-radius: 0.5rem;
  border: none;
  background: var(--primary);
  color: var(--bg);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-send-btn:hover {
  background: var(--primary-hover);
}

.chat-send-btn svg {
  width: 16px;
  height: 16px;
}

/* Floating AI Button */
.floating-ai-btn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--primary);
  color: var(--bg);
  padding: 0.75rem 1.25rem;
  border-radius: 9999px;
  border: none;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(34, 211, 238, 0.3);
  transition: all 0.2s;
}

.floating-ai-btn:hover {
  background: var(--primary-hover);
  transform: scale(1.05);
}

.floating-ai-btn svg {
  width: 16px;
  height: 16px;
}

/* ===== Auth Page ===== */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.auth-container {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  padding: 2rem;
}

.auth-logo {
  display: block;
  text-align: center;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1.5rem;
}

.auth-tabs {
  display: flex;
  background: var(--bg-input);
  border-radius: 0.75rem;
  padding: 0.25rem;
  margin-bottom: 1.5rem;
}

.auth-tab {
  flex: 1;
  padding: 0.75rem;
  border: none;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  background: transparent;
  color: var(--text-muted);
  transition: all 0.2s;
}

.auth-tab.active {
  background: var(--primary);
  color: var(--bg);
}

.social-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.social-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.875rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: transparent;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
}

.social-btn:hover {
  background: var(--bg-input);
  border-color: var(--border-focus);
}

.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.form-group input {
  padding: 0.875rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  font-size: 0.875rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.form-group input:focus {
  border-color: var(--border-focus);
}

.password-input {
  position: relative;
}

.password-input input {
  width: 100%;
  padding-right: 3rem;
}

.toggle-password {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  padding: 0.25rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  transition: color 0.2s;
}

.toggle-password:hover {
  color: var(--text);
}

.toggle-password svg {
  width: 18px;
  height: 18px;
}

.forgot-link {
  font-size: 0.875rem;
  color: var(--primary);
  text-align: right;
  margin-top: -0.5rem;
}

.forgot-link:hover {
  text-decoration: underline;
}

.auth-submit {
  padding: 0.875rem;
  background: var(--primary);
  border: none;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--bg);
  transition: background 0.2s;
  margin-top: 0.5rem;
}

.auth-submit:hover {
  background: var(--primary-hover);
}

.auth-footer {
  margin-top: 1.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
}

.auth-footer a {
  color: var(--primary);
}

.auth-footer a:hover {
  text-decoration: underline;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .logo {
    font-size: 3rem;
  }

  .page-btn .nav-text {
    display: none;
  }

  .auth-container {
    padding: 1.5rem;
  }
}
