html,
body {
  margin: 0;
  background: transparent;
  overflow: hidden;
  font-family: Arial, sans-serif;
}

#chat-toggle {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #f5c542, #b88912);
  color: #111;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 16px 36px rgba(0,0,0,0.28);
  animation: pulse 1.8s infinite;
  z-index: 99999;
}

.toggle-badge {
  position: absolute;
  right: 7px;
  top: 7px;
  width: 12px;
  height: 12px;
  background: #2ecc71;
  border: 2px solid white;
  border-radius: 50%;
}

#chat-widget {
  width: 370px;
  height: 640px;
  max-height: calc(100vh - 110px);
  position: fixed;
  right: 24px;
  bottom: 96px;
  border-radius: 22px;
  background: white;
  box-shadow: 0 22px 60px rgba(0,0,0,0.28);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.25s ease;
  z-index: 99999;
  border: 1px solid rgba(0,0,0,0.08);
}

#chat-header {
  background: radial-gradient(circle at top left, rgba(245,197,66,0.25), transparent 35%), linear-gradient(135deg, #070707, #1f2937);
  color: white;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.avatar {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #f5c542, #b88912);
  color: #111;
  border-radius: 14px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 900;
}

#chat-header strong {
  font-size: 15px;
}

#chat-header small {
  display: block;
  font-size: 12px;
  color: #d8dde6;
  margin-top: 4px;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #2ecc71;
  border-radius: 50%;
  margin-right: 5px;
}

#close-chat {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.12);
  color: white;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}

#prechat-form {
  padding: 18px;
  flex: 1;
  background: #f6f7fb;
  overflow-y: auto;
}

.welcome-card {
  background: white;
  border: 1px solid #edf0f4;
  border-radius: 20px;
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.05);
}

.welcome-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #fff3c4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 12px;
}

#prechat-form h3 {
  margin: 0 0 8px;
  color: #111;
  font-size: 18px;
}

#prechat-form p {
  margin: 0;
  color: #6f7682;
  font-size: 13px;
  line-height: 1.45;
}

#prechat-form label {
  display: block;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 7px;
  color: #3b4250;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

#prechat-form input,
#prechat-form textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 13px;
  border: 1px solid #dde3eb;
  border-radius: 14px;
  outline: none;
  margin-bottom: 14px;
  font-family: Arial, sans-serif;
  background: white;
  font-size: 14px;
}

#prechat-form textarea {
  height: 96px;
  resize: none;
}

#start-chat-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #111827, #000);
  color: white;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0,0,0,0.18);
}

#chat-area {
  height: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #f5f7fb;
}

#chat-box {
  flex: 1;
  min-height: 0;
  padding: 14px;
  overflow-y: auto;
  background: radial-gradient(circle at top right, rgba(245,197,66,0.12), transparent 28%), linear-gradient(180deg, #f8fafc, #eef2f7);
}

.message {
  animation: fadeIn 0.2s ease;
}

.user-message,
.bot-message {
  width: fit-content;
  max-width: 78%;
  padding: 10px 13px;
  margin-bottom: 11px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.user-message {
  background: linear-gradient(135deg, #111827, #000);
  color: white;
  margin-left: auto;
  border-bottom-right-radius: 6px;
}

.bot-message {
  background: white;
  color: #111827;
  margin-right: auto;
  border-bottom-left-radius: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.07);
}

#typing {
  display: none;
  padding: 0 14px 10px;
  background: #eef2f7;
}

.typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: white;
  border-radius: 18px;
  padding: 10px 12px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.06);
}

#typing span {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #777;
  border-radius: 50%;
  animation: typing 1s infinite;
}

#typing span:nth-child(2) {
  animation-delay: 0.2s;
}

#typing span:nth-child(3) {
  animation-delay: 0.4s;
}

#chat-input-area {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #ffffff;
  border-top: 1px solid #e8ebf0;
  flex-shrink: 0;
}

.attach-btn,
#send-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.attach-btn {
  background: #111827;
  color: #fff;
  cursor: pointer;
  font-size: 17px;
}

.input-wrap {
  min-width: 0;
  width: 100%;
}

#selected-file {
  display: block;
  font-size: 11px;
  color: #777;
  max-width: 180px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

#message {
  width: 100%;
  height: 40px;
  min-height: 40px;
  max-height: 40px;
  resize: none;
  overflow: hidden;
  border: 1px solid #d9dee7;
  border-radius: 17px;
  padding: 9px 12px;
  font-size: 14px;
  line-height: 20px;
  font-family: Arial, sans-serif;
  outline: none;
  box-sizing: border-box;
}

#message:focus {
  border-color: #111827;
  box-shadow: 0 0 0 3px rgba(17,24,39,0.06);
}

#send-btn {
  background: linear-gradient(135deg, #f5c542, #b88912);
  color: #111;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  position: static !important;
  margin: 0 !important;
}

#send-btn:disabled {
  background: #c8ccd3;
  color: white;
  cursor: not-allowed;
}

.chat-image-preview {
  max-width: 190px;
  max-height: 260px;
  width: auto;
  height: auto;
  border-radius: 14px;
  display: block;
  cursor: pointer;
  object-fit: contain;
}

#rating-panel.rating-panel {
  margin: 10px 12px 0;
  padding: 14px;
  background: #ffffff;
  border: 1px solid #edf0f4;
  border-radius: 18px;
  box-shadow: 0 -4px 18px rgba(0,0,0,0.08);
  width: calc(100% - 24px);
  box-sizing: border-box;
}

.rating-title {
  font-size: 15px;
  font-weight: 800;
  color: #111;
  margin-bottom: 4px;
}

.rating-subtitle {
  font-size: 12px;
  color: #777;
  margin-bottom: 10px;
}

.rating-stars {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.rating-stars button {
  flex: 1;
  border: none;
  background: #f5f6f8;
  border-radius: 12px;
  padding: 9px 0;
  cursor: pointer;
  font-size: 18px;
}

#rating-comment {
  width: 100%;
  height: 58px;
  resize: none;
  border: 1px solid #dde3eb;
  border-radius: 12px;
  padding: 9px;
  font-size: 13px;
  font-family: Arial, sans-serif;
  outline: none;
  margin-bottom: 8px;
  box-sizing: border-box;
}

.rating-skip {
  width: 100%;
  border: none;
  background: #111827;
  color: white;
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
  font-weight: bold;
}

@media (max-width: 768px) {
  #chat-widget {
    width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    right: 0 !important;
    bottom: 0 !important;
    border-radius: 0 !important;
  }

  #chat-toggle {
    right: 18px;
    bottom: 18px;
    width: 56px;
    height: 56px;
    font-size: 22px;
  }

  #chat-header {
    padding: 12px 14px !important;
  }

  .avatar {
    width: 36px !important;
    height: 36px !important;
    border-radius: 12px !important;
  }

  #chat-header strong {
    font-size: 14px !important;
  }

  #chat-header small {
    font-size: 11px !important;
  }

  #chat-box {
    padding: 12px !important;
  }

  .user-message,
  .bot-message {
    max-width: 84% !important;
    font-size: 13px !important;
    padding: 9px 12px !important;
  }

  #chat-input-area {
    grid-template-columns: 38px minmax(0, 1fr) 38px !important;
    gap: 7px !important;
    padding: 8px 10px !important;
    padding-bottom: calc(8px + env(safe-area-inset-bottom)) !important;
  }

  .attach-btn,
  #send-btn {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
  }

  #message {
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    font-size: 13px !important;
    padding: 8px 11px !important;
    line-height: 18px !important;
  }

  #selected-file {
    max-width: 140px;
  }

  .chat-image-preview {
    max-width: 180px;
    max-height: 230px;
  }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(25px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes typing {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-4px); }
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(245,197,66,0.45); }
  70% { box-shadow: 0 0 0 15px rgba(245,197,66,0); }
  100% { box-shadow: 0 0 0 0 rgba(245,197,66,0); }
}

::-webkit-scrollbar {
  width: 7px;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}
