/**
 * TumbuhCare.ID — Chatbot Widget Styles
 * Palet: Sage (#7a9e7e), Blush (#f2ddd5), Cream (#faf7f2), Charcoal (#2c2c2c)
 * Tipografi: Playfair Display + DM Sans
 */

:root {
  --tc-sage: #7a9e7e;
  --tc-sage-light: #e8f0e9;
  --tc-sage-dark: #4a6b4e;
  --tc-blush: #f2ddd5;
  --tc-blush-deep: #e8b9a8;
  --tc-cream: #faf7f2;
  --tc-warm-white: #fffdf9;
  --tc-charcoal: #2c2c2c;
  --tc-muted: #7a7570;
  --tc-border: rgba(122, 158, 126, 0.2);
  --tc-shadow: 0 16px 40px -10px rgba(74, 107, 78, 0.25), 0 8px 16px -6px rgba(0, 0, 0, 0.08);
  --tc-radius: 20px;
}

/* Sembunyikan tombol WA lama saat widget chatbot aktif */
.has-tc-chat .wa-float {
  display: none !important;
}

/* === LAUNCHER BUTTON === */
.tc-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9990;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--tc-sage);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 12px 20px 12px 14px;
  font-family: 'DM Sans', -apple-system, sans-serif;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(74, 107, 78, 0.35);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.2s ease, box-shadow 0.2s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.tc-chat-launcher:hover {
  background: var(--tc-sage-dark);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(74, 107, 78, 0.45);
}

.tc-chat-launcher:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--tc-sage);
}

.tc-chat-launcher-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tc-chat-launcher-text {
  letter-spacing: -0.01em;
}

/* Badge notifikasi */
.tc-chat-launcher-badge {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #ff5252;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #fff;
}

/* === CHAT PANEL === */
.tc-chat-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 390px;
  max-width: calc(100vw - 32px);
  height: 640px;
  max-height: calc(100vh - 48px);
  margin: 0 !important;
  padding: 0 !important;
  box-sizing: border-box !important;
  background: var(--tc-warm-white);
  border: 1px solid rgba(122, 158, 126, 0.28);
  border-radius: var(--tc-radius);
  box-shadow: 
    0 24px 50px -12px rgba(35, 52, 38, 0.22),
    0 8px 24px -4px rgba(0, 0, 0, 0.08),
    0 0 0 1px rgba(255, 255, 255, 0.6) inset;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: 'DM Sans', -apple-system, sans-serif;
  color: var(--tc-charcoal);
  opacity: 0;
  transform: translateY(20px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.tc-chat-panel.tc-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* === PANEL HEADER === */
.tc-chat-header {
  margin: 0;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--tc-sage) 0%, var(--tc-sage-dark) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  border-top-left-radius: var(--tc-radius);
  border-top-right-radius: var(--tc-radius);
}

.tc-chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tc-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tc-sage-dark);
  font-weight: 700;
  font-size: 1.1rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.tc-chat-header-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.2;
  margin: 0;
  letter-spacing: -0.01em;
}

.tc-chat-header-status {
  font-size: 0.75rem;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.tc-chat-header-status::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #25d366;
  border-radius: 50%;
}

.tc-chat-close-btn {
  background: transparent;
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.2s, background-color 0.2s;
}

.tc-chat-close-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.15);
}

.tc-chat-close-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px #fff;
}

/* === NOTICE / BANNER === */
.tc-chat-privacy-notice {
  font-size: 0.75rem;
  padding: 6px 16px;
  background: var(--tc-cream);
  color: var(--tc-muted);
  border-bottom: 1px solid var(--tc-border);
  text-align: center;
  line-height: 1.35;
}

/* === MESSAGES CONTAINER === */
.tc-chat-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--tc-warm-white);
}

.tc-chat-body::-webkit-scrollbar {
  width: 5px;
}
.tc-chat-body::-webkit-scrollbar-thumb {
  background: rgba(122, 158, 126, 0.25);
  border-radius: 10px;
}

/* === MESSAGE BUBBLE === */
.tc-msg {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: tcFadeIn 0.2s ease-out;
}

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

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

.tc-msg-bubble {
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.45;
  word-break: break-word;
}

.tc-msg.tc-bot .tc-msg-bubble {
  background: var(--tc-cream);
  color: var(--tc-charcoal);
  border: 1px solid var(--tc-border);
  border-bottom-left-radius: 4px;
}

.tc-msg.tc-user .tc-msg-bubble {
  background: var(--tc-sage);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.tc-msg-time {
  font-size: 0.7rem;
  color: var(--tc-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.tc-msg.tc-user .tc-msg-time {
  text-align: right;
}

/* Typing indicator */
.tc-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
}

.tc-typing-dot {
  width: 6px;
  height: 6px;
  background: var(--tc-sage);
  border-radius: 50%;
  animation: tcTyping 1.2s infinite ease-in-out;
}

.tc-typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}
.tc-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

/* === QUICK CHIPS === */
.tc-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.tc-chip {
  background: #fff;
  border: 1px solid var(--tc-border);
  color: var(--tc-sage-dark);
  padding: 7px 12px;
  border-radius: 50px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
  touch-action: manipulation;
}

.tc-chip:hover {
  background: var(--tc-sage-light);
  border-color: var(--tc-sage);
  transform: translateY(-1px);
}

.tc-chip:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--tc-sage);
}

.tc-chip.tc-chip-primary {
  background: var(--tc-sage);
  color: #fff;
  border-color: var(--tc-sage);
}

.tc-chip.tc-chip-primary:hover {
  background: var(--tc-sage-dark);
}

/* Urgent / Red Flag Card */
.tc-card-urgent {
  background: #fff5f5;
  border: 1px solid #fed7d7;
  border-left: 4px solid #e53e3e;
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 8px;
  font-size: 0.82rem;
  color: #9b2c2c;
  line-height: 1.4;
}

/* === STEP CARDS / INTERACTIVE BOOKING FORM === */
.tc-step-card {
  background: #fff;
  border: 1px solid var(--tc-border);
  border-radius: 14px;
  padding: 14px;
  margin-top: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.tc-step-title {
  font-family: 'Playfair Display', serif;
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--tc-charcoal);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tc-step-badge {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--tc-sage-dark);
  background: var(--tc-sage-light);
  padding: 2px 8px;
  border-radius: 10px;
}

/* Price Preview Box */
.tc-price-summary {
  background: var(--tc-cream);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 8px;
  font-size: 0.82rem;
}

.tc-price-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

.tc-price-row.tc-total {
  border-top: 1px dashed rgba(122, 158, 126, 0.3);
  padding-top: 6px;
  margin-top: 6px;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--tc-sage-dark);
}

.tc-price-disclaimer {
  font-size: 0.72rem;
  color: var(--tc-muted);
  margin-top: 5px;
  line-height: 1.35;
  font-style: italic;
}

/* Form controls inside widget */
.tc-form-group {
  margin-bottom: 10px;
}

.tc-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--tc-charcoal);
  margin-bottom: 4px;
}

.tc-input,
.tc-select,
.tc-textarea {
  width: 100%;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 0.84rem;
  border: 1px solid var(--tc-border);
  border-radius: 8px;
  background: #fff;
  color: var(--tc-charcoal);
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tc-input:focus,
.tc-select:focus,
.tc-textarea:focus {
  outline: none;
  border-color: var(--tc-sage);
  box-shadow: 0 0 0 2px rgba(122, 158, 126, 0.25);
}

.tc-input-error {
  border-color: #e53e3e !important;
}

.tc-error-text {
  font-size: 0.72rem;
  color: #e53e3e;
  margin-top: 3px;
  display: block;
}

.tc-btn-block {
  width: 100%;
  padding: 10px;
  background: var(--tc-sage);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  margin-top: 8px;
  transition: background-color 0.15s ease, transform 0.15s ease;
  touch-action: manipulation;
}

.tc-btn-block:hover {
  background: var(--tc-sage-dark);
}

.tc-btn-block:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(122, 158, 126, 0.4);
}

.tc-btn-block:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.tc-btn-wa {
  background: #25d366;
  color: #fff;
}

.tc-btn-wa:hover {
  background: #1ebc57;
}

/* Success Card */
.tc-card-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  color: #166534;
}

.tc-booking-code {
  font-family: monospace;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--tc-sage-dark);
  background: #fff;
  border: 1px dashed var(--tc-sage);
  border-radius: 6px;
  padding: 6px 10px;
  margin: 8px 0;
  display: inline-block;
}

/* === CHAT INPUT FOOTER === */
.tc-chat-footer {
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid var(--tc-border);
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom-left-radius: var(--tc-radius);
  border-bottom-right-radius: var(--tc-radius);
}

.tc-chat-input {
  flex: 1;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 0.88rem;
  border: 1px solid var(--tc-border);
  border-radius: 24px;
  background: var(--tc-cream);
  color: var(--tc-charcoal);
  box-sizing: border-box;
}

.tc-chat-input:focus {
  outline: none;
  border-color: var(--tc-sage);
  background: #fff;
  box-shadow: 0 0 0 2px rgba(122, 158, 126, 0.25);
}

.tc-chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--tc-sage);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background-color 0.15s ease, transform 0.15s ease;
  touch-action: manipulation;
}

.tc-chat-send-btn:hover {
  background: var(--tc-sage-dark);
  transform: scale(1.05);
}

.tc-chat-send-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--tc-sage);
}

.tc-chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Keyframes */
@keyframes tcFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes tcTyping {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* === MOBILE RESPONSIVENESS (BOTTOM SHEET) === */
@media (max-width: 640px) {
  .tc-chat-launcher {
    bottom: 18px;
    right: 18px;
    padding: 10px 16px 10px 12px;
    font-size: 0.86rem;
  }

  .tc-chat-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100vw;
    max-width: 100vw;
    height: 92vh;
    max-height: 92vh;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

/* Prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .tc-chat-launcher,
  .tc-chat-panel,
  .tc-msg,
  .tc-chip,
  .tc-btn-block {
    transition: none !important;
    animation: none !important;
  }
}
