/**
 * PharmEtrade — Chat Widget & Search Modal Styles
 */

/* ── Chat Bubble (FAB) ─────────────────────────────── */
.chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9000;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--color-green) 0%, #00c98e 100%);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 168, 120, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}
.chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0, 168, 120, 0.5);
}
.chat-bubble svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chat-bubble__close {
  display: none;
}
.chat-bubble.is-open .chat-bubble__icon { display: none; }
.chat-bubble.is-open .chat-bubble__close { display: block; }

/* ── Chat Panel ────────────────────────────────────── */
.chat-panel {
  position: fixed;
  bottom: 100px;
  right: 24px;
  z-index: 8999;
  width: 400px;
  height: 560px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.chat-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.chat-panel__header {
  background: var(--color-navy);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.chat-panel__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.chat-panel__title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
}
.chat-panel__subtitle {
  font-size: 0.75rem;
  opacity: 0.7;
}
.chat-panel__close {
  margin-left: auto;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
  opacity: 0.7;
  transition: opacity 0.15s;
}
.chat-panel__close:hover { opacity: 1; }
.chat-panel__close svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

/* Messages area */
.chat-panel__messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.chat-panel__messages::-webkit-scrollbar { width: 4px; }
.chat-panel__messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

/* Message bubbles */
.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.5;
  word-wrap: break-word;
}
.chat-msg--user {
  align-self: flex-end;
  background: var(--color-navy);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg--assistant {
  align-self: flex-start;
  background: #f1f3f5;
  color: var(--color-text-primary);
  border-bottom-left-radius: 4px;
}
.chat-msg--assistant strong { color: var(--color-navy); }

/* Typing indicator */
.chat-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: #f1f3f5;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}
.chat-typing__dot {
  width: 8px;
  height: 8px;
  background: #999;
  border-radius: 50%;
  animation: chatBounce 1.2s ease-in-out infinite;
}
.chat-typing__dot:nth-child(2) { animation-delay: 0.15s; }
.chat-typing__dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes chatBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Product cards in chat */
.chat-products {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.chat-product-card {
  display: flex;
  gap: 10px;
  padding: 10px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  align-items: center;
  transition: border-color 0.15s;
}
.chat-product-card:hover { border-color: var(--color-green); }
.chat-product-card__img {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: #f5f5f5;
}
.chat-product-card__info {
  flex: 1;
  min-width: 0;
}
.chat-product-card__name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  text-decoration: none;
}
.chat-product-card__name:hover { text-decoration: underline; }
.chat-product-card__meta {
  font-size: 0.7rem;
  color: #666;
}
.chat-product-card__price {
  font-weight: 700;
  color: var(--color-green);
  font-size: 0.85rem;
  white-space: nowrap;
}
.chat-product-card__stock {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}
.chat-product-card__stock--in-stock { background: #e6f9f0; color: #0a7c42; }
.chat-product-card__stock--low-stock { background: #fef3cd; color: #856404; }
.chat-product-card__add {
  padding: 4px 10px;
  font-size: 0.7rem;
  border: none;
  border-radius: 6px;
  background: var(--color-green);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.chat-product-card__add:hover { background: #009168; }
.chat-product-card__add.added {
  background: var(--color-navy);
  pointer-events: none;
}
.chat-product-card__actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

/* Suggestions */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.chat-suggestion-btn {
  padding: 6px 12px;
  font-size: 0.75rem;
  border: 1px solid var(--color-green);
  border-radius: 20px;
  background: #fff;
  color: var(--color-green);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.chat-suggestion-btn:hover {
  background: var(--color-green);
  color: #fff;
}

/* Input area */
.chat-panel__input-area {
  padding: 12px 16px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  background: #fafafa;
}
.chat-panel__input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 24px;
  font-size: 0.875rem;
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.15s;
}
.chat-panel__input:focus { border-color: var(--color-green); }
.chat-panel__input::placeholder { color: #aaa; }
.chat-panel__send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--color-green);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.chat-panel__send:hover { background: #009168; }
.chat-panel__send:disabled { background: #ccc; cursor: not-allowed; }
.chat-panel__send svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Backend badge */
.chat-panel__backend {
  text-align: center;
  font-size: 0.65rem;
  color: #aaa;
  padding: 2px 0 6px;
  background: #fafafa;
}

/* ── Search Modal ──────────────────────────────────── */
.search-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.search-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}
.search-modal__content {
  width: 600px;
  max-width: 92vw;
  max-height: 70vh;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(-10px);
  transition: transform 0.2s;
}
.search-modal.is-open .search-modal__content {
  transform: translateY(0);
}
.search-modal__header {
  padding: 20px 20px 0;
  display: flex;
  align-items: center;
  gap: 12px;
}
.search-modal__input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 10px 16px;
  transition: border-color 0.15s;
}
.search-modal__input-wrap:focus-within { border-color: var(--color-green); }
.search-modal__input-wrap svg {
  width: 20px;
  height: 20px;
  stroke: #999;
  stroke-width: 2;
  fill: none;
  flex-shrink: 0;
}
.search-modal__input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1rem;
  font-family: var(--font-body);
  background: transparent;
}
.search-modal__input::placeholder { color: #aaa; }
.search-modal__close-btn {
  background: none;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.75rem;
  color: #666;
  cursor: pointer;
  white-space: nowrap;
}
.search-modal__close-btn:hover { background: #f5f5f5; }

/* Tabs */
.search-modal__tabs {
  display: flex;
  gap: 0;
  padding: 12px 20px 0;
  border-bottom: 1px solid #e5e7eb;
}
.search-modal__tab {
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #666;
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.search-modal__tab:hover { color: var(--color-navy); }
.search-modal__tab.is-active {
  color: var(--color-green);
  border-bottom-color: var(--color-green);
}

/* Results area */
.search-modal__body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}
.search-modal__body::-webkit-scrollbar { width: 4px; }
.search-modal__body::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

.search-results { display: flex; flex-direction: column; gap: 8px; }
.search-result-item {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}
.search-result-item:hover { background: #f5f7f9; }
.search-result-item__img {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  background: #f5f5f5;
  flex-shrink: 0;
}
.search-result-item__info { flex: 1; min-width: 0; }
.search-result-item__name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-item__meta { font-size: 0.78rem; color: #666; }
.search-result-item__price {
  font-weight: 700;
  color: var(--color-green);
  font-size: 0.9rem;
  flex-shrink: 0;
  align-self: center;
}

.search-empty {
  text-align: center;
  padding: 32px 16px;
  color: #999;
  font-size: 0.9rem;
}
.search-hint {
  text-align: center;
  padding: 32px 16px;
  color: #bbb;
  font-size: 0.85rem;
}

/* AI tab in search */
.search-ai-area {
  display: none;
}
.search-ai-area.is-active { display: block; }
.search-results-area.is-active { display: block; }
.search-results-area { display: none; }

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 480px) {
  .chat-panel {
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
  }
  .chat-bubble {
    bottom: 16px;
    right: 16px;
    width: 52px;
    height: 52px;
  }
  .search-modal { padding-top: 0; }
  .search-modal__content {
    max-width: 100%;
    max-height: 100%;
    height: 100%;
    border-radius: 0;
  }
}
