body {
  font-family: "Helvetica", sans-serif;
  background: #ffffff;
  margin: 0;
  overflow: hidden; /* Prevents whole page scrolling, handled by layout */
}

/* APP LAYOUT - Gemini Style */
.app-layout {
  display: flex;
  height: 100dvh; /* Dynamic viewport height for perfect mobile sizing */
  width: 100%;    /* Changed from 100vw to prevent horizontal scrollbars */
  background: #ffffff;
  overflow: hidden; /* Ensures no unwanted scrollbars escape the layout */
}

/* =========================================
   LOGIN OVERLAY
   ========================================= */
.login-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #F1F2F7;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.login-box {
  background: #ffffff;
  padding: 40px;
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.08);
  text-align: center;
  max-width: 400px;
  width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.login-box img {
  height: 40px;
  margin-bottom: 20px;
}

.login-box h2 {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 24px;
  background: linear-gradient(90deg, #5731ED, #0B69EB);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
}

.login-box p {
  color: #59606C;
  margin-bottom: 30px;
  font-size: 15px;
}

/* SIDEBAR (Functions as the Menu Bar when collapsed) */
.sidebar {
  width: 280px;
  background: #F1F2F7;
  padding: 10px 15px;
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease, padding 0.3s ease;
  flex-shrink: 0;
  box-sizing: border-box;
  z-index: 50;
  overflow: hidden;
}

.sidebar.collapsed {
  width: 68px; /* Persistent narrow left menu bar */
  padding: 10px 14px;
}

.new-chat-btn {
  background: #E8EDF1;
  border: none;
  padding: 12px 15px;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #161C26;
  margin-bottom: 30px;
  transition: all 0.3s ease;
  white-space: nowrap;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.new-chat-btn svg {
  flex-shrink: 0;
}

.new-chat-btn:hover {
  background: #DDE3E9;
}

/* Shrink the button to a circle when menu is collapsed */
.sidebar.collapsed .new-chat-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  justify-content: center;
  gap: 0;
}

.sidebar.collapsed .new-chat-text {
  display: none;
}

/* Wrap history content to fade out smoothly when collapsing */
.sidebar-history {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity 0.2s ease;
  opacity: 1;
}

.sidebar.collapsed .sidebar-history {
  opacity: 0;
  pointer-events: none;
}

.history-title {
  font-size: 14px;
  font-weight: 600;
  color: #59606C;
  margin-bottom: 10px;
  padding-left: 10px;
  white-space: nowrap;
}

.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow-y: auto;
  flex: 1;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 10px;
  border-radius: 10px;
  cursor: pointer;
  color: #59606C;
  transition: background 0.2s;
  margin-bottom: 2px;
}

.history-item:hover {
  background: #E8EDF1;
}

.history-item.active {
  background: #DDE3E9;
  font-weight: 600;
  color: #161C26;
}

.history-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
}

.history-actions {
  display: none;
  gap: 5px;
}

.history-item:hover .history-actions {
  display: flex;
}

.action-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #59606C;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.action-btn:hover {
  background: #cdd3d8;
  color: #161C26;
}

/* SIDEBAR FOOTER (SUPPORT) */
.sidebar-footer {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #DDE3E9;
}

.sidebar.collapsed .sidebar-footer {
  border-top: none;
  padding-top: 0;
}

.support-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #59606C;
  padding: 10px 12px;
  border-radius: 10px;
  transition: background 0.2s;
  overflow: hidden;
  white-space: nowrap;
  box-sizing: border-box;
}

.support-link:hover {
  background: #E8EDF1;
  color: #161C26;
}

.support-icon {
  flex-shrink: 0;
}

.support-text {
  font-size: 13px;
  font-weight: 500;
}

.sidebar.collapsed .support-link {
  padding: 0;
  justify-content: center;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  margin: 0 auto;
}

.sidebar.collapsed .support-text {
  display: none;
}

/* MAIN CONTENT AREA */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background: #ffffff;
  min-width: 0;
}

/* TOP STICKY HEADER */
.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  height: 60px;
  box-sizing: border-box;
  background: #ffffff;
  flex-shrink: 0;
  z-index: 100;
  border-bottom: 1px solid transparent;
  transition: border-bottom 0.3s ease;
}

.main-header.chat-mode {
  border-bottom: 1px solid #F0F4F9;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 15px;
  flex: 1;
}

.menu-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #59606C;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  transition: background 0.2s;
  flex-shrink: 0;
}

.menu-btn:hover {
  background: #e1e5ea;
}

.sidebar .menu-btn {
  margin-bottom: 25px;
}

.mobile-menu-btn {
  display: none;
}

.header-logo {
  height: 28px;
  object-fit: contain;
}

.header-chat-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  background: linear-gradient(90deg, #5731ED, #0B69EB);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.4s ease;
}

.main-header.chat-mode .header-chat-title {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* User Auth Info in Header Right */
.header-right {
  flex: 1;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}

.user-email {
  font-size: 13px;
  font-weight: 500;
  color: #59606C;
  display: none; /* hidden on mobile for space */
}

@media (min-width: 769px) {
  .user-email {
    display: block;
  }
}

.logout-btn {
  background: #fff;
  border: 1px solid #DDE3E9;
  color: #d93025;
  padding: 6px 14px;
  border-radius: 15px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.logout-btn:hover {
  background: #fce8e6;
  border-color: #fce8e6;
}

/* Layout container handling scroll */
.page-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* Inner wrapper to restrict width but allow scrollbar at the edge */
.page-content-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
  box-sizing: border-box;
  flex: 1;
}

/* HERO INTRO SECTION (Hidden during chat) */
.top-header {
  text-align: center;
  padding: 20px 0 10px;
  transition: all 0.4s ease;
  background: #ffffff;
  margin-top: auto;
}

.top-header h1 {
  font-size: 42px;
  font-weight: 700;
  margin-top: 10px;
  margin-bottom: 5px;
  background: linear-gradient(90deg, #5731ED, #0B69EB);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
}

.top-header p {
  color: #59606C;
  font-size: 18px;
  font-weight: 400;
}

.top-header.hidden {
  display: none !important;
}

/* CHAT BUBBLES */
.chat-container {
  width: 100%;
  margin-top: 10px;
}

.chat-messages {
  width: 100%;
  height: auto;
  padding-bottom: 20px;
  box-sizing: border-box;
}

.user-message {
  text-align: right;
  margin: 25px 0 20px 0;
  color: #0057E5;
  font-style: oblique;
  font-weight: bold;
}

.user-bubble {
  display: inline-block;
  background: #F1F2F7;
  padding: 12px 18px;
  border-radius: 15px 15px 0 15px;
  text-align: left;
  max-width: 80%;
  word-break: break-word;
}

.bot-message {
  display: flex;
  gap: 14px;
  color: #161C26;
  margin-bottom: 30px;
}

.bot-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 85%;
}

.bot-bubble {
  background: linear-gradient(
    90deg,
    rgba(87, 49, 237, 0.10),
    rgba(11, 105, 235, 0.10)
  );
  padding: 15px;
  border-radius: 0 15px 15px 15px;
  line-height: 1.5;
  word-break: break-word;
}

.bot-actions {
  display: flex;
  gap: 6px;
  padding-left: 5px;
}

.feedback-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #8c95a3;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.feedback-btn:hover {
  background: #E8EDF1;
  color: #59606C;
}

.feedback-btn.active-like {
  color: #0b69eb;
  background: #F0F6FF;
}

.feedback-btn.active-like svg {
  fill: #0b69eb;
}

.feedback-btn.active-dislike {
  color: #d93025;
  background: #fce8e6;
}

.feedback-btn.active-dislike svg {
  fill: #d93025;
}

/* INTERACTION PANEL */
.interaction-panel {
  width: 100%;
  transition: all 0.4s ease;
  background: #ffffff;
}

.center-mode {
  margin-top: 70px;
  margin-bottom: auto;
}

.bottom-mode {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  padding: 20px 0 30px;
  z-index: 10;
}

.top-search-row {
  display: flex;
  align-items: center;
  gap: 15px;
}

.avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
}

.search-wrapper {
  flex: 1;
  display: flex;
  gap: 10px;
}

.search-wrapper input {
  flex: 1;
  height: 25px;
  min-width: 0;
  padding: 14px 18px;
  border-radius: 30px;
  border: none;
  background: linear-gradient(
    90deg,
    rgba(87, 49, 237, 0.05),
    rgba(11, 105, 235, 0.05)
  );
  font-weight: 400;
  font-size: 16px;
}

.search-wrapper input::placeholder {
  color: #A0ABBA;
  opacity: 1;
  font-weight: normal;
  font-style: normal;
}

.search-wrapper input:focus {
  outline: 1px solid #0057E5;
  background: #ffffff;
}

.search-wrapper button {
  flex-shrink: 0;
  padding: 10px 22px;
  border-radius: 20px;
  border: none;
  background: linear-gradient(45deg, #4f6dff, #7b5cff);
  color: white;
  font-weight: bold;
  cursor: pointer;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-text {
  display: inline;
  font-size: 16px;
}

.search-icon {
  display: none;
}

.search-wrapper button:disabled {
  background: #c7c9d1;
  cursor: not-allowed;
}

.search-wrapper button:hover:not(:disabled) {
  opacity: 0.9;
}

/* Tabs Section */
.tabs-section {
  margin-top: 20px;
  margin-bottom: 15px;
  position: relative;
}

.tabs {
  width: 100%;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.tab-wrapper {
  position: relative;
  flex: 0 0 auto;
}

.tab {
  width: 100%;
  text-align: center;
  background: #ffffff;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  color: #59606C;
  border: 1px solid #E8EDF1;
  font-size: 16px;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab.active, .tab:hover {
  background: #F0F6FF;
  color: #0057E5;
  border: 1px solid #0057E5;
}

/* Dropdown anchored to specific tab */
.question-box {
  position: absolute;
  bottom: calc(100% + 5px);
  left: 0;
  min-width: 300px;
  max-width: 100vw;
  max-height: 250px;
  overflow-y: auto;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  border: 1px solid #E8EDF1;
  padding: 8px 0;
  z-index: 200;
  visibility: hidden;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.2s ease;
  text-align: left;
}

.question-box.show {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

.question-item {
  padding: 10px 15px;
  cursor: pointer;
  margin: 2px 8px;
  border-radius: 6px;
  color: #59606C;
  font-size: 14px;
  transition: all 0.2s;
}

.question-item:hover {
  background: linear-gradient(
    90deg,
    rgba(87, 49, 237, 0.10),
    rgba(11, 105, 235, 0.10)
  );
  color: #0057E5;
}

.question-box::-webkit-scrollbar {
  width: 8px;
}

.question-box::-webkit-scrollbar-track {
  background: transparent;
}

.question-box::-webkit-scrollbar-thumb {
  background-color: #53A2FF66;
  border-radius: 10px;
}

.question-box::-webkit-scrollbar-thumb:hover {
  background-color: #53A2FFAA;
}

.hidden {
  display: none !important;
}

/* Mobile handling */
@media (max-width: 768px) {
  .mobile-menu-btn {
    display: flex;
  }
  .sidebar {
    position: absolute;
    height: 100vh;
    left: 0;
    top: 0;
    box-shadow: 4px 0 15px rgba(0,0,0,0.1);
  }
  .sidebar.collapsed {
    width: 0;
    padding: 0;
    border: none;
  }
  .main-header {
    padding: 10px 15px;
    position: relative;
  }
  .header-left {
    gap: 10px;
    position: static;
  }
  .header-logo {
    height: 24px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
  }
  .header-chat-title {
    display: none !important;
  }
  .page-content-wrapper {
    padding: 0 15px;
  }
  .top-header h1 {
    font-size: 28px;
    margin-top: 5px;
  }
  .top-header p {
    font-size: 14px;
  }
  .top-search-row {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
  }
  .avatar {
    width: 40px;
    height: 40px;
    margin: 0;
    flex-shrink: 0;
  }
  .search-wrapper {
    flex-direction: row;
    align-items: center;
    width: 100%;
    gap: 8px;
    flex: 1;
  }
  .search-wrapper input {
    font-size: 14px;
    padding: 12px 14px;
    width: 100%;
    box-sizing: border-box;
    text-align: left;
    flex: 1;
    height: 44px;
  }
  .search-wrapper button {
    padding: 0 !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 50% !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  .search-text {
    display: none !important;
  }
  .search-icon {
    display: block !important;
  }
  .tabs-section {
    text-align: center;
    width: 100%;
    margin-top: 15px;
  }
  .tabs {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
  }
  .tab-wrapper {
    width: 100%;
    display: flex;
  }
  .tab {
    width: 100%;
    font-size: 12px;
    padding: 10px 4px;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .question-box {
    min-width: 280px;
  }
  .tab-wrapper:nth-child(odd) .question-box {
    left: 0;
    right: auto;
  }
  .tab-wrapper:nth-child(even) .question-box {
    left: auto;
    right: 0;
  }
  .user-bubble, .bot-bubble {
    max-width: 95%;
    font-size: 14px;
    padding: 10px 14px;
  }
  .bot-message {
    gap: 10px;
    margin-bottom: 20px;
  }
  .center-mode {
    margin-top: 20px;
  }
  .bottom-mode {
    padding: 10px 0 15px;
  }
}
