/* Gift Advisor - Standalone styles */
/* Inspired by havanora-shopify, gift-focused aesthetic */

:root {
  --bg: #faf9f7;
  --bg-card: #ffffff;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --accent: #c45c3e;
  --accent-hover: #a84d33;
  --accent-soft: rgba(196, 92, 62, 0.12);
  --border: rgba(26, 26, 26, 0.08);
  --border2: rgba(26, 26, 26, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(26, 26, 26, 0.06);
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Fraunces', Georgia, serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

.ga-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.ga-header {
  padding: 1.5rem 1.5rem 1rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.ga-header__inner {
  max-width: 640px;
  margin: 0 auto;
}

.ga-logo {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.48rem;
}

.ga-logo__mark {
  width: 1.55rem;
  height: 1.55rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--accent-soft);
  font-size: 0.95rem;
  line-height: 1;
}

.ga-tagline {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Main chat area */
.ga-main {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 1rem;
}

.ga-chat {
  width: 100%;
  max-width: 680px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 62vh;
}

.ga-chat__shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.ga-chat__center {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Occasion chips */
.ga-occasion {
  margin-bottom: 0.5rem;
  display: none;
}

.ga-occasion__label {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.ga-occasion__label--sub {
  margin-top: 1.15rem;
}

.ga-occasion__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ga-chip {
  padding: 0.5rem 1rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ga-chip:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.ga-chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* Hero — centered welcome, shown before any messages */
.ga-hero {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  text-align: center;
}

.ga-hero__tagline {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 400;
  font-style: italic;
  color: var(--text-muted);
  line-height: 1.5;
  max-width: 26ch;
}

.ga-hero.is-hidden {
  display: none;
}

/* Messages */
.ga-messages {
  flex: 1;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.ga-msg {
  margin-bottom: 1rem;
  animation: ga-fade-in 0.3s ease;
}

@keyframes ga-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.ga-msg__wrap {
  display: flex;
  justify-content: flex-start;
}

.ga-msg--user .ga-msg__wrap {
  justify-content: flex-end;
}

.ga-msg__bubble {
  max-width: 85%;
  padding: 0.48rem 0.74rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  line-height: 1.42;
  white-space: pre-wrap;
  word-break: break-word;
}

.ga-msg__bubble:has(.ga-results) {
  max-width: 100%;
}

.ga-msg--assistant .ga-msg__bubble {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
}

.ga-msg--user .ga-msg__bubble {
  background: var(--accent);
  color: white;
  border: none;
}

.ga-typing {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.ga-typing__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: ga-bounce 1.4s ease-in-out infinite both;
}

.ga-typing__dot:nth-child(1) { animation-delay: -0.32s; }
.ga-typing__dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes ga-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.6; }
  40% { transform: scale(1); opacity: 1; }
}

/* Results container - LLM brief at top, then carousels */
.ga-results {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 100%;
  min-width: 0;
}

.ga-results__brief {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.ga-reply p,
.ga-results__brief p {
  margin: 0;
}

/* Carousel section - title, subtitle, horizontal scroll */
.ga-carousel-section {
  margin-top: 0.5rem;
  overflow: hidden;
}

.ga-carousel-section__header {
  margin-bottom: 0.75rem;
}

.ga-carousel-section__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.ga-carousel-section__subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Loading state - single state until products ready */
.ga-loading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 0;
}

.ga-loading__spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: ga-spin 0.8s linear infinite;
  flex-shrink: 0;
}

.ga-loading__text {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.ga-loading__dots {
  display: inline-flex;
  gap: 2px;
  margin-left: 2px;
}

.ga-loading__dots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: ga-bounce 1.4s ease-in-out infinite both;
}

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

.ga-results__brief ul,
.ga-reply ul {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
}

.ga-results__brief li,
.ga-reply li {
  margin: 0.25rem 0;
}

.ga-reply {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
}

/* Products loading animation */
.ga-products-loading {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.ga-products-loading__spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: ga-spin 0.8s linear infinite;
}

.ga-products-loading__text {
  font-size: 0.9rem;
  color: var(--text-muted);
}

@keyframes ga-spin {
  to { transform: rotate(360deg); }
}

.ga-carousel {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 0.5rem;
  padding-right: 0.5rem;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.ga-carousel::-webkit-scrollbar {
  height: 6px;
}

.ga-carousel::-webkit-scrollbar-track {
  background: var(--border);
  border-radius: 3px;
}

.ga-carousel::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 3px;
}

.ga-product {
  flex: 0 0 200px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ga-product:hover {
  border-color: var(--border2);
  box-shadow: var(--shadow);
}

.ga-product__link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.ga-product__img-wrap {
  position: relative;
}

.ga-product__img {
  aspect-ratio: 1;
  background: rgba(26, 26, 26, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.ga-product__img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ga-product__placeholder {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.ga-product__body {
  padding: 0.85rem;
  flex: 1;
  min-width: 0;
}

.ga-product__title {
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ga-product__rating {
  font-size: 0.82rem;
  color: #262626;
  margin-top: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.18rem;
}

.ga-product__rating-value {
  font-weight: 500;
}

.ga-product__stars-text {
  color: #f28c1b;
  letter-spacing: -0.02em;
  font-size: 0.9em;
}

.ga-product__reviews-count {
  color: #666;
  margin-left: 0.05rem;
}

.ga-product__stars {
  display: inline-flex;
  gap: 1px;
}

.ga-star {
  width: 14px;
  height: 14px;
  display: inline-block;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23FFA41C'%3E%3Cpath d='M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z'/%3E%3C/svg%3E") center/contain no-repeat;
}

.ga-star--full {
  opacity: 1;
}

.ga-star--empty {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ddd'%3E%3Cpath d='M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z'/%3E%3C/svg%3E") center/contain no-repeat;
}

.ga-star--partial {
  position: relative;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ddd'%3E%3Cpath d='M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z'/%3E%3C/svg%3E") center/contain no-repeat;
}

.ga-star--partial::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23FFA41C'%3E%3Cpath d='M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z'/%3E%3C/svg%3E") left center/contain no-repeat;
  clip-path: inset(0 calc(100% - var(--fill, 50%)) 0 0);
}

.ga-product__rating-text {
  margin-left: 0.15rem;
}

.ga-product__price {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 0.5rem;
}

.ga-product__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  padding: 0 0.65rem 0.6rem;
}

.ga-feedback {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--border2);
  background: transparent;
  color: #777;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 13px;
  line-height: 1;
}

.ga-feedback:hover {
  border-color: #c7c7c7;
  background: #f1f1f1;
  color: #555;
}

.ga-feedback:focus-visible {
  outline: 2px solid var(--accent-soft);
  outline-offset: 1px;
}

.ga-feedback.is-active {
  border-color: #b9b9b9;
  background: #dbdbdb;
  color: #3f3f3f;
}

.ga-feedback-toast {
  position: fixed;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%) translateY(8px);
  background: rgba(35, 35, 35, 0.9);
  color: #fff;
  font-size: 0.78rem;
  padding: 0.38rem 0.58rem;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
  z-index: 30;
}

.ga-feedback-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Composer */
.ga-composer {
  padding: 1rem 1.5rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}

.ga-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ga-inputwrap {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ga-inputwrap:focus-within {
  border-color: var(--border2);
  box-shadow: none;
}

.ga-input {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 0.6rem 0.5rem;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--text);
  background: transparent;
  border: none;
  resize: none;
  outline: none;
}

.ga-input::placeholder {
  color: var(--text-muted);
}

.ga-send {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
}

.ga-send:hover {
  background: var(--accent-hover);
}

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

.ga-send svg {
  width: 20px;
  height: 20px;
}

@media (max-width: 768px) {
  .ga-header {
    padding: 0.85rem 0.75rem 0.5rem;
  }

  .ga-logo {
    font-size: 1.45rem;
  }

  .ga-logo__mark {
    width: 1.35rem;
    height: 1.35rem;
    font-size: 0.82rem;
  }

  .ga-tagline {
    margin-top: 0.1rem;
    font-size: 0.8rem;
  }

  .ga-main {
    padding: 0.2rem;
  }

  .ga-chat {
    max-width: none;
    min-height: unset;
    /* Clearance below last message so it never hides behind the fixed composer. */
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom));
  }

  .ga-chat__center {
    padding: 0.55rem 0.5rem 0;
    padding-bottom: 0.5rem;
    gap: 0.55rem;
  }

  .ga-occasion {
    margin-bottom: 0.25rem;
  }

  .ga-occasion__label {
    margin-bottom: 0.45rem;
    font-size: 0.82rem;
  }

  .ga-occasion__label--sub {
    margin-top: 0.85rem;
  }

  .ga-occasion__chips {
    gap: 0.4rem;
  }

  .ga-chip {
    padding: 0.42rem 0.78rem;
    font-size: 0.84rem;
  }

  .ga-feedback-toast {
    bottom: 82px;
  }

  .ga-messages {
    min-height: 0;
  }

  .ga-composer {
    position: fixed;
    left: 0.2rem;
    right: 0.2rem;
    bottom: 0;
    z-index: 14;
    padding: 0.55rem 0.5rem calc(0.9rem + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 16px rgba(26, 26, 26, 0.06);
  }
}
