/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --color-primary: #10a37f;
  --color-user: #5436DA;
  --color-bg: #ffffff;
  --color-text: #202123;
  --color-border: #ececf1;
  --color-bg-light: #f7f7f8;
  --color-error: #ef4444;
  --color-success: #10a37f;
  --max-width: 768px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
}

/* Lock body scroll when chatting on mobile */
body.chatting {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100vh;
}

@media (min-width: 769px) {
  /* On desktop, allow normal scrolling */
  body.chatting {
    overflow-y: auto;
    position: relative;
  }
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem;
  width: 100%;
}

/* Header */
.header {
  padding: 1rem 0;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.logo {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
}

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

/* Main Navigation */
.main-nav {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.main-nav a {
  color: #666;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
}

.main-nav a:hover {
  color: #111;
}

@media (max-width: 640px) {
  .main-nav {
    gap: 1rem;
  }
  .main-nav a {
    font-size: 0.8rem;
  }
}

/* Reset icon button in header - positioned next to logo */
.reset-icon-button {
  background: transparent;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: #9ca3af;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
}

.reset-icon-button:hover {
  color: var(--color-text);
  background: var(--color-bg-light);
}

.reset-icon-button svg {
  display: block;
}

/* Main content - Chat area only (first fold) */
.main-content {
  height: 100vh; /* Exactly viewport height - no more */
  display: block;
  box-sizing: border-box;
  position: relative; /* For absolute positioning of input */
  overflow: hidden; /* Prevent main content from scrolling */
  padding-bottom: 270px; /* Reserve space for input */
}

/* Welcome section */
.welcome {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  text-align: center;
  min-height: 50vh;
}

.welcome.hidden {
  display: none !important;
}

.welcome-content {
  max-width: 600px;
  margin: 0 auto;
}

.welcome-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--color-text);
}

.welcome-intro {
  font-size: 1.125rem;
  color: #444;
  line-height: 1.7;
  margin-bottom: 2rem;
  max-width: 650px;
  margin-left: auto;
  margin-right: auto;
}

.welcome-subtitle {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.5rem;
  margin-top: 1rem;
}

.welcome-description {
  font-size: 1rem;
  color: #6e6e80;
  line-height: 1.5;
}

/* Chat container */
.chat-container {
  width: 100%;
  height: calc(100vh - 270px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  margin: 0;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Chat messages */
.message {
  display: flex;
  padding: 1rem 0;
  opacity: 0;
  animation: fadeIn 0.3s ease forwards;
  width: 100%;
  justify-content: center;
}

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

.message.user {
  background: transparent;
}

.message.assistant {
  background: transparent;
}

.message-wrapper {
  width: 100%;
  max-width: var(--max-width);
  padding: 0 1rem;
  box-sizing: border-box;
  display: flex;
}

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

.message.assistant .message-wrapper {
  justify-content: flex-start;
}

.message-content {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
  max-width: 100%;
}

.message.user .message-content {
  background: #f4f4f4;
  border-radius: 18px;
  padding: 0.75rem 1rem;
}

.message.assistant .message-content {
  background: transparent;
  padding: 0;
}

/* Typing indicator */
.typing-indicator {
  opacity: 1 !important;
}

.typing-indicator .message-content {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: #6e6e80;
  font-style: italic;
}

.typing-text {
  font-size: 0.95rem;
}

.typing-dots {
  display: inline-flex;
  gap: 1px;
}

.typing-dots span {
  animation: typingDots 1.4s ease-in-out infinite;
  opacity: 0.4;
}

.typing-dots span:nth-child(1) {
  animation-delay: 0s;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingDots {
  0%, 60%, 100% {
    opacity: 0.4;
  }
  30% {
    opacity: 1;
  }
}

/* Legacy typing dot (for backwards compatibility) */
.typing-dot {
  display: flex;
  padding: 0.5rem 0;
  align-items: center;
}

.typing-dot span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #000000;
  animation: chatPulse 1s ease-in-out infinite;
}

@keyframes chatPulse {
  0%, 100% {
    opacity: 0.5;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.3);
  }
}

/* Budget selection UI */
.budget-selection {
  margin: 1rem 0;
  padding: 1rem;
  border-radius: 8px;
  background: var(--color-bg-light);
  animation: fadeIn 0.3s ease;
}

.budget-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin: 1rem 0;
}

.budget-option {
  background: white;
  border: 2px solid var(--color-border);
  border-radius: 8px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.budget-option:hover {
  border-color: var(--color-primary);
  background: #e6f7f1;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(16, 163, 127, 0.15);
}

.budget-option.selected {
  border-color: var(--color-primary);
  background: #e6f7f1;
}

.budget-icon {
  font-size: 1.5rem;
}

.budget-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text);
}

/* SEO Section - Completely separate from chat, always visible below the fold */
.seo-section {
  background: var(--color-bg-light);
  border-top: 1px solid var(--color-border);
  padding: 4rem 0;
  margin-top: 2rem;
}

/* Profession cards */
.profession-cards {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.cards-title {
  font-size: 1.75rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 2.5rem;
  color: var(--color-text);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.profession-card {
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  text-align: center;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-text);
  transition: all 0.2s ease;
  background: white;
}

.profession-card:hover {
  border-color: var(--color-primary);
  background: var(--color-bg-light);
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.card-icon {
  font-size: 1.5rem;
}

.card-label {
  font-weight: 500;
  font-size: 0.875rem;
}

/* Chat input - Fixed at bottom, above scrollable area */
.chat-input-wrapper {
  position: absolute;
  bottom: 150px; /* Position it higher on the page */
  left: 0;
  right: 0;
  height: 120px;
  background: linear-gradient(to top, var(--color-bg) 85%, transparent);
  padding: 2rem 0;
  z-index: 50;
  pointer-events: none; /* Allow clicking through the gradient */
  display: flex;
  align-items: center;
}

.chat-input-wrapper > * {
  pointer-events: auto; /* Re-enable clicking on input */
}

.chat-input-container {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  transition: border-color 0.2s ease;
}

.chat-input-container:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 4px 20px rgba(16, 163, 127, 0.15);
}

.chat-input {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
  background: transparent;
  padding: 0.25rem 0;
}

.chat-input::placeholder {
  color: #9ca3af;
}

.send-button {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 6px;
  background: var(--color-primary);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
  background: #0d9672;
  transform: scale(1.05);
}

.send-button:disabled {
  background: var(--color-border);
  cursor: not-allowed;
  opacity: 0.5;
}

/* Voice input button */
.voice-button {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 6px;
  background: var(--color-bg-light);
  color: var(--color-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  margin-right: 8px;
}

.voice-button:hover {
  background: var(--color-border);
}

.voice-button.listening {
  background: #ef4444;
  color: white;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
  }
}

/* Validation messages */
.validation-message {
  font-size: 0.875rem;
  margin-top: 0.25rem;
  padding: 0.5rem;
  border-radius: 4px;
}

.validation-message.error {
  color: var(--color-error);
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.validation-message.success {
  color: var(--color-success);
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .main-content {
    height: 100vh;
  }

  .welcome-title {
    font-size: 1.5rem;
  }

  .welcome-subtitle {
    font-size: 1rem;
  }

  .seo-section {
    padding: 3rem 0;
  }

  .cards-title {
    font-size: 1.5rem;
    margin-bottom: 2rem;
  }

  .cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  .budget-options {
    grid-template-columns: 1fr;
  }

  .chat-container {
    padding: 1rem;
  }

  .message {
    padding: 0.75rem;
  }
}

@media (max-width: 640px) {
  .cards-grid {
    grid-template-columns: 1fr;
  }

  .profession-card {
    flex-direction: row;
    justify-content: flex-start;
    text-align: left;
  }
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #d1d1d6;
}

/* Loading state */
.loading {
  pointer-events: none;
  opacity: 0.6;
}

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

.slide-up {
  animation: slideUp 0.3s ease;
}

/* RGPD Consent Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: white;
  border-radius: 16px;
  padding: 2rem;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
  z-index: 1001;
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 1rem;
}

.modal-description {
  color: #6e6e80;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.consent-checkbox-wrapper {
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--color-bg-light);
  border-radius: 8px;
  border: 1px solid var(--color-border);
}

.consent-label {
  display: flex;
  gap: 0.75rem;
  cursor: pointer;
  align-items: flex-start;
}

.consent-checkbox {
  margin-top: 0.25rem;
  width: 18px;
  height: 18px;
  cursor: pointer;
  flex-shrink: 0;
  accent-color: var(--color-primary);
}

.consent-text {
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--color-text);
}

.consent-text a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
}

.consent-text a:hover {
  text-decoration: underline;
}

.modal-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
  justify-content: flex-end;
}

.button-primary,
.button-secondary {
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  outline: none;
}

.button-primary {
  background: var(--color-primary);
  color: white;
}

.button-primary:hover:not(:disabled) {
  background: #0d9672;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 163, 127, 0.3);
}

.button-primary:disabled {
  background: var(--color-border);
  cursor: not-allowed;
  opacity: 0.5;
}

.button-secondary {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.button-secondary:hover {
  background: var(--color-bg-light);
  border-color: var(--color-text);
}

@media (max-width: 640px) {
  .modal-content {
    padding: 1.5rem;
    width: 95%;
  }

  .modal-title {
    font-size: 1.25rem;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .button-primary,
  .button-secondary {
    width: 100%;
  }
}

/* Small modal (for reset confirmation) */
.modal-small {
  max-width: 360px;
  text-align: center;
}

.modal-small .modal-title {
  font-size: 1.25rem;
}

.modal-small .modal-description {
  font-size: 0.95rem;
  color: #666;
  margin-bottom: 1.5rem;
}

.modal-small .modal-actions {
  justify-content: center;
  gap: 0.75rem;
}

/* Fallback Form Styles */
.fallback-form-message {
  opacity: 1 !important;
}

.fallback-form {
  background: linear-gradient(135deg, #f8fafc 0%, #f0f9ff 100%);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 1.5rem;
  max-width: 400px;
  animation: slideUp 0.3s ease;
}

.fallback-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.fallback-icon {
  font-size: 1.5rem;
}

.fallback-header h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}

.fallback-description {
  font-size: 0.95rem;
  color: #6e6e80;
  line-height: 1.5;
  margin-bottom: 1.25rem;
}

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

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

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

.fallback-form input,
.fallback-form textarea {
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background: white;
}

.fallback-form input:focus,
.fallback-form textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

.fallback-form input::placeholder,
.fallback-form textarea::placeholder {
  color: #9ca3af;
}

.fallback-form textarea {
  resize: vertical;
  min-height: 80px;
}

.fallback-submit-btn {
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 0.5rem;
}

.fallback-submit-btn:hover:not(:disabled) {
  background: #0d9672;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 163, 127, 0.3);
}

.fallback-submit-btn:disabled {
  background: var(--color-border);
  cursor: not-allowed;
  opacity: 0.7;
}

/* Fallback Success Message */
.fallback-success {
  text-align: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 1px solid #bbf7d0;
  border-radius: 16px;
  max-width: 400px;
}

.fallback-success .success-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.75rem;
}

.fallback-success h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 0.5rem 0;
}

.fallback-success p {
  font-size: 0.95rem;
  color: #4b5563;
  line-height: 1.5;
  margin: 0;
}

@media (max-width: 640px) {
  .fallback-form {
    padding: 1.25rem;
  }

  .fallback-header h3 {
    font-size: 1rem;
  }

  .fallback-description {
    font-size: 0.875rem;
  }
}
