:root {
  --primary-color: #4285f4;
  --text-color: #202124;
  --light-text: #5f6368;
  --border-color: #dfe1e5;
  --bg-color: #ffffff;
  --footer-bg: #f2f2f2;
  --hover-bg: #f8f9fa;
}

[data-theme="dark"] {
  --primary-color: #8ab4f8;
  --text-color: #e8eaed;
  --light-text: #9aa0a6;
  --border-color: #5f6368;
  --bg-color: #202124;
  --footer-bg: #171717;
  --hover-bg: #303134;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  transition: background-color 0.3s, color 0.3s;
}

body {
  font-family: 'Arial', sans-serif;
  color: var(--text-color);
  background-color: var(--bg-color);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Navigation */
nav {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 30px 20px;
  height: 60px;
}

.logo {
  margin-right: auto;
}

.logo img {
  height: 40px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

.nav-btn {
  background: none;
  border: none;
  color: var(--text-color);
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
}

.nav-btn:hover {
  background-color: var(--hover-bg);
}

/* Fixed login link with proper click area */
.login-btn {
  background: none;
  border: none;
  color: var(--primary-color);
  font-size: 14px;
  padding: 8px 12px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 500;
  display: inline-block;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 1;
}

.login-btn:hover {
  text-decoration: underline;
  background: none;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
}

/* Apps Dropdown */
.apps-dropdown-container {
  position: relative;
}

.apps-dropdown-menu {
  position: absolute;
  right: 0;
  top: 50px;
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  width: 300px;
  max-height: 400px;
  overflow-y: auto;
  padding: 15px;
  display: none;
  z-index: 100;
}

.apps-dropdown-menu.show {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
}

.app-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  min-width: 0;
}

.app-icon:hover {
  background-color: var(--hover-bg);
}

.app-icon i {
  font-size: 24px;
  margin-bottom: 5px;
  color: var(--primary-color);
}

.app-icon span {
  font-size: 12px;
  color: var(--text-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  text-align: center;
}

/* Main Search */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  margin-top: -60px;
}

.search-logo {
  margin-bottom: 20px;
  text-align: center;
}

.search-logo img {
  height: 80px;
}

.search-container {
  width: 100%;
  max-width: 584px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.search-form {
  width: 100%;
}

.search-bar-container {
  position: relative;
  width: 100%;
  margin-bottom: 25px;
}

.search-bar {
  width: 100%;
  height: 44px;
  padding: 10px 45px 10px 20px;
  border: 1px solid var(--border-color);
  border-radius: 24px;
  font-size: 16px;
  outline: none;
  background-color: var(--bg-color);
  color: var(--text-color);
}

.search-bar:focus {
  box-shadow: 0 1px 6px rgba(32, 33, 36, 0.28);
  border-color: rgba(223, 225, 229, 0);
}

.search-icons {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 10px;
}

.search-icons i {
  color: var(--light-text);
  cursor: pointer;
}

.search-buttons {
  display: flex;
  gap: 15px;
  width: 100%;
  justify-content: center;
}

.search-buttons button {
  background-color: var(--hover-bg);
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 8px 16px;
  color: var(--text-color);
  font-size: 14px;
  cursor: pointer;
  min-width: 120px;
}

.search-buttons button:hover {
  border: 1px solid var(--border-color);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

/* AI Chat Modal */
.ai-chat-modal {
  position: fixed;
  top: 0;
  right: -100%;
  width: 100%;
  max-width: 400px;
  height: 100%;
  background-color: var(--bg-color);
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
}

.ai-chat-modal.show {
  right: 0;
}

.ai-chat-header {
  padding: 15px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ai-chat-header h3 {
  color: var(--primary-color);
}

.close-chat {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-color);
}

.ai-chat-body {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
}

.ai-chat-input {
  padding: 15px;
  border-top: 1px solid var(--border-color);
  display: flex;
}

.ai-chat-input input {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  outline: none;
  background-color: var(--bg-color);
  color: var(--text-color);
}

/* Overlay for modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 999;
  display: none;
}

.modal-overlay.show {
  display: block;
}

/* Footer */
footer {
  background-color: var(--footer-bg);
  padding: 15px 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}

.footer-left, .footer-right {
  display: flex;
  gap: 15px;
}

footer a {
  color: var(--light-text);
  text-decoration: none;
  font-size: 14px;
}

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

/* Theme Toggle */
.theme-toggle {
  background: none;
  border: none;
  color: var(--text-color);
  cursor: pointer;
  font-size: 16px;
  padding: 8px;
}

/* Responsive */
@media (max-width: 768px) {
  .apps-dropdown-menu {
    width: 280px;
    grid-template-columns: repeat(2, 1fr);
  }

  .search-logo img {
    height: 60px;
  }

  .search-buttons {
    flex-direction: row;
  }

  .search-buttons button {
    min-width: auto;
    padding: 8px 12px;
  }

  .ai-chat-modal {
    width: 85%;
  }

  footer {
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }

  .footer-left, .footer-right {
    justify-content: center;
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  /* Restored original nav positioning */
  nav {
    padding: 10px 15px;
    justify-content: flex-end;
    flex-wrap: nowrap;
    overflow: visible;
  }

  .logo {
    margin-right: auto;
    width: auto;
    text-align: left;
    margin-bottom: 0;
  }

  .nav-right {
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: nowrap;
  }

  /* Fixed dropdown menu width and centering */
  .apps-dropdown-menu {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 90vw;
    min-width: 280px;
    max-width: 320px;
    top: 60px;
    padding: 10px;
  }

  .apps-dropdown-menu.show {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }

  .app-icon {
    padding: 8px 5px;
  }

  .app-icon span {
    font-size: 11px;
  }

  .nav-btn, .login-btn {
    padding: 8px 10px;
    font-size: 13px;
  }

  .search-bar {
    height: 40px;
    padding: 8px 40px 8px 15px;
  }

  .search-buttons {
    gap: 8px;
  }

  .search-buttons button {
    font-size: 13px;
    padding: 8px 10px;
  }
}