/**
 * Riviera Limited — Chatbot & WhatsApp Styles
 * @package Riviera
 */

/* ========================================================
   FLOATING ACTION BUTTONS (FAB)
   ======================================================== */
.riviera-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.riviera-fab__wa {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #25D366;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(37, 211, 102, .35);
  transition: transform .25s ease, box-shadow .25s ease;
  text-decoration: none;
}

.riviera-fab__wa:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(37, 211, 102, .5);
}

.riviera-fab__chat {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--red, #C8102E);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(200, 16, 46, .4);
  transition: transform .25s ease, box-shadow .25s ease, background .25s ease;
  position: relative;
}

.riviera-fab__chat:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(200, 16, 46, .55);
}

.riviera-fab__icon-close {
  display: none;
}

.riviera-fab.chat-open .riviera-fab__icon-open {
  display: none;
}

.riviera-fab.chat-open .riviera-fab__icon-close {
  display: block;
}

.riviera-fab.chat-open .riviera-fab__wa {
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
}

/* Pulse animation on chat button */
.riviera-fab__chat::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--red, #C8102E);
  opacity: 0;
  animation: fabPulse 3s ease-out infinite;
}

@keyframes fabPulse {
  0% { transform: scale(1); opacity: .6; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* ========================================================
   CHAT WINDOW
   ======================================================== */
.riviera-chat {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  max-height: 560px;
  z-index: 9998;
  background: rgba(18, 18, 18, .97);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 48px rgba(0, 0, 0, .5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transform: translateY(20px) scale(.95);
  opacity: 0;
  pointer-events: none;
  transition: transform .3s cubic-bezier(.34, 1.56, .64, 1), opacity .25s ease;
}

.riviera-chat.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* ----- Header ----- */
.riviera-chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(200, 16, 46, .12);
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.riviera-chat__header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.riviera-chat__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--red, #C8102E);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.riviera-chat__name {
  font-family: var(--serif, 'Cinzel', serif);
  font-size: .85rem;
  font-weight: 500;
  letter-spacing: .04em;
  color: #fff;
}

.riviera-chat__status {
  font-size: .7rem;
  color: rgba(255, 255, 255, .5);
  display: flex;
  align-items: center;
  gap: 5px;
}

.riviera-chat__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #25D366;
  display: inline-block;
}

.riviera-chat__close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, .5);
  cursor: pointer;
  padding: 4px;
  transition: color .2s;
}

.riviera-chat__close:hover {
  color: #fff;
}

/* ----- Messages Area ----- */
.riviera-chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 300px;
  max-height: 360px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .1) transparent;
}

.riviera-chat__messages::-webkit-scrollbar {
  width: 4px;
}

.riviera-chat__messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .1);
  border-radius: 2px;
}

/* ----- Message Bubbles ----- */
.riviera-chat__msg {
  display: flex;
  animation: msgFadeIn .3s ease;
}

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

.riviera-chat__msg--user {
  justify-content: flex-end;
}

.riviera-chat__msg--bot {
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.riviera-chat__bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: .82rem;
  line-height: 1.55;
  font-weight: 300;
  word-break: break-word;
}

.riviera-chat__bubble--user {
  background: var(--red, #C8102E);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.riviera-chat__bubble--bot {
  background: rgba(255, 255, 255, .07);
  color: rgba(255, 255, 255, .85);
  border-bottom-left-radius: 4px;
}

.riviera-chat__bubble--bot strong {
  color: var(--gold, #C5A47E);
  font-weight: 600;
}

/* ----- Action Buttons (WhatsApp links in chat) ----- */
.riviera-chat__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-left: 4px;
}

.riviera-chat__action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 500;
  text-decoration: none;
  transition: transform .2s, box-shadow .2s;
}

.riviera-chat__action-btn--wa {
  background: #25D366;
  color: #fff;
}

.riviera-chat__action-btn--wa:hover {
  transform: scale(1.04);
  box-shadow: 0 3px 12px rgba(37, 211, 102, .35);
}

/* ----- Quick Replies ----- */
.riviera-chat__quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0;
  animation: msgFadeIn .3s ease;
}

.riviera-chat__qr {
  padding: 6px 14px;
  border: 1px solid rgba(200, 16, 46, .4);
  border-radius: 20px;
  background: rgba(200, 16, 46, .08);
  color: rgba(255, 255, 255, .8);
  font-size: .72rem;
  cursor: pointer;
  transition: background .2s, border-color .2s, color .2s;
  white-space: nowrap;
  font-family: var(--sans, 'Montserrat', sans-serif);
}

.riviera-chat__qr:hover {
  background: var(--red, #C8102E);
  border-color: var(--red, #C8102E);
  color: #fff;
}

/* ----- Typing Indicator ----- */
.riviera-chat__typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, .05);
  border-radius: 14px;
  width: fit-content;
  border-bottom-left-radius: 4px;
}

.riviera-chat__typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .3);
  animation: typingBounce 1.2s ease-in-out infinite;
}

.riviera-chat__typing span:nth-child(2) {
  animation-delay: .15s;
}

.riviera-chat__typing span:nth-child(3) {
  animation-delay: .3s;
}

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .3; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ----- Input Row ----- */
.riviera-chat__input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, .06);
  background: rgba(18, 18, 18, .6);
}

.riviera-chat__input {
  flex: 1;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 24px;
  padding: 10px 16px;
  color: #fff;
  font-size: .82rem;
  font-family: var(--sans, 'Montserrat', sans-serif);
  outline: none;
  transition: border-color .2s;
}

.riviera-chat__input::placeholder {
  color: rgba(255, 255, 255, .35);
}

.riviera-chat__input:focus {
  border-color: var(--red, #C8102E);
}

.riviera-chat__send {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: var(--red, #C8102E);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform .2s, background .2s;
}

.riviera-chat__send:hover {
  transform: scale(1.08);
  background: #a00d24;
}

/* ========================================================
   PRODUCT CARD — WHATSAPP ORDER BUTTON
   ======================================================== */
.product-wa-order {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 7px 16px;
  border-radius: 20px;
  background: #25D366;
  color: #fff;
  font-size: .7rem;
  font-weight: 500;
  text-decoration: none;
  transition: transform .2s, box-shadow .2s;
  letter-spacing: .02em;
}

.product-wa-order:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(37, 211, 102, .4);
}

.product-wa-order svg {
  flex-shrink: 0;
}

/* ========================================================
   PRODUCT MODAL — WHATSAPP ORDER BUTTON
   ======================================================== */
.modal-wa-order {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 1.5rem;
  padding: 10px 24px;
  border-radius: 24px;
  background: #25D366;
  color: #fff;
  font-size: .8rem;
  font-weight: 500;
  text-decoration: none;
  transition: transform .2s, box-shadow .2s;
  letter-spacing: .02em;
}

.modal-wa-order:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 18px rgba(37, 211, 102, .4);
}

/* ========================================================
   LIGHT THEME OVERRIDES
   ======================================================== */
.light-theme .riviera-chat {
  background: rgba(255, 255, 255, .97);
  border-color: rgba(0, 0, 0, .08);
  box-shadow: 0 12px 48px rgba(0, 0, 0, .15);
}

.light-theme .riviera-chat__header {
  background: rgba(200, 16, 46, .06);
  border-bottom-color: rgba(0, 0, 0, .06);
}

.light-theme .riviera-chat__name {
  color: var(--onyx, #121212);
}

.light-theme .riviera-chat__status {
  color: rgba(0, 0, 0, .45);
}

.light-theme .riviera-chat__close {
  color: rgba(0, 0, 0, .4);
}

.light-theme .riviera-chat__close:hover {
  color: var(--onyx, #121212);
}

.light-theme .riviera-chat__bubble--bot {
  background: rgba(0, 0, 0, .05);
  color: rgba(0, 0, 0, .8);
}

.light-theme .riviera-chat__bubble--bot strong {
  color: #8B6914;
}

.light-theme .riviera-chat__qr {
  border-color: rgba(200, 16, 46, .25);
  background: rgba(200, 16, 46, .04);
  color: rgba(0, 0, 0, .7);
}

.light-theme .riviera-chat__qr:hover {
  background: var(--red, #C8102E);
  color: #fff;
}

.light-theme .riviera-chat__typing span {
  background: rgba(0, 0, 0, .2);
}

.light-theme .riviera-chat__typing {
  background: rgba(0, 0, 0, .04);
}

.light-theme .riviera-chat__input-row {
  background: rgba(245, 245, 245, .8);
  border-top-color: rgba(0, 0, 0, .06);
}

.light-theme .riviera-chat__input {
  background: rgba(0, 0, 0, .04);
  border-color: rgba(0, 0, 0, .1);
  color: var(--onyx, #121212);
}

.light-theme .riviera-chat__input::placeholder {
  color: rgba(0, 0, 0, .35);
}

.light-theme .riviera-chat__messages {
  scrollbar-color: rgba(0, 0, 0, .1) transparent;
}

.light-theme .riviera-chat__messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, .1);
}

/* ========================================================
   RESPONSIVE
   ======================================================== */
@media (max-width: 480px) {
  .riviera-chat {
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 16px 16px 0 0;
  }

  .riviera-chat__messages {
    max-height: calc(100vh - 140px);
    max-height: calc(100dvh - 140px);
  }

  .riviera-fab {
    bottom: 16px;
    right: 16px;
  }

  .riviera-fab__wa {
    width: 46px;
    height: 46px;
  }

  .riviera-fab__chat {
    width: 50px;
    height: 50px;
  }
}

@media (max-width: 768px) {
  .riviera-chat {
    width: min(380px, calc(100vw - 20px));
    right: 10px;
    bottom: 90px;
  }
}

/* Safe area for notched phones */
@supports (padding: max(0px)) {
  .riviera-fab {
    bottom: max(24px, env(safe-area-inset-bottom));
    right: max(24px, env(safe-area-inset-right));
  }

  .riviera-chat__input-row {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .riviera-chat {
    transition: opacity .15s ease;
    transform: none;
  }

  .riviera-chat.open {
    transform: none;
  }

  .riviera-fab__chat::after {
    animation: none;
  }

  .riviera-chat__typing span {
    animation: none;
    opacity: .5;
  }

  .riviera-chat__msg {
    animation: none;
  }

  .riviera-chat__quick-replies {
    animation: none;
  }
}

/* Print: hide everything */
@media print {
  .riviera-fab,
  .riviera-chat {
    display: none !important;
  }
}
