/* Global Reset & Typography */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: #f9f9fc;
  color: #1a1a1a;
  height: 100vh;
  overflow: hidden; /* App-like feel */
}

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

/* Layout Containers */
.app-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  position: relative;
}

/* Header */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
  flex-shrink: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #7c63ff, #fd72c7);
  color: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
}

.top-links a {
  text-decoration: none;
  color: #666;
  font-size: 0.9rem;
  margin-left: 20px;
  transition: color 0.2s;
}

.top-links a:hover {
  color: #1a1a1a;
}

/* Main Content Area */
#main-content {
  flex: 1;
  position: relative;
  overflow: hidden; /* manage scroll inside sections */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Views State Management */
.view {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  transform: translateY(20px);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.view.active {
  opacity: 1 !important;
  pointer-events: all !important;
  transform: translateY(0) !important;
  position: relative; /* Allow flow within main */
  display: flex !important;
}

.view.hidden {
  display: none !important; /* Fully hide to prevent interaction/scroll issues */
  opacity: 0;
  pointer-events: none;
}

/* VIEW 1: Welcome / Name */
#view-welcome {
  justify-content: center;
}

.welcome-content {
  text-align: center;
  max-width: 500px;
  width: 100%;
}

.welcome-content h1 {
  font-size: 2.5rem;
  margin-bottom: 40px;
  color: #1a1a1a;
}

#name-form {
  width: 100%;
}

.input-wrapper {
  position: relative;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
}

#name-input {
  width: 100%;
  padding: 16px 20px;
  font-size: 1.1rem;
  border: 1px solid #ccc;
  border-radius: 8px; /* Simple box */
  background: white;
  transition: border-color 0.3s, box-shadow 0.3s;
  outline: none;
  text-align: center;
}

#name-input:focus {
  border-color: #7c63ff;
  box-shadow: 0 8px 24px rgba(124, 99, 255, 0.15);
}

.arrow-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border: none;
  background: linear-gradient(135deg, #7c63ff, #fd72c7);
  color: white;
  border-radius: 12px;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.arrow-btn:hover {
  transform: translateY(-50%) scale(1.05);
}

/* VIEW 2: Dashboard */
#view-dashboard {
  height: 100%;
  display: flex !important;
  flex-direction: column;
  padding: 20px 0;
  justify-content: flex-start;
  align-items: center;
}

.dashboard-container-inner {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.dashboard-top-row {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
  /* No margin-bottom: auto here, we want it at the top */
}

.ghost-back-btn {
  align-self: flex-start;
  border: 1px solid #e2e4f3;
  background: #fff;
  color: #4a4f73;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 10px 20px rgba(10, 21, 60, 0.08);
  margin-bottom: 10px;
}

.ghost-back-btn:hover {
  color: #7c63ff;
  border-color: #7c63ff;
  transform: translateY(-2px);
}

.dashboard-header {
  text-align: center;
  margin-bottom: 30px;
}

.dashboard-header h1 {
  font-size: 2.2rem;
  margin: 0 0 10px 0;
}

.dashboard-header .subtitle {
  color: #666;
  font-size: 1.1rem;
  max-width: 600px;
  margin: 0 auto;
}

.search-bar-container {
  width: 100%;
  max-width: 600px;
  margin: 0 auto 40px;
  position: relative;
  display: flex;
  gap: 10px;
}

#dashboard-search {
  flex: 1;
  padding: 16px 20px;
  border-radius: 14px;
  border: 1px solid #ddd;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

#dashboard-search:focus {
  border-color: #7c63ff;
}

#dashboard-search-btn {
  padding: 0 24px;
  background: #1a1a1a;
  color: white;
  border: none;
  border-radius: 14px;
  font-weight: 600;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); /* Slightly wider cards */
  gap: 20px;
  width: 100%;
  padding: 10px 0 30px;
}

.card {
  background: #fff;
  padding: 28px;
  border-radius: 22px;
  border: 1px solid #eceef7;
  box-shadow: 0 18px 40px rgba(10, 22, 70, 0.08);
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

.card:hover {
  transform: translateY(-6px);
  box-shadow: 0 24px 46px rgba(15, 18, 70, 0.12);
}

.card-icon {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: #fff;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.card-title {
  font-weight: 600;
  font-size: 1.15rem;
  color: #1f1f33;
  line-height: 1.3;
}

.card-desc {
  margin: 0;
  color: #333; /* Darker for visibility */
  font-size: 0.95rem;
  line-height: 1.5;
  margin-top: 8px;
}

/* VIEW 3: Chat Interface */
#view-chat {
  height: 100%;
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  background: white;
  border-radius: 24px; /* Card look */
  box-shadow: 0 10px 40px rgba(0,0,0,0.05);
  overflow: hidden;
  border: 1px solid #eee;
  margin-bottom: 0;
}

.chat-header-actions {
  padding: 15px 20px;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
}

.secondary-btn {
  background: transparent;
  border: 1px solid #ddd;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 0.9rem;
  color: #555;
  transition: background 0.2s;
}

.secondary-btn:hover {
  background: #f5f5f5;
}

.ghost-btn {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  color: #999;
  padding: 5px;
}

.ghost-btn:hover {
  color: #333;
}

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  scroll-behavior: smooth;
  position: relative;
}

.chat-message {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  max-width: 85%;
  animation: popIn 0.3s ease;
}

.chat-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-message .avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: bold;
  color: #555;
  flex-shrink: 0;
}

.chat-message.bot .avatar {
  background: linear-gradient(135deg, #7c63ff, #fd72c7);
  color: white;
}

.chat-message .bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.95rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-message.bot .bubble {
  background: #f4f6f8;
  color: #1a1a1a;
  border-top-left-radius: 4px;
}

.chat-message.user .bubble {
  background: #1a1a1a;
  color: white;
  border-top-right-radius: 4px;
}

/* Link Button Style in Chat */
.chat-link-btn {
    display: inline-block;
    margin-top: 12px;
    padding: 10px 20px;
    background: #1a1a1a;
    color: white !important; /* Force white text */
    text-decoration: none !important; /* No underline */
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: transform 0.2s, background 0.2s;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.chat-link-btn:hover {
    background: #333;
    transform: translateY(-1px);
    text-decoration: none;
}

.bot-list {
    margin: 0;
    padding-left: 20px;
}
.bot-list li {
    margin-bottom: 5px;
}


.chat-input-area {
  padding: 0;
  border-top: none;
  background: transparent;
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 6px 0 0 0;
  min-height: 0;
}

.suggestion-chip {
  padding: 10px 16px;
  border-radius: 18px;
  border: 1px solid #dde1ff;
  background: #f6f7ff;
  color: #1f1f33;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 10px rgba(96, 99, 255, 0.05);
  text-align: center;
  line-height: 1.4;
  white-space: nowrap;
}

.suggestion-chip:hover {
  background: #ffffff;
  border-color: #7c63ff;
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(124, 99, 255, 0.15);
}

.bubble-options {
  background: #f7f7fb;
  border: 1px solid #e6e9f5;
}

.options-prompt .bubble {
  font-weight: 600;
}

.options-inline-prompt {
  font-weight: 600;
  margin-bottom: 8px;
}

.option-chip-bubble .bubble {
  display: inline-flex;
  align-items: center;
  padding: 8px 10px;
}

.option-chip-bubble .suggestion-chip {
  margin: 0;
}

.primary-footer {
  position: sticky;
  bottom: 16px; /* lift above absolute bottom */
  width: 100%;
  background: transparent;
  padding: 0 0 12px 0;
}

.primary-footer-options {
  display: none;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  max-width: 900px;
  margin: 0 auto;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #eceff4;
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}

.footer-chip {
  padding: 10px 14px;
  border-radius: 16px;
  border: 1px solid #dde1ff;
  background: #fff;
  color: #1f1f33;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 10px rgba(96, 99, 255, 0.08);
  white-space: nowrap;
}

.footer-chip:hover {
  background: #f7f7ff;
  border-color: #7c63ff;
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(124, 99, 255, 0.18);
}

.input-row {
  display: flex;
  gap: 10px;
}

#chatInput {
  flex: 1;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid #ddd;
  font-size: 0.95rem;
  outline: none;
  /* Ensure it looks good without the button */
  width: 100%;
}

#chatInput:focus {
  border-color: #7c63ff;
}

.send-btn {
  display: none; /* User requested removal */
}

/* Animations */
@keyframes popIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  opacity: 0;
  animation: fadeIn 0.8s forwards;
}

.delay-1 { animation-delay: 0.3s; }

@keyframes fadeIn {
  to { opacity: 1; }
}

/* Responsive */
@media (max-width: 768px) {
  .app-container {
    padding: 0 16px;
  }
  
  .welcome-content h1 {
    font-size: 2rem;
  }

  .cards-grid {
    grid-template-columns: 1fr; /* Stack on mobile */
  }
  
  .chat-container {
    height: calc(100vh - 100px);
    margin-bottom: 0;
  }
}
