/* ============================================================
   Discord Chat Support – Widget Styles
   ============================================================ */

/* Reset scoped to the widget */
#dcs-widget-root,
#dcs-widget-root * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
}

/* ── Toggle bubble ───────────────────────────────────────── */
#dcs-toggle-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 58px;
  height: 58px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  z-index: 99998;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px rgba(0,0,0,0.30), 0 2px 8px rgba(0,0,0,0.20);
  transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1),
              box-shadow 0.2s ease;
}

#dcs-toggle-btn:hover {
  transform: scale(1.12);
  box-shadow: 0 10px 32px rgba(0,0,0,0.38);
}

#dcs-toggle-btn:active { transform: scale(0.95); }

#dcs-toggle-btn .dcs-icon-chat,
#dcs-toggle-btn .dcs-icon-close { transition: opacity 0.2s, transform 0.2s; }
#dcs-toggle-btn .dcs-icon-close { display: none; }

#dcs-toggle-btn.is-open .dcs-icon-chat  { display: none; }
#dcs-toggle-btn.is-open .dcs-icon-close { display: block; }

#dcs-toggle-btn svg { width: 26px; height: 26px; fill: #fff; }

/* Unread badge */
#dcs-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  background: #ff4757;
  border: 2px solid #fff;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ── Chat panel ──────────────────────────────────────────── */
#dcs-chat-panel {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 348px;
  max-width: calc(100vw - 32px);
  height: 500px;
  max-height: calc(100vh - 120px);
  background: #ffffff;
  border-radius: 16px;
  box-shadow:
    0 20px 60px rgba(0,0,0,0.15),
    0 6px 20px rgba(0,0,0,0.10),
    0 0 0 1px rgba(0,0,0,0.06);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* Entry animation */
  transform: scale(0.85) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.28s cubic-bezier(0.34,1.56,0.64,1),
    opacity   0.22s ease;
}

#dcs-chat-panel.is-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ──────────────────────────────────────────────── */
#dcs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  background: linear-gradient(135deg, #101827 0%, #1e293b 100%);
  color: #ffffff;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

#dcs-header-info { display: flex; flex-direction: column; gap: 4px; }

#dcs-title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #f3f4f6;
}

#dcs-status {
  font-size: 11px;
  font-weight: 600;
  color: #4ade80;
  display: flex;
  align-items: center;
  gap: 6px;
}

#dcs-status::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(74,222,128,0.25);
  animation: dcs-pulse 2s infinite;
}

@keyframes dcs-pulse {
  0% { box-shadow: 0 0 0 0 rgba(74,222,128,0.4); }
  70% { box-shadow: 0 0 0 6px rgba(74,222,128,0); }
  100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); }
}

#dcs-header-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #9ca3af;
  font-size: 20px;
  line-height: 1;
  padding: 6px;
  border-radius: 50%;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

#dcs-header-close:hover {
  color: #ffffff;
  background: rgba(255,255,255,0.1);
}

/* ── Body (swappable between pre-chat form & messages) ───── */
#dcs-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Pre-chat form ───────────────────────────────────────── */
#dcs-prechat {
  flex: 1;
  overflow-y: auto;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#dcs-prechat-welcome {
  font-size: 14px;
  color: #555;
  line-height: 1.55;
}

.dcs-field { display: flex; flex-direction: column; gap: 6px; }

.dcs-field label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #888;
}

.dcs-field input,
.dcs-field textarea {
  border: 1.5px solid #e8e8e8;
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 13.5px;
  color: #222;
  outline: none;
  font-family: inherit;
  transition: border-color 0.18s, box-shadow 0.18s;
  background: #fafafa;
}

.dcs-field input:focus,
.dcs-field textarea:focus {
  border-color: #1a1a2e;
  box-shadow: 0 0 0 3px rgba(26,26,46,0.08);
  background: #fff;
}

.dcs-field input.dcs-error,
.dcs-field textarea.dcs-error {
  border-color: #ff4757;
  box-shadow: 0 0 0 3px rgba(255,71,87,0.10);
}

.dcs-field textarea { resize: none; height: 68px; }

#dcs-start-btn {
  background: linear-gradient(135deg, #1a1a2e 0%, #2d2d5e 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 13px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.2s, transform 0.15s;
}

#dcs-start-btn:hover  { opacity: 0.88; }
#dcs-start-btn:active { transform: scale(0.98); }
#dcs-start-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Messages area ───────────────────────────────────────── */
#dcs-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

#dcs-messages::-webkit-scrollbar { width: 4px; }
#dcs-messages::-webkit-scrollbar-track { background: transparent; }
#dcs-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

/* Individual message */
#dcs-widget-root .dcs-msg {
  display: flex !important;
  flex-direction: column !important;
  max-width: 82% !important;
  animation: dcs-pop 0.22s ease both !important;
}
@keyframes dcs-pop {
  from { opacity:0; transform: translateY(10px) scale(0.96); }
  to   { opacity:1; transform: translateY(0)   scale(1); }
}

#dcs-widget-root .dcs-msg.dcs-msg--agent    { align-self: flex-start !important; align-items: flex-start !important; }
#dcs-widget-root .dcs-msg.dcs-msg--customer { align-self: flex-end !important; align-items: flex-end !important; }
#dcs-widget-root .dcs-msg.dcs-msg--system   { align-self: center !important; align-items: center !important; max-width: 90% !important; }

#dcs-widget-root .dcs-msg__author {
  font-size: 10px !important;
  font-weight: 600 !important;
  color: #888888 !important;
  margin-bottom: 4px !important;
  padding: 0 2px !important;
}
#dcs-widget-root .dcs-msg--customer .dcs-msg__author { text-align: right !important; }

#dcs-widget-root .dcs-msg__bubble {
  padding: 10px 14px !important;
  border-radius: 14px !important;
  font-size: 13.5px !important;
  line-height: 1.55 !important;
  word-break: break-word !important;
  white-space: pre-wrap !important;
  box-sizing: border-box !important;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05) !important;
}

#dcs-widget-root .dcs-msg--agent .dcs-msg__bubble {
  background: #f3f3f6 !important;
  color: #1a1a2e !important;
  border-bottom-left-radius: 4px !important;
}

#dcs-widget-root .dcs-msg--customer .dcs-msg__bubble {
  background: linear-gradient(135deg, #1a1a2e 0%, #2d2d5e 100%) !important;
  color: #ffffff !important;
  border-bottom-right-radius: 4px !important;
}

#dcs-widget-root .dcs-msg--system .dcs-msg__bubble {
  background: none !important;
  color: #bbb !important;
  font-size: 11px !important;
  text-align: center !important;
  padding: 0 !important;
  box-shadow: none !important;
}

.dcs-msg__time {
  font-size: 10px;
  color: #ccc;
  margin-top: 4px;
  padding: 0 2px;
}
.dcs-msg--customer .dcs-msg__time { text-align: right; }

/* ── Typing indicator ────────────────────────────────────── */
#dcs-typing {
  display: none;
  padding: 0 18px 10px;
}

.dcs-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  background: #f3f3f6;
  border-radius: 12px;
  padding: 8px 13px;
}

.dcs-dots span {
  width: 6px;
  height: 6px;
  background: #bbb;
  border-radius: 50%;
  animation: dcs-bounce 1.3s infinite ease-in-out;
}
.dcs-dots span:nth-child(2) { animation-delay: 0.18s; }
.dcs-dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes dcs-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-5px); }
}

/* ── Input area ──────────────────────────────────────────── */
#dcs-input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid #f2f2f2;
  background: #fff;
  flex-shrink: 0;
}

#dcs-input {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-size: 13.5px;
  line-height: 1.5;
  color: #222;
  background: transparent;
  max-height: 96px;
  overflow-y: auto;
  font-family: inherit;
}

#dcs-input::placeholder { color: #bbb; }

#dcs-send-btn {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #1a1a2e 0%, #2d2d5e 100%);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s, transform 0.15s;
}

#dcs-send-btn:hover  { opacity: 0.85; }
#dcs-send-btn:active { transform: scale(0.92); }
#dcs-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
#dcs-send-btn svg { width: 16px; height: 16px; fill: #fff; }

/* ── Spinner ─────────────────────────────────────────────── */
.dcs-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: dcs-spin 0.65s linear infinite;
}
@keyframes dcs-spin { to { transform: rotate(360deg); } }

/* ── Chat closed banner ──────────────────────────────────── */
#dcs-closed-banner {
  background: #fff8f8;
  border-top: 1px solid #fde8e8;
  padding: 12px 18px;
  text-align: center;
  font-size: 12.5px;
  color: #c0392b;
  display: none;
  flex-shrink: 0;
}

/* ── Mobile & Responsive Breakpoints ───────────────────────── */
@media (max-width: 768px) {
  #dcs-widget-root #dcs-chat-panel {
    width: calc(100vw - 16px) !important;
    right: 8px !important;
    bottom: 180px !important; /* Lifted higher to stay above the toggle button and clear nav bar */
    border-radius: 14px !important;
    height: 60vh !important;
    z-index: 999999 !important;
  }
  #dcs-widget-root #dcs-toggle-btn {
    right: 16px !important;
    bottom: 110px !important; /* Lifted perfectly above the sticky bottom navigation bar */
    z-index: 999998 !important;
  }
}
