/* ==========================================================================
   ROSIE - ROSETTA AI LUXURY JEWELLERY STYLIST & VOICE CONCIERGE
   Aesthetic: Deep Obsidian, Warm Gold, Rose Radiance & Glassmorphism
   Strict Anti-Overflow Mobile Architecture
   ========================================================================== */

/* Rosie AI Concealment per client request (preserved for future use) */
#rosie-launcher,
.rosie-ai-launcher,
#rosie-chat-window,
.rosie-chat-window,
#rosie-backdrop,
.rosie-backdrop {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* 0. Semi-transparent Backdrop (Active on Mobile/Tablet when open) */
.rosie-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 1990;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.rosie-backdrop.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* 1. Floating Launcher Button (Collapsed State) */
.rosie-ai-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1995;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  background: linear-gradient(135deg, #181512 0%, #2b2218 50%, #15120e 100%);
  border: 1.5px solid rgba(197, 160, 89, 0.65);
  padding: 6px 16px 6px 8px;
  border-radius: 50px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 18px rgba(197, 160, 89, 0.25);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  animation: rosieFloat 4s ease-in-out infinite;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  max-width: calc(100vw - 32px);
}

.rosie-ai-launcher:hover {
  transform: translateY(-3px) scale(1.03);
  border-color: #f7eedc;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6), 0 0 24px rgba(197, 160, 89, 0.4);
}

@keyframes rosieFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.rosie-avatar-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #e9268f 0%, #a7144c 60%, #4a041f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 0 12px rgba(233, 38, 143, 0.6);
  flex-shrink: 0;
}

.rosie-avatar-circle svg {
  color: #ffffff;
  animation: diamondSparkle 2.5s infinite;
}

@keyframes diamondSparkle {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.12) rotate(6deg); }
}

.rosie-pulse-ring {
  position: absolute;
  top: -3px;
  left: -3px;
  right: -3px;
  bottom: -3px;
  border-radius: 50%;
  border: 2px solid rgba(233, 38, 143, 0.75);
  animation: pulseExpand 2s infinite;
}

@keyframes pulseExpand {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.35); opacity: 0; }
}

.rosie-launcher-text {
  display: flex;
  flex-direction: column;
}

.rosie-launcher-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #f7eedc;
  letter-spacing: 0.4px;
  display: flex;
  align-items: center;
  gap: 5px;
  line-height: 1.2;
}

.rosie-launcher-title .ai-badge {
  font-size: 0.6rem;
  background: #e9268f;
  color: #ffffff;
  padding: 1px 5px;
  border-radius: 8px;
  font-weight: 800;
}

.rosie-launcher-sub {
  font-size: 0.68rem;
  color: #c5a059;
  font-weight: 500;
  line-height: 1.2;
  margin-top: 2px;
}

/* 2. Main Chatbot Modal Window */
.rosie-chat-window {
  position: fixed;
  bottom: 84px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 100px);
  background: #12100e;
  border: 1.5px solid rgba(197, 160, 89, 0.4);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 35px rgba(197, 160, 89, 0.15);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(20px) scale(0.96);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
}

.rosie-chat-window.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* Drag handle bar (Mobile) */
.rosie-drag-handle-wrap {
  display: none;
  justify-content: center;
  align-items: center;
  padding: 10px 0 4px;
  background: #1b1612;
  cursor: pointer;
  user-select: none;
}

.rosie-drag-bar {
  width: 38px;
  height: 4px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 4px;
}

/* Chat Header */
.rosie-chat-header {
  background: linear-gradient(135deg, #1b1612 0%, #2e2217 60%, #15110d 100%);
  padding: 12px 16px;
  border-bottom: 1px solid rgba(197, 160, 89, 0.3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.rosie-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rosie-header-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e9268f, #a7144c);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px rgba(233, 38, 143, 0.5);
  flex-shrink: 0;
}

.rosie-header-info h4 {
  font-size: 0.9rem;
  color: #f7eedc;
  margin: 0;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.2;
}

.rosie-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #00e676;
  display: inline-block;
  box-shadow: 0 0 6px #00e676;
}

.rosie-header-info p {
  font-size: 0.68rem;
  color: #c5a059;
  margin: 0;
  line-height: 1.2;
}

.rosie-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rosie-icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f7eedc;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1.1rem;
  line-height: 1;
}

.rosie-icon-btn:hover {
  background: rgba(197, 160, 89, 0.25);
  color: #ffffff;
  border-color: #c5a059;
}

.rosie-icon-btn.active-sound {
  color: #e9268f;
  border-color: #e9268f;
}

/* Chat Messages Area */
.rosie-messages-container {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: radial-gradient(circle at 50% 0%, rgba(35, 26, 18, 0.6) 0%, #100e0c 100%);
  scrollbar-width: thin;
  scrollbar-color: rgba(197, 160, 89, 0.3) transparent;
  -webkit-overflow-scrolling: touch;
}

.rosie-messages-container::-webkit-scrollbar {
  width: 4px;
}
.rosie-messages-container::-webkit-scrollbar-thumb {
  background: rgba(197, 160, 89, 0.3);
  border-radius: 4px;
}

/* Message Bubbles */
.rosie-msg {
  display: flex;
  flex-direction: column;
  max-width: 90%;
  font-size: 0.85rem;
  line-height: 1.45;
  animation: fadeInMsg 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.rosie-msg.bot {
  align-self: flex-start;
}

.rosie-msg.user {
  align-self: flex-end;
}

.rosie-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  position: relative;
  word-wrap: break-word;
}

.rosie-msg.bot .rosie-msg-bubble {
  background: #1c1814;
  color: #ede9e1;
  border: 1px solid rgba(197, 160, 89, 0.25);
  border-bottom-left-radius: 4px;
}

.rosie-msg.user .rosie-msg-bubble {
  background: linear-gradient(135deg, #e9268f 0%, #a7144c 100%);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 3px 10px rgba(233, 38, 143, 0.3);
}

.rosie-msg-time {
  font-size: 0.62rem;
  color: #8c857b;
  margin-top: 3px;
  padding: 0 4px;
}

.rosie-msg.user .rosie-msg-time {
  align-self: flex-end;
}

/* Embedded Recommendation Product Card */
.rosie-product-mini-card {
  background: #14110e;
  border: 1px solid rgba(197, 160, 89, 0.35);
  border-radius: 10px;
  padding: 8px;
  margin-top: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
  transition: all 0.2s ease;
}

.rosie-product-mini-card:hover {
  border-color: #f7eedc;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.rosie-card-img {
  width: 50px;
  height: 50px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid rgba(197, 160, 89, 0.2);
  flex-shrink: 0;
}

.rosie-card-details {
  flex: 1;
  min-width: 0;
}

.rosie-card-title {
  font-size: 0.76rem;
  font-weight: 700;
  color: #f7eedc;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rosie-card-specs {
  font-size: 0.66rem;
  color: #c5a059;
  margin-bottom: 3px;
}

.rosie-card-price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rosie-card-price {
  font-size: 0.8rem;
  font-weight: 800;
  color: #ffffff;
}

.rosie-card-btn {
  font-size: 0.66rem;
  background: var(--color-gold, #c5a059);
  color: #111111;
  padding: 3px 7px;
  border-radius: 4px;
  font-weight: 700;
  text-decoration: none;
  transition: 0.2s;
}

.rosie-card-btn:hover {
  background: #ffffff;
}

/* Quick Suggestion Chips */
.rosie-chips-bar {
  padding: 6px 12px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  background: #15120f;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  scrollbar-width: none;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}

.rosie-chips-bar::-webkit-scrollbar {
  display: none;
}

.rosie-chip {
  background: #221d18;
  border: 1px solid rgba(197, 160, 89, 0.35);
  color: #e0dcd5;
  padding: 5px 10px;
  border-radius: 16px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.rosie-chip:hover, .rosie-chip:active {
  background: rgba(233, 38, 143, 0.2);
  border-color: #e9268f;
  color: #ffffff;
}

/* Input Area & Voice Wave Animation */
.rosie-input-wrapper {
  padding: 10px 12px;
  background: #171310;
  border-top: 1px solid rgba(197, 160, 89, 0.25);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.rosie-input-field {
  flex: 1;
  background: #221d17;
  border: 1px solid rgba(197, 160, 89, 0.3);
  padding: 9px 12px;
  color: #ffffff;
  border-radius: 20px;
  font-size: 0.85rem;
  outline: none;
  transition: 0.2s;
  min-width: 0;
}

.rosie-input-field:focus {
  border-color: #e9268f;
  background: #29231c;
  box-shadow: 0 0 0 2px rgba(233, 38, 143, 0.2);
}

.rosie-mic-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #241d17;
  border: 1px solid rgba(197, 160, 89, 0.4);
  color: #c5a059;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.rosie-mic-btn:hover {
  background: rgba(197, 160, 89, 0.2);
  color: #ffffff;
}

.rosie-mic-btn.listening {
  background: #e9268f;
  color: #ffffff;
  border-color: #e9268f;
  animation: micPulse 1.2s infinite alternate;
}

@keyframes micPulse {
  from { transform: scale(1); box-shadow: 0 0 6px #e9268f; }
  to { transform: scale(1.15); box-shadow: 0 0 18px #e9268f; }
}

.rosie-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c5a059, #a38241);
  border: none;
  color: #111111;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.rosie-send-btn:hover {
  background: linear-gradient(135deg, #f7eedc, #c5a059);
  transform: scale(1.05);
}

/* Typing Indicator Animation */
.rosie-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: #1c1814;
  border-radius: 10px;
  width: fit-content;
  border: 1px solid rgba(197, 160, 89, 0.2);
}

.rosie-typing-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #c5a059;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

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

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   STRICT MOBILE RESPONSIVE RULES (Max Width: 768px)
   Zero Horizontal Slide / Clean Floating Alignment
   ========================================================================== */
@media (max-width: 768px) {
  /* 1. Super-Compact Floating Launcher (Pinned to true right viewport) */
  .rosie-ai-launcher {
    bottom: 20px;
    right: 14px;
    left: auto;
    padding: 5px 12px 5px 6px;
    gap: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.65), 0 0 14px rgba(197, 160, 89, 0.3);
  }

  /* Automatically elevate above sticky bars on PDP so it never blocks Add to Bag */
  body:has(.mobile-sticky-pdp-bar) .rosie-ai-launcher,
  body:has(.pdp-section) .rosie-ai-launcher,
  body.has-pdp-sticky-bar .rosie-ai-launcher,
  .pdp-section ~ .rosie-ai-launcher {
    bottom: 84px !important;
    padding: 4px !important;
    border-radius: 50% !important;
    width: 44px !important;
    height: 44px !important;
    justify-content: center !important;
  }

  body:has(.pdp-section) .rosie-launcher-text,
  .pdp-section ~ .rosie-ai-launcher .rosie-launcher-text {
    display: none !important;
  }

  .rosie-avatar-circle {
    width: 34px;
    height: 34px;
  }

  .rosie-avatar-circle svg {
    width: 17px;
    height: 17px;
  }

  .rosie-launcher-title {
    font-size: 0.8rem;
  }

  .rosie-launcher-sub {
    display: none; /* Hide subtitle completely on mobile */
  }

  /* 2. Compact Bottom-Sheet Modal (Centered within mobile viewport without overflow) */
  .rosie-chat-window {
    bottom: 10px;
    right: 10px;
    left: 10px;
    width: auto;
    max-width: calc(100vw - 20px);
    height: 74vh;
    max-height: 520px;
    border-radius: 18px;
    border: 1.5px solid rgba(197, 160, 89, 0.45);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.9), 0 0 25px rgba(197, 160, 89, 0.2);
  }

  .rosie-drag-handle-wrap {
    display: flex;
  }

  .rosie-chat-header {
    padding: 10px 14px;
  }

  .rosie-messages-container {
    padding: 12px;
    gap: 10px;
  }

  .rosie-msg {
    max-width: 94%;
    font-size: 0.82rem;
  }

  .rosie-msg-bubble {
    padding: 8px 12px;
    border-radius: 12px;
  }

  .rosie-input-wrapper {
    padding: 8px 10px;
    gap: 6px;
  }

  .rosie-input-field {
    padding: 8px 10px;
    font-size: 0.82rem;
  }

  .rosie-mic-btn, .rosie-send-btn {
    width: 34px;
    height: 34px;
  }
}
