﻿/* ============================================================
   PREM AI - WIDGET STYLES
   Part A: Base, floating button, window container
   ============================================================ */

/* ---------- BASE ---------- */
#prem-ai-root,
#prem-ai-root * {
  box-sizing: border-box;
  font-family: var(--prem-font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#prem-ai-root {
  position: relative;
  z-index: var(--prem-z-widget);
}

/* ---------- FLOATING PILL BUTTON ---------- */
.prem-launcher {
  position: fixed;
  bottom: var(--prem-space-6);
  right: var(--prem-space-6);
  display: inline-flex;
  align-items: center;
  gap: var(--prem-space-3);
  padding: var(--prem-space-3) var(--prem-space-5) var(--prem-space-3) var(--prem-space-4);
  background: linear-gradient(135deg, var(--prem-primary) 0%, var(--prem-primary-light) 100%);
  color: var(--prem-text-on-primary);
  border: none;
  border-radius: var(--prem-radius-pill);
  box-shadow: var(--prem-shadow-lg);
  cursor: pointer;
  transition:
    transform var(--prem-duration-base) var(--prem-ease-spring),
    box-shadow var(--prem-duration-base) var(--prem-ease);
  font-weight: var(--prem-fw-medium);
  font-size: var(--prem-fs-sm);
  line-height: 1;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.prem-launcher:hover {
  transform: translateY(-2px);
  box-shadow: var(--prem-shadow-xl);
}

.prem-launcher:active {
  transform: translateY(0);
}

.prem-launcher__avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--prem-radius-pill);
  background: rgba(255, 255, 255, 0.15);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--prem-fs-md);
  flex-shrink: 0;
}

.prem-launcher__label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.prem-launcher__name {
  font-weight: var(--prem-fw-semibold);
  font-size: var(--prem-fs-sm);
}

.prem-launcher__status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--prem-fs-xs);
  opacity: 0.85;
}

.prem-launcher__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ADE80;
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.3);
  animation: prem-pulse 2s ease-in-out infinite;
}

@keyframes prem-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

/* ---------- CHAT WINDOW ---------- */
.prem-window {
  position: fixed;
  bottom: var(--prem-space-6);
  right: var(--prem-space-6);
  width: var(--prem-widget-width);
  height: var(--prem-widget-height);
  max-height: calc(100vh - 48px);
  background: var(--prem-surface);
  border-radius: var(--prem-radius-xl);
  box-shadow: var(--prem-shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  transform-origin: bottom right;
  pointer-events: none;
  transition:
    opacity var(--prem-duration-base) var(--prem-ease),
    transform var(--prem-duration-base) var(--prem-ease-spring);
}

.prem-window.prem-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ---------- RTL SUPPORT ---------- */
[dir="rtl"] .prem-launcher,
[dir="rtl"] .prem-window {
  right: auto;
  left: var(--prem-space-6);
}

[dir="rtl"] .prem-window {
  transform-origin: bottom left;
}

/* ---------- MOBILE ---------- */
@media (max-width: 480px) {
  .prem-launcher {
    bottom: var(--prem-space-4);
    right: var(--prem-space-4);
    padding: var(--prem-space-3);
  }

  .prem-launcher__label {
    display: none;
  }

  .prem-window {
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    transform: translateY(100%);
    transform-origin: center bottom;
  }

  .prem-window.prem-open {
    transform: translateY(0);
  }
}

/* ---------- REDUCED MOTION ---------- */
@media (prefers-reduced-motion: reduce) {
  .prem-window { transform: none; }
  .prem-window.prem-open { transform: none; }
  .prem-launcher:hover { transform: none; }
  .prem-launcher__dot { animation: none; }
}

/* ============================================================
   Part B: Header, messages, bubbles, typing
   ============================================================ */

/* ---------- HEADER ---------- */
.prem-header {
  height: var(--prem-header-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--prem-space-3);
  padding: 0 var(--prem-space-4);
  background: linear-gradient(135deg, var(--prem-primary) 0%, var(--prem-primary-light) 100%);
  color: var(--prem-text-on-primary);
}

.prem-header__avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--prem-radius-pill);
  background: rgba(255, 255, 255, 0.15);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--prem-fs-lg);
  flex-shrink: 0;
}

.prem-header__info {
  flex: 1;
  min-width: 0;
}

.prem-header__name {
  font-weight: var(--prem-fw-semibold);
  font-size: var(--prem-fs-md);
  line-height: 1.2;
  margin: 0;
}

.prem-header__status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--prem-fs-xs);
  opacity: 0.9;
}

.prem-header__actions {
  display: flex;
  align-items: center;
  gap: var(--prem-space-1);
}

.prem-iconbtn {
  width: 32px;
  height: 32px;
  border-radius: var(--prem-radius-sm);
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--prem-duration-fast) var(--prem-ease);
}

.prem-iconbtn:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* ---------- MESSAGES AREA ---------- */
.prem-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--prem-space-5) var(--prem-space-4);
  display: flex;
  flex-direction: column;
  gap: var(--prem-space-3);
  background: var(--prem-surface);
  scroll-behavior: smooth;
}

.prem-messages::-webkit-scrollbar { width: 6px; }
.prem-messages::-webkit-scrollbar-track { background: transparent; }
.prem-messages::-webkit-scrollbar-thumb {
  background: var(--prem-border);
  border-radius: var(--prem-radius-pill);
}

/* ---------- MESSAGE BUBBLES ---------- */
.prem-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: prem-msg-in var(--prem-duration-slow) var(--prem-ease-out) both;
}

@keyframes prem-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.prem-msg--ai,
.prem-msg--human {
  align-self: flex-start;
  align-items: flex-start;
}

.prem-msg--visitor {
  align-self: flex-end;
  align-items: flex-end;
}

.prem-msg__bubble {
  padding: var(--prem-space-3) var(--prem-space-4);
  border-radius: var(--prem-radius-lg);
  font-size: var(--prem-fs-base);
  line-height: var(--prem-lh-base);
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.prem-msg--ai .prem-msg__bubble {
  background: var(--prem-surface-2);
  color: var(--prem-text);
  border-bottom-left-radius: var(--prem-radius-sm);
}

.prem-msg--human .prem-msg__bubble {
  background: var(--prem-primary-soft);
  color: var(--prem-text);
  border-bottom-left-radius: var(--prem-radius-sm);
  border-left: 3px solid var(--prem-primary);
}

.prem-msg--visitor .prem-msg__bubble {
  background: var(--prem-primary);
  color: var(--prem-text-on-primary);
  border-bottom-right-radius: var(--prem-radius-sm);
}

.prem-msg__meta {
  font-size: var(--prem-fs-xs);
  color: var(--prem-text-muted);
  margin-top: 4px;
  padding: 0 var(--prem-space-2);
}

/* ---------- TYPING INDICATOR ---------- */
.prem-typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: var(--prem-space-4) var(--prem-space-5);
  background: var(--prem-surface-2);
  border-radius: var(--prem-radius-lg);
  border-bottom-left-radius: var(--prem-radius-sm);
  width: fit-content;
}

.prem-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--prem-text-muted);
  animation: prem-typing-bounce 1.2s infinite ease-in-out;
}

.prem-typing span:nth-child(2) { animation-delay: 0.15s; }
.prem-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes prem-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* ============================================================
   Part C: Footer input, listing cards, quick replies
   ============================================================ */

/* ---------- FOOTER INPUT ---------- */
.prem-footer {
  flex-shrink: 0;
  padding: var(--prem-space-3) var(--prem-space-4);
  background: var(--prem-surface);
  border-top: 1px solid var(--prem-border);
  display: flex;
  align-items: flex-end;
  gap: var(--prem-space-2);
}

.prem-input {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: var(--prem-space-3) var(--prem-space-4);
  background: var(--prem-surface-2);
  border: 1px solid transparent;
  border-radius: var(--prem-radius-lg);
  font-size: var(--prem-fs-base);
  font-family: inherit;
  color: var(--prem-text);
  resize: none;
  outline: none;
  line-height: var(--prem-lh-base);
  transition:
    border-color var(--prem-duration-fast) var(--prem-ease),
    background var(--prem-duration-fast) var(--prem-ease);
}

.prem-input::placeholder { color: var(--prem-text-muted); }

.prem-input:focus {
  border-color: var(--prem-border-focus);
  background: var(--prem-surface);
}

.prem-send {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: var(--prem-radius-pill);
  border: none;
  background: var(--prem-primary);
  color: var(--prem-text-on-primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    background var(--prem-duration-fast) var(--prem-ease),
    transform var(--prem-duration-fast) var(--prem-ease);
}

.prem-send:hover {
  background: var(--prem-primary-dark);
  transform: scale(1.05);
}

.prem-send:disabled {
  background: var(--prem-border);
  color: var(--prem-text-muted);
  cursor: not-allowed;
  transform: none;
}

/* ---------- QUICK REPLIES ---------- */
.prem-quick {
  display: flex;
  flex-direction: column;
  gap: var(--prem-space-2);
  margin-top: var(--prem-space-2);
  align-self: flex-start;
  max-width: 92%;
}

.prem-quick__btn {
  padding: var(--prem-space-3) var(--prem-space-4);
  background: var(--prem-surface);
  border: 1px solid var(--prem-border);
  border-radius: var(--prem-radius-lg);
  font-size: var(--prem-fs-sm);
  color: var(--prem-text);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition:
    border-color var(--prem-duration-fast) var(--prem-ease),
    background var(--prem-duration-fast) var(--prem-ease),
    transform var(--prem-duration-fast) var(--prem-ease);
}

.prem-quick__btn:hover {
  border-color: var(--prem-primary);
  background: var(--prem-primary-soft);
  transform: translateX(2px);
}

/* ---------- LISTING CARD ---------- */
.prem-listing {
  width: 100%;
  max-width: 320px;
  background: var(--prem-surface);
  border: 1px solid var(--prem-border);
  border-radius: var(--prem-radius-lg);
  overflow: hidden;
  box-shadow: var(--prem-shadow-sm);
  transition:
    box-shadow var(--prem-duration-base) var(--prem-ease),
    transform var(--prem-duration-base) var(--prem-ease);
  cursor: pointer;
  margin-top: var(--prem-space-2);
}

.prem-listing:hover {
  box-shadow: var(--prem-shadow-md);
  transform: translateY(-2px);
}

.prem-listing__img {
  width: 100%;
  height: 160px;
  background: var(--prem-surface-2);
  object-fit: cover;
  display: block;
}

.prem-listing__body {
  padding: var(--prem-space-4);
}

.prem-listing__title {
  font-size: var(--prem-fs-md);
  font-weight: var(--prem-fw-semibold);
  color: var(--prem-text);
  margin: 0 0 var(--prem-space-1);
  line-height: var(--prem-lh-tight);
}

.prem-listing__location {
  font-size: var(--prem-fs-sm);
  color: var(--prem-text-muted);
  margin: 0 0 var(--prem-space-3);
}

.prem-listing__specs {
  display: flex;
  gap: var(--prem-space-3);
  font-size: var(--prem-fs-sm);
  color: var(--prem-text-muted);
  margin-bottom: var(--prem-space-3);
  flex-wrap: wrap;
}

.prem-listing__price {
  font-size: var(--prem-fs-lg);
  font-weight: var(--prem-fw-bold);
  color: var(--prem-primary);
  font-variant-numeric: tabular-nums;
}

.prem-listing__price-alt {
  font-size: var(--prem-fs-xs);
  color: var(--prem-text-muted);
  margin-left: var(--prem-space-2);
}

.prem-listing__actions {
  display: flex;
  gap: var(--prem-space-2);
  margin-top: var(--prem-space-3);
}

.prem-btn {
  flex: 1;
  padding: var(--prem-space-2) var(--prem-space-3);
  border-radius: var(--prem-radius-md);
  font-size: var(--prem-fs-sm);
  font-weight: var(--prem-fw-medium);
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: background var(--prem-duration-fast) var(--prem-ease);
}

.prem-btn--primary {
  background: var(--prem-accent);
  color: var(--prem-text-inverse);
}

.prem-btn--primary:hover { background: var(--prem-accent-dark); }

.prem-btn--ghost {
  background: var(--prem-surface-2);
  color: var(--prem-text);
}

.prem-btn--ghost:hover { background: var(--prem-surface-3); }
