/* ==========================================================================
   Liberta Design - AI Creative Consultant Chatbot Styles
   ========================================================================== */

/* --- Chatbot Floating Trigger Button --- */
.liberta-chat-trigger {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9990;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
  transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.liberta-chat-trigger:hover {
  transform: translateY(-3px) scale(1.02);
}

.liberta-chat-trigger-btn {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #121318 0%, #2a2d36 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  overflow: hidden;
}

html.dark-theme .liberta-chat-trigger-btn {
  background: linear-gradient(135deg, #ffffff 0%, #e2e8f0 100%);
  color: #0f1117;
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(255, 255, 255, 0.2);
}

.liberta-chat-trigger-btn::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.25) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.liberta-chat-trigger:hover .liberta-chat-trigger-btn::before {
  opacity: 1;
}

.liberta-chat-trigger-btn svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
  transition: transform 0.3s ease;
}

.liberta-chat-trigger-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  background: #10b981;
  border: 2px solid #121318;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
  animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.liberta-chat-tooltip {
  background: rgba(18, 19, 24, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #ffffff;
  padding: 8px 14px;
  border-radius: 30px;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}

html.dark-theme .liberta-chat-tooltip {
  background: rgba(255, 255, 255, 0.95);
  color: #0f1117;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.liberta-avatar-label {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #ffffff;
}

html.dark-theme .liberta-avatar-label {
  color: #ffffff;
}


/* --- Chatbot Modal / Drawer Container --- */
.liberta-chat-modal {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 400px;
  max-width: calc(100vw - 40px);
  height: 640px;
  max-height: calc(100vh - 100px);
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.06);
  z-index: 9995;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(30px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.35s cubic-bezier(0.25, 1, 0.5, 1), 
              transform 0.35s cubic-bezier(0.25, 1, 0.5, 1), 
              visibility 0.35s;
}

html.dark-theme .liberta-chat-modal {
  background: #111319;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.6), 0 0 30px rgba(255, 255, 255, 0.03);
}

.liberta-chat-modal.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}


/* --- Header --- */
.liberta-chat-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, #121318 0%, #1f222b 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

html.dark-theme .liberta-chat-header {
  background: linear-gradient(135deg, #0d0f14 0%, #181b22 100%);
}

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

.liberta-chat-avatar-wrap {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2b2e38 0%, #3f4452 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.liberta-chat-status-dot {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 10px;
  height: 10px;
  background: #10b981;
  border: 2px solid #121318;
  border-radius: 50%;
}

.liberta-chat-title-group h3 {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  margin: 0;
  line-height: 1.2;
}

.liberta-chat-title-group p {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.65);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.liberta-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.liberta-chat-header-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.liberta-chat-header-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.liberta-chat-header-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}


/* --- Message Body Area --- */
.liberta-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
  background: #fafafa;
}

html.dark-theme .liberta-chat-messages {
  background: #0d0e12;
}

/* Custom Scrollbar */
.liberta-chat-messages::-webkit-scrollbar {
  width: 5px;
}
.liberta-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.liberta-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 10px;
}
html.dark-theme .liberta-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
}


/* --- Message Items --- */
.liberta-msg-row {
  display: flex;
  gap: 10px;
  max-width: 90%;
  animation: msgFadeIn 0.35s ease forwards;
}

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

.liberta-msg-row.is-bot {
  align-self: flex-start;
}

.liberta-msg-row.is-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.liberta-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #121318;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

html.dark-theme .liberta-msg-avatar {
  background: #252830;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.liberta-msg-content-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.liberta-msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.6;
  position: relative;
  word-break: break-word;
}

.liberta-msg-row.is-bot .liberta-msg-bubble {
  background: #ffffff;
  color: #1a1d24;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-top-left-radius: 4px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

html.dark-theme .liberta-msg-row.is-bot .liberta-msg-bubble {
  background: #1a1d26;
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.liberta-msg-row.is-user .liberta-msg-bubble {
  background: linear-gradient(135deg, #121318 0%, #2b2e3a 100%);
  color: #ffffff;
  border-top-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(18, 19, 24, 0.2);
}

html.dark-theme .liberta-msg-row.is-user .liberta-msg-bubble {
  background: linear-gradient(135deg, #ffffff 0%, #e2e8f0 100%);
  color: #0f1117;
  font-weight: 500;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.liberta-msg-time {
  font-size: 0.68rem;
  color: #8c91a0;
  align-self: flex-start;
  padding: 0 4px;
}

.liberta-msg-row.is-user .liberta-msg-time {
  align-self: flex-end;
}


/* --- Typing Animation Indicator --- */
.liberta-typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 18px;
}

.liberta-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8c91a0;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.liberta-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.liberta-typing-dot:nth-child(2) { animation-delay: -0.16s; }
.liberta-typing-dot:nth-child(3) { animation-delay: 0s; }

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


/* --- Suggestion Chips (Options) --- */
.liberta-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  animation: msgFadeIn 0.3s ease forwards;
}

.liberta-chip-btn {
  background: #ffffff;
  color: #1a1d24;
  border: 1px solid rgba(18, 19, 24, 0.12);
  padding: 9px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  text-align: left;
}

html.dark-theme .liberta-chip-btn {
  background: #1e222d;
  color: #f1f5f9;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.liberta-chip-btn:hover {
  background: #121318;
  color: #ffffff;
  border-color: #121318;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(18, 19, 24, 0.15);
}

html.dark-theme .liberta-chip-btn:hover {
  background: #ffffff;
  color: #0f1117;
  border-color: #ffffff;
  box-shadow: 0 4px 15px rgba(255, 255, 255, 0.2);
}

.liberta-chip-btn:active {
  transform: translateY(0);
}


/* --- Rich Diagnosis Result Card (Step 7) --- */
.liberta-diag-card {
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  padding: 16px;
  margin-top: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

html.dark-theme .liberta-diag-card {
  background: #171922;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.4);
}

.liberta-diag-header {
  border-bottom: 1px dashed rgba(0, 0, 0, 0.1);
  padding-bottom: 10px;
}

html.dark-theme .liberta-diag-header {
  border-bottom-color: rgba(255, 255, 255, 0.12);
}

.liberta-diag-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 4px;
  background: #121318;
  color: #ffffff;
  margin-bottom: 6px;
}

html.dark-theme .liberta-diag-badge {
  background: #ffffff;
  color: #0f1117;
}

.liberta-diag-title {
  font-size: 1rem;
  font-weight: 700;
  color: #121318;
  margin: 0;
}

html.dark-theme .liberta-diag-title {
  color: #ffffff;
}

.liberta-diag-analysis {
  font-size: 0.83rem;
  line-height: 1.6;
  color: #4b5563;
  background: #f8fafc;
  padding: 10px 12px;
  border-radius: 10px;
  border-left: 3px solid #121318;
}

html.dark-theme .liberta-diag-analysis {
  background: #0f1117;
  color: #cbd5e1;
  border-left-color: #ffffff;
}

.liberta-diag-plans-title {
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #121318;
}

html.dark-theme .liberta-diag-plans-title {
  color: #ffffff;
}

.liberta-diag-plan-item {
  background: #fafafa;
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

html.dark-theme .liberta-diag-plan-item {
  background: #20232e;
  border-color: rgba(255, 255, 255, 0.06);
}

.liberta-diag-plan-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.liberta-diag-rank {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 6px;
  background: #e2e8f0;
  color: #334155;
}

.liberta-diag-rank.rank-1 {
  background: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
  color: #ffffff;
}

.liberta-diag-plan-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: #1e293b;
  flex: 1;
  margin-left: 8px;
}

html.dark-theme .liberta-diag-plan-name {
  color: #f1f5f9;
}

.liberta-diag-plan-desc {
  font-size: 0.78rem;
  color: #64748b;
  line-height: 1.5;
  margin: 0;
}

html.dark-theme .liberta-diag-plan-desc {
  color: #94a3b8;
}

.liberta-diag-cost-box {
  background: linear-gradient(135deg, #121318 0%, #232733 100%);
  color: #ffffff;
  padding: 12px 14px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

html.dark-theme .liberta-diag-cost-box {
  background: linear-gradient(135deg, #232733 0%, #171922 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.liberta-diag-cost-label {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.75);
}

.liberta-diag-cost-val {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: #38bdf8;
}

.liberta-diag-cta-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border: none;
  padding: 13px 18px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
  transition: all 0.25s ease;
  width: 100%;
  text-decoration: none;
  margin-top: 4px;
}

.liberta-diag-cta-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(16, 185, 129, 0.5);
  background: linear-gradient(135deg, #34d399 0%, #059669 100%);
  color: #ffffff;
}

.liberta-diag-restart-btn {
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.12);
  color: #64748b;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.2s ease;
  width: 100%;
}

html.dark-theme .liberta-diag-restart-btn {
  border-color: rgba(255, 255, 255, 0.15);
  color: #94a3b8;
}

.liberta-diag-restart-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #1e293b;
}

html.dark-theme .liberta-diag-restart-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #f1f5f9;
}


/* --- Footer Input Area --- */
.liberta-chat-footer {
  padding: 12px 16px;
  background: #ffffff;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  gap: 10px;
}

html.dark-theme .liberta-chat-footer {
  background: #111319;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.liberta-chat-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.liberta-chat-input {
  width: 100%;
  padding: 11px 16px;
  border-radius: 24px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #f8fafc;
  font-size: 0.86rem;
  color: #1e293b;
  outline: none;
  font-family: inherit;
  transition: all 0.2s ease;
}

html.dark-theme .liberta-chat-input {
  background: #1a1d26;
  border-color: rgba(255, 255, 255, 0.1);
  color: #f1f5f9;
}

.liberta-chat-input:focus {
  border-color: #121318;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(18, 19, 24, 0.08);
}

html.dark-theme .liberta-chat-input:focus {
  border-color: #ffffff;
  background: #20232f;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.liberta-chat-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #121318;
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

html.dark-theme .liberta-chat-send-btn {
  background: #ffffff;
  color: #0f1117;
}

.liberta-chat-send-btn:hover:not(:disabled) {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.liberta-chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.liberta-chat-send-btn svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
  margin-left: 2px;
}


/* --- Toast Notification --- */
.liberta-chat-toast {
  position: fixed;
  top: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(-50px);
  background: rgba(18, 19, 24, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #ffffff;
  padding: 14px 24px;
  border-radius: 40px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.15);
  z-index: 99999;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  pointer-events: none;
}

.liberta-chat-toast.is-show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
}

.liberta-chat-toast .toast-icon {
  font-size: 1.2rem;
}


/* --- Mobile Responsive Tweaks --- */
@media (max-width: 600px) {
  .liberta-chat-trigger {
    bottom: 20px;
    right: 20px;
  }

  .liberta-chat-tooltip {
    display: none; /* Hide tooltip on small mobile to save space */
  }

  .liberta-chat-modal {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100vw;
    max-width: 100vw;
    height: 92vh;
    max-height: 92vh;
    border-radius: 24px 24px 0 0;
    transform: translateY(100%);
    transform-origin: bottom center;
  }

  .liberta-chat-modal.is-open {
    transform: translateY(0);
  }
}
