:root {
  --tsb-primary: #00838F;
  --tsb-primary-dark: #006973;
  --tsb-white: #ffffff;
  --tsb-bg: #f5f5f5;
  --tsb-text: #333333;
  --tsb-bubble-user: #00838F;
  --tsb-bubble-bot: #e8f5f6;
  --tsb-shadow: 0 4px 24px rgba(0, 131, 143, 0.25);
  --tsb-radius: 16px;
}

/* Floating bubble wrapper */
.tsb-bubble-wrapper {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

/* Label "Besoin d'aide ?" */
.tsb-bubble-label {
  background: var(--tsb-white);
  color: var(--tsb-primary);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  white-space: nowrap;
  cursor: pointer;
  border: 1.5px solid var(--tsb-primary);
  transition: background 0.2s, color 0.2s;
  animation: tsb-label-in 0.4s ease 1.5s both;
}

.tsb-bubble-label:hover {
  background: var(--tsb-primary);
  color: var(--tsb-white);
}

.tsb-bubble-label.tsb-hidden {
  display: none;
}

@keyframes tsb-label-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Floating bubble */
.tsb-bubble {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--tsb-primary);
  color: var(--tsb-white);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--tsb-shadow);
  transition: background 0.2s, transform 0.2s;
  outline: none;
  animation: tsb-pulse 2.5s ease-in-out 2s 3;
}

.tsb-bubble:hover {
  background: var(--tsb-primary-dark);
  transform: scale(1.08);
}

.tsb-bubble svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: var(--tsb-white);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@keyframes tsb-pulse {
  0%, 100% { box-shadow: var(--tsb-shadow); }
  50%       { box-shadow: 0 0 0 10px rgba(0, 131, 143, 0.2), var(--tsb-shadow); }
}

/* Chat panel */
.tsb-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  z-index: 9998;
  width: 360px;
  height: 520px;
  background: var(--tsb-white);
  border-radius: var(--tsb-radius);
  box-shadow: var(--tsb-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.92) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.22s ease;
  transform-origin: bottom right;
}

.tsb-panel.tsb-open {
  transform: none;
  opacity: 1;
  pointer-events: all;
}

/* Header */
.tsb-header {
  background: var(--tsb-primary);
  color: var(--tsb-white);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.tsb-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.tsb-header-info {
  flex: 1;
}

.tsb-header-name {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
}

.tsb-header-status {
  font-size: 12px;
  opacity: 0.85;
}

.tsb-header-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--tsb-white);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.15s;
  outline: none;
}

.tsb-header-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.tsb-header-close svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}

/* Messages area */
.tsb-messages {
  flex: 1;
  overflow-y: scroll;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  will-change: scroll-position;
}

.tsb-messages::-webkit-scrollbar {
  width: 4px;
}

.tsb-messages::-webkit-scrollbar-track {
  background: transparent;
}

.tsb-messages::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

/* Message bubbles */
.tsb-msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
}

.tsb-msg-bot {
  align-self: flex-start;
}

.tsb-msg-user {
  align-self: flex-end;
}

.tsb-msg-content {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.tsb-msg-bot .tsb-msg-content {
  background: var(--tsb-bubble-bot);
  color: var(--tsb-text);
  border-bottom-left-radius: 4px;
}

.tsb-msg-user .tsb-msg-content {
  background: var(--tsb-bubble-user);
  color: var(--tsb-white);
  border-bottom-right-radius: 4px;
}

/* Contact form */
.tsb-contact-form {
  background: var(--tsb-white);
  border: 1.5px solid #e0e0e0;
  border-radius: 12px;
  padding: 14px;
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 300px;
}

.tsb-contact-form-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--tsb-primary);
  margin-bottom: 2px;
}

.tsb-contact-input {
  border: 1.5px solid #ddd;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--tsb-text);
  background: #fafafa;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
  box-sizing: border-box;
}

.tsb-contact-input:focus {
  border-color: var(--tsb-primary);
  background: var(--tsb-white);
}

.tsb-contact-textarea {
  resize: none;
  height: 70px;
}

.tsb-contact-submit {
  background: var(--tsb-primary);
  color: var(--tsb-white);
  border: none;
  border-radius: 8px;
  padding: 9px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}

.tsb-contact-submit:hover {
  background: var(--tsb-primary-dark);
}

.tsb-contact-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.tsb-contact-success {
  background: #e8f5e9;
  color: #2e7d32;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  text-align: center;
}

/* Suggestions */
.tsb-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.tsb-suggestion {
  background: var(--tsb-white);
  border: 1.5px solid var(--tsb-primary);
  color: var(--tsb-primary);
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  outline: none;
}

.tsb-suggestion:hover {
  background: var(--tsb-primary);
  color: var(--tsb-white);
}

/* Typing indicator */
.tsb-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  background: var(--tsb-bubble-bot);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.tsb-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tsb-primary);
  animation: tsb-bounce 1.2s infinite ease-in-out;
}

.tsb-typing span:nth-child(1) { animation-delay: 0s; }
.tsb-typing span:nth-child(2) { animation-delay: 0.2s; }
.tsb-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes tsb-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Input area */
.tsb-input-area {
  padding: 12px 16px;
  border-top: 1px solid #e8e8e8;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
  background: var(--tsb-white);
}

.tsb-input {
  flex: 1;
  border: 1.5px solid #ddd;
  border-radius: 20px;
  padding: 9px 14px;
  font-size: 14px;
  resize: none;
  outline: none;
  font-family: inherit;
  line-height: 1.4;
  max-height: 96px;
  overflow-y: auto;
  transition: border-color 0.15s;
  color: var(--tsb-text);
  background: #fafafa;
}

.tsb-input:focus {
  border-color: var(--tsb-primary);
  background: var(--tsb-white);
}

.tsb-input::placeholder {
  color: #aaa;
}

.tsb-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--tsb-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
  outline: none;
}

.tsb-send:hover {
  background: var(--tsb-primary-dark);
}

.tsb-send:active {
  transform: scale(0.92);
}

.tsb-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tsb-send svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--tsb-white);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Mobile */
@media (max-width: 480px) {
  .tsb-panel {
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    transform-origin: bottom center;
  }

  .tsb-bubble-wrapper {
    bottom: 16px;
    right: 16px;
  }
}
