/* ── Semu Chat Widget ── */

:root {
  --semu-primary: #8B4513;
  --semu-primary-dark: #6B3410;
  --semu-bg: #fff;
  --semu-text: #1a1a1a;
  --semu-bot-bg: #f5f0eb;
  --semu-user-bg: var(--semu-primary);
  --semu-shadow: 0 4px 24px rgba(0,0,0,.18);
  --semu-radius: 18px;
}

#semu-chat-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
}

/* ── Toggle button ─────────────────────────────── */
#semu-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--semu-primary);
  border: none;
  cursor: pointer;
  box-shadow: var(--semu-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s, background .2s;
  margin-left: auto;
}
#semu-toggle:hover { background: var(--semu-primary-dark); transform: scale(1.06); }
#semu-toggle svg   { width: 28px; height: 28px; fill: #fff; }

#semu-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #e53e3e;
  color: #fff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  display: none;
}

/* ── Chat window ───────────────────────────────── */
#semu-window {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 360px;
  max-height: 520px;
  background: var(--semu-bg);
  border-radius: var(--semu-radius);
  box-shadow: var(--semu-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(.97);
  pointer-events: none;
  transition: opacity .22s, transform .22s;
}
#semu-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Header ────────────────────────────────────── */
#semu-header {
  background: var(--semu-primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
#semu-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#semu-avatar svg { width: 20px; height: 20px; fill: #fff; }
#semu-header-info { flex: 1; }
#semu-bot-name { font-weight: 600; font-size: 15px; }
#semu-status { font-size: 11px; opacity: .85; }
#semu-close, #semu-end {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px 6px;
  opacity: .8;
  line-height: 1;
  font-size: 18px;
}
#semu-close { font-size: 22px; }
#semu-close:hover, #semu-end:hover { opacity: 1; }

/* Rating */
.semu-rating {
  background: #fff;
  border: 1px solid #e8ddd5;
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  align-self: stretch;
}
.semu-rating-title { font-size: 13px; color: #1a1a1a; margin-bottom: 10px; font-weight: 500; }
.semu-stars { display: flex; justify-content: center; gap: 6px; }
.semu-star {
  background: none;
  border: none;
  font-size: 30px;
  color: #ddd;
  cursor: pointer;
  padding: 0;
  transition: color .15s, transform .15s;
}
.semu-star:hover:not(:disabled) { color: #f5b50a; transform: scale(1.15); }
.semu-star.filled { color: #f5b50a; }
.semu-rating-comment {
  width: 100%;
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid #e0d5cc;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  resize: none;
  outline: none;
  background: #faf8f6;
  box-sizing: border-box;
}
.semu-rating-comment:focus { border-color: var(--semu-primary); }
.semu-rating-submit {
  margin-top: 8px;
  width: 100%;
  padding: 8px;
  background: var(--semu-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .18s, opacity .18s;
}
.semu-rating-submit:hover:not(:disabled) { background: var(--semu-primary-dark); }
.semu-rating-submit:disabled { opacity: .4; cursor: default; }

/* Ticket Form */
.semu-form {
  background: #fff;
  border: 1px solid #e8ddd5;
  border-radius: 12px;
  padding: 14px;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.semu-form-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--semu-primary);
  margin-bottom: 4px;
}
.semu-form-subtitle {
  font-size: 12px;
  color: #666;
  margin-bottom: 8px;
  line-height: 1.4;
}
.semu-form-label {
  font-size: 12px;
  font-weight: 500;
  color: #333;
  margin-top: 6px;
}
.semu-form-label .req { color: #e53e3e; }
.semu-form-input, .semu-form-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #e0d5cc;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  background: #faf8f6;
  box-sizing: border-box;
  transition: border-color .15s;
}
.semu-form-input:focus, .semu-form-textarea:focus { border-color: var(--semu-primary); }
.semu-form-textarea { resize: vertical; min-height: 60px; }
.semu-form-radios {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 0;
}
.semu-form-radio {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #333;
  cursor: pointer;
}
.semu-form-radio input { accent-color: var(--semu-primary); margin: 0; }
.semu-form-error {
  font-size: 12px;
  color: #e53e3e;
  margin-top: 4px;
}
.semu-form-submit {
  margin-top: 10px;
  width: 100%;
  padding: 10px;
  background: var(--semu-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .18s, opacity .18s;
}
.semu-form-submit:hover:not(:disabled) { background: var(--semu-primary-dark); }
.semu-form-submit:disabled { opacity: .6; cursor: default; }

/* ── Messages ──────────────────────────────────── */
#semu-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
#semu-messages::-webkit-scrollbar { width: 4px; }
#semu-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

.semu-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
  font-size: 14px;
}
.semu-msg.bot {
  background: var(--semu-bot-bg);
  color: var(--semu-text);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}
.semu-msg.user {
  background: var(--semu-user-bg);
  color: #fff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}
.semu-msg.bot a {
  color: var(--semu-primary);
  text-decoration: underline;
  font-weight: 500;
  word-break: break-all;
}
.semu-msg.bot a:hover { color: var(--semu-primary-dark); }

/* ── Product cards ─────────────────────────────── */
.semu-products {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.semu-product-card {
  background: #fff;
  border: 1px solid #e8ddd5;
  border-radius: 12px;
  padding: 10px;
  display: flex;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .18s;
}
.semu-product-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,.1); }
.semu-product-thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  background: #f5f0eb;
  flex-shrink: 0;
}
.semu-product-info { flex: 1; }
.semu-product-name { font-weight: 600; font-size: 13px; color: #1a1a1a; }
.semu-product-price { color: var(--semu-primary); font-weight: 600; font-size: 13px; margin-top: 2px; }

/* ── Human handoff ─────────────────────────────── */
.semu-contact-card {
  background: #fff;
  border: 1px solid #e8ddd5;
  border-radius: 12px;
  padding: 12px;
  margin-top: 6px;
  font-size: 13px;
}
.semu-contact-card a {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--semu-primary);
  text-decoration: none;
  padding: 4px 0;
  font-weight: 500;
}
.semu-contact-card a:hover { text-decoration: underline; }

/* ── Typing indicator ──────────────────────────── */
.semu-typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 10px 14px;
  background: var(--semu-bot-bg);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}
.semu-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #999;
  animation: semuBounce 1.2s infinite;
}
.semu-typing span:nth-child(2) { animation-delay: .2s; }
.semu-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes semuBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

/* ── Input area ────────────────────────────────── */
#semu-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid #f0e8e0;
  background: #fff;
}
#semu-input {
  flex: 1;
  border: 1px solid #e0d5cc;
  border-radius: 24px;
  padding: 9px 16px;
  font-size: 14px;
  outline: none;
  resize: none;
  line-height: 1.4;
  font-family: inherit;
  background: #faf8f6;
  transition: border-color .18s;
}
#semu-input:focus { border-color: var(--semu-primary); }
#semu-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--semu-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .18s;
}
#semu-send:hover { background: var(--semu-primary-dark); }
#semu-send svg { width: 18px; height: 18px; fill: #fff; }
#semu-send:disabled { opacity: .5; cursor: default; }

/* ── Quick replies ─────────────────────────────── */
#semu-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 10px;
}
.semu-quick-btn {
  background: #f5f0eb;
  border: 1px solid #e8ddd5;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--semu-text);
  transition: background .18s, color .18s;
  white-space: nowrap;
}
.semu-quick-btn:hover { background: var(--semu-primary); color: #fff; border-color: var(--semu-primary); }

/* ── Mobile ────────────────────────────────────── */
@media (max-width: 600px) {
  #semu-chat-root { bottom: 16px; right: 16px; }
  #semu-window {
    width: calc(100vw - 24px);
    height: calc(100vh - 100px);
    max-height: calc(100vh - 100px);
    right: -8px;
    bottom: 80px;
  }
  #semu-toggle { width: 56px; height: 56px; }
  #semu-toggle svg { width: 26px; height: 26px; }
  .semu-msg { font-size: 15px; max-width: 88%; }
  #semu-input { font-size: 16px; }
}
