/*
 * The AI Pet Finder (ai-pet-finder.php): introduction, chat, suggestions and matching listings.
 * Linked from the <head> by the page ($boPageStylesheets).
 */
/* AI Pet Finder Page Styles */

/* Page Header */
.page-header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: white;
  padding: var(--space-2xl) 0 var(--space-xl);
}

.breadcrumb-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  margin-bottom: var(--space-md);
  opacity: 0.8;
}

.breadcrumb-nav a {
  color: white;
  text-decoration: none;
}

.breadcrumb-nav a:hover {
  text-decoration: underline;
}

.breadcrumb-nav .sep {
  width: 4px;
  height: 4px;
  background: rgba(255,255,255,0.4);
  border-radius: 50%;
}

.breadcrumb-nav .current {
  opacity: 0.7;
}

.page-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
}

.page-title-content h1 {
  font-size: 2rem;
  font-weight: 700;
  margin: 0;
  color: #ffffff !important;
}

.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: rgba(255,255,255,0.15);
  padding: 0.25rem 0.75rem;
  border-radius: 100px;
  font-size: var(--text-xs);
  font-weight: 500;
  margin-bottom: var(--space-sm);
}

/* Chat Container */
.chat-container {
  max-width: 800px;
  margin: 0 auto;
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-lg) var(--space-xl);
  background: var(--primary);
  color: white;
}

.chat-status {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 600;
}

.status-indicator {
  width: 10px;
  height: 10px;
  background: #4ade80;
  border-radius: 50%;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(0.9); }
}

.chat-reset {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  background: rgba(255,255,255,0.2);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  padding: var(--space-sm) var(--space-md);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chat-reset:hover {
  background: rgba(255,255,255,0.3);
}

.chat-messages {
  height: 400px;
  overflow-y: auto;
  /* Reaching the top/bottom of the chat doesn't start scrolling the page */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-xl);
  background: #f8fafc;
}

.chat-privacy-note {
  max-width: 800px;
  margin: var(--space-sm) auto 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-align: center;
}

/* Messages */
.message {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  max-width: 85%;
}

.ai-message {
  align-items: flex-start;
}

.user-message {
  margin-left: auto;
  flex-direction: row-reverse;
}

.message-avatar {
  width: 40px;
  height: 40px;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
  border-radius: 50%;
}

.message-content {
  background: white;
  padding: var(--space-md) var(--space-lg);
  line-height: 1.7;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.ai-message .message-content {
  border-top-left-radius: 4px;
}

.user-message .message-content {
  background: var(--primary);
  color: white;
  border-top-right-radius: 4px;
}

.user-message .message-content p {
  color: white;
}

.message-content p {
  margin: 0 0 var(--space-sm);
  color: var(--text-secondary);
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content strong {
  color: var(--text-primary);
}

.user-message .message-content strong {
  color: white;
}

/* Typing Indicator */
.typing-dots {
  display: flex;
  gap: 4px;
  padding: var(--space-xs) 0;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  animation: typing-bounce 1.4s ease-in-out infinite both;
}

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

@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
  40% { transform: scale(1.2); opacity: 1; }
}

/* The security check for a chat's first message sits above the message box.
   It takes no room unless Cloudflare asks the visitor to tick the box. */
.chat-security-check {
  background: white;
}

.chat-security-check .bo-turnstile.is-visible {
  margin: 0;
  padding: var(--space-md) var(--space-xl) 0;
}

/* Chat Input */
.chat-input-wrapper {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-lg) var(--space-xl);
  background: white;
  border-top: 1px solid var(--border-color);
}

.chat-input-wrapper input {
  flex: 1;
  border: 2px solid var(--border-color);
  background: white;
  padding: var(--space-md) var(--space-lg);
  font-size: 1rem;
  color: var(--text-primary);
  border-radius: var(--radius-lg);
  transition: all 0.2s ease;
}

.chat-input-wrapper input::placeholder {
  color: var(--text-light);
}

.chat-input-wrapper input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(44, 85, 48, 0.1);
}

.chat-send {
  width: 52px;
  height: 52px;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-lg);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: all 0.2s ease;
}

.chat-send:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-2px);
}

.chat-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chat-send .send-spinner {
  display: none;
}

.chat-send.loading .send-icon {
  display: none;
}

.chat-send.loading .send-spinner {
  display: block;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Breed Card */
.breed-card {
  background: white;
  border: 2px solid var(--primary);
  border-radius: var(--radius-lg);
  margin-top: var(--space-lg);
  overflow: hidden;
}

.breed-card-header {
  background: var(--primary);
  color: white;
  padding: var(--space-sm) var(--space-md);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.breed-card-body {
  display: flex;
  gap: var(--space-lg);
  padding: var(--space-lg);
}

.breed-card-image {
  width: 120px;
  height: 120px;
  object-fit: cover;
  object-position: center top;
  flex-shrink: 0;
  border-radius: var(--radius-md);
}

.breed-card-info h3 {
  font-size: var(--text-xl);
  color: var(--text-primary);
  margin: 0 0 var(--space-sm);
}

.breed-card-info p {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin: 0 0 var(--space-md);
}

.breed-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}

.breed-link:hover {
  color: var(--primary-dark);
}

/* Adverts Section */
.adverts-section {
  background: #f8fafc;
  padding: var(--space-lg);
  margin-top: var(--space-lg);
  border-radius: var(--radius-lg);
}

.adverts-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 var(--space-md);
}

.adverts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-md);
}

.advert-item {
  background: white;
  text-decoration: none;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.advert-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.advert-item img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  object-position: center top;
}

.advert-item-info {
  padding: var(--space-sm);
}

.advert-item-info h4 {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.no-adverts-msg {
  background: white;
  padding: var(--space-md);
  font-size: var(--text-sm);
  color: var(--text-muted);
  border-radius: var(--radius-md);
}

.no-adverts-msg a {
  color: var(--primary);
  font-weight: 500;
}

/* Steps Grid */
.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-xl);
  max-width: 1000px;
  margin: 0 auto;
}

.step-card {
  text-align: center;
  padding: var(--space-xl);
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: all 0.3s ease;
}

.step-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.step-number {
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 30px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
}

.step-icon {
  width: 70px;
  height: 70px;
  background: var(--primary);
  color: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  margin: 0 auto var(--space-lg);
}

.step-card h3 {
  font-size: var(--text-xl);
  color: var(--text-primary);
  margin: 0 0 var(--space-sm);
}

.step-card p {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin: 0;
  line-height: 1.6;
}

/* Examples Grid */
.section-desc {
  color: var(--text-muted);
  margin-top: var(--space-sm);
}

.examples-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-xl);
  align-items: stretch;
}

.example-card {
  background: white;
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
}

.example-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.example-icon {
  width: 50px;
  height: 50px;
  background: var(--primary);
  color: #ffffff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-bottom: var(--space-md);
}

.example-card h3 {
  font-size: var(--text-lg);
  color: var(--text-primary);
  margin: 0 0 var(--space-lg);
}

.example-chat {
  display: grid;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.chat-bubble {
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-sm);
  line-height: 1.5;
  border-radius: var(--radius-md);
}

.user-bubble {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  margin-left: var(--space-lg);
  border-top-right-radius: 4px;
}

.ai-bubble {
  background: var(--primary);
  color: white;
  margin-right: var(--space-lg);
  border-top-left-radius: 4px;
}

.example-result {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: auto;
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-color);
  color: #16a34a;
  font-size: var(--text-sm);
  font-weight: 600;
}

.example-result i {
  color: #16a34a;
}

.example-preview {
  margin-top: var(--space-md);
}

.example-preview-label {
  color: var(--primary);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-sm);
  text-transform: uppercase;
}

.example-advert {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  height: 137px;
  overflow: hidden;
}

.example-advert img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}

.example-advert-body {
  min-width: 0;
  padding: var(--space-sm) var(--space-md);
}

.example-advert-body h4 {
  color: var(--text-primary);
  font-size: 0.95rem;
  line-height: 1.25;
  margin: 0 0 0.25rem;
}

.example-advert-body p {
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.4;
  margin: 0 0 var(--space-sm);
}

.example-advert-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.375rem 0.75rem;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
}

.example-advert-meta span {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.example-advert-meta i {
  color: var(--primary);
  font-size: 0.75rem;
}

@media (min-width: 993px) {
  .example-chat {
    grid-template-rows: minmax(86px, auto) minmax(126px, auto);
  }

  .chat-bubble {
    display: flex;
    align-items: center;
  }
}

/* Video Layout */
.video-layout {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: var(--space-3xl);
  align-items: center;
}

.video-content h2 {
  margin-top: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.video-content p {
  color: var(--text-muted);
  line-height: 1.8;
  margin-bottom: var(--space-xl);
}

.video-features {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.video-feature {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--text-secondary);
}

.video-feature i {
  color: var(--primary);
  font-size: 1.125rem;
}

.video-player {
  position: relative;
}

.video-wrapper {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #0a0a0a;
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-xl);
}

.video-wrapper video {
  width: 100%;
  height: 100%;
  display: block;
  /* contain, so the native controls and the whole recording stay visible */
  object-fit: contain;
}

/* CTA Section */
.ai-cta {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  padding: var(--space-3xl) 0;
  text-align: center;
}

.cta-content h2 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  margin: 0 0 var(--space-md);
  color: white !important;
}

.cta-content p {
  font-size: 1.125rem;
  opacity: 0.9;
  margin: 0 0 var(--space-xl);
}

.btn-light {
  background: white;
  color: var(--primary-dark);
  border: none;
}

.btn-light:hover {
  background: rgba(255,255,255,0.9);
  color: var(--primary-dark);
}

/* Responsive */
@media (max-width: 1024px) {
  .video-layout {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .video-features {
    align-items: center;
  }
}

@media (max-width: 992px) {
  .steps-grid,
  .examples-grid {
    grid-template-columns: 1fr;
    max-width: 500px;
    margin: 0 auto;
  }
}

@media (max-width: 768px) {
  .page-header {
    padding: var(--space-xl) 0 var(--space-lg);
  }

  .page-title-content h1 {
    font-size: 1.5rem;
  }

  .chat-messages {
    height: 350px;
    /* leave room for the input and the on-screen keyboard on short phones */
    max-height: 60vh;
  }

  .breed-card-body {
    flex-direction: column;
  }

  .breed-card-image {
    width: 100%;
    height: 160px;
  }
}

@media (max-width: 576px) {
  .chat-header {
    padding: var(--space-md);
  }

  .chat-input-wrapper {
    padding: var(--space-md);
  }

  .message {
    max-width: 95%;
  }
}

.animate-in {
  animation: fadeInUp 0.4s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .animate-in {
    animation: none;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
