/* Interactive Support Desk Component */
:root {
  --sd-primary: #007bff;
  --sd-primary-hover: #0056b3;
  --sd-bg: #ffffff;
  --sd-bg-hover: #f1f3f5;
  --sd-text: #333333;
  --sd-text-muted: #6c757d;
  --sd-border: #dee2e6;
  --sd-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
  --sd-radius: 12px;
  --sd-msg-user: #007bff;
  --sd-msg-user-text: #ffffff;
  --sd-msg-bot: #f1f3f5;
  --sd-msg-bot-text: #333333;
}

.sd-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family:
    "Inter",
    system-ui,
    -apple-system,
    sans-serif;
}

.sd-launcher {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--sd-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: var(--sd-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition:
    transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    background 0.2s ease,
    box-shadow 0.2s ease;
}

.sd-launcher:hover {
  transform: scale(1.08);
  background: var(--sd-primary-hover);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.sd-panel {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 380px;
  height: 560px;
  max-height: calc(100vh - 100px);
  background: var(--sd-bg);
  border-radius: var(--sd-radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.16);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.95);
  transform-origin: bottom right;
  transition:
    opacity 0.3s ease,
    transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.1);
}

.sd-panel.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.sd-header {
  padding: 16px 20px;
  background: var(--sd-primary);
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top-left-radius: var(--sd-radius);
  border-top-right-radius: var(--sd-radius);
}

.sd-header-info {
  display: flex;
  flex-direction: column;
}

.sd-header-info h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: #fff;
  /* Ensure it's readable if global styles override */
}

.sd-header-info p {
  margin: 4px 0 0 0;
  font-size: 12px;
  opacity: 0.85;
  color: #fff;
}

.sd-close {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #fff;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.2s;
}

.sd-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.sd-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f8f9fc;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sd-message {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  position: relative;
  word-wrap: break-word;
  display: block;
  width: fit-content;
}

.sd-message.user {
  margin-left: auto;
  margin-right: 0;
  margin-bottom: 5px;
  background: var(--sd-msg-user);
  color: var(--sd-msg-user-text);
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
}

.sd-message.bot {
  margin-left: 0;
  margin-right: auto;
  background: #ffffff;
  color: var(--sd-msg-bot-text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.sd-message-time {
  display: block;
  font-size: 11px;
  margin-top: 6px;
  opacity: 0.7;
  text-align: right;
}

.sd-composer {
  padding: 14px;
  background: var(--sd-bg);
  border-top: 1px solid var(--sd-border);
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.sd-input {
  flex: 1;
  border: 1px solid var(--sd-border);
  background: #f8f9fa;
  border-radius: 20px;
  padding: 12px 16px;
  font-size: 14px;
  outline: none;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
  min-height: 44px;
  line-height: 1.4;
  font-family: inherit;
  transition:
    border-color 0.2s,
    background 0.2s;
}

.sd-input:focus {
  border-color: var(--sd-primary);
  background: #ffffff;
}

.sd-btn-icon {
  background: none;
  border: none;
  color: var(--sd-text-muted);
  cursor: pointer;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    color 0.2s,
    background 0.2s;
  flex-shrink: 0;
}

.sd-btn-icon:hover {
  color: var(--sd-primary);
  background: var(--sd-bg-hover);
}

.sd-btn-send {
  color: #fff;
  background: var(--sd-primary);
}

.sd-btn-send:hover {
  color: #fff;
  background: var(--sd-primary-hover);
}

/* Attachment preview styles */
.sd-attachment-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 14px;
  background: var(--sd-bg);
  border-top: 1px solid var(--sd-border);
}

.sd-attachment-item {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 8px;
  border: 1px solid var(--sd-border);
  overflow: hidden;
  background: var(--sd-bg-hover);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.sd-attachment-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sd-attachment-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s;
}

.sd-attachment-remove:hover {
  transform: scale(1.1);
  background: rgba(220, 53, 69, 0.9);
}

/* Scrollbar styling for a cleaner look */
.sd-body::-webkit-scrollbar,
.sd-input::-webkit-scrollbar {
  width: 6px;
}

.sd-body::-webkit-scrollbar-track,
.sd-input::-webkit-scrollbar-track {
  background: transparent;
}

.sd-body::-webkit-scrollbar-thumb,
.sd-input::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.15);
  border-radius: 10px;
}

@media (max-width: 480px) {
  .sd-panel {
    width: calc(100vw - 32px);
    right: 16px;
    bottom: 86px;
    height: 70vh;
  }
}
