/* style.css - Premium Design System for Dr. Rajeev Patient Chatbot */

:root {
  /* Color System */
  --primary-navy: hsl(220, 71%, 20%);
  --primary-navy-dark: hsl(220, 72%, 14%);
  --primary-navy-light: hsl(219, 45%, 35%);
  --accent-teal: hsl(187, 87%, 24%);
  --accent-teal-light: hsl(187, 50%, 94%);
  --accent-gold: hsl(45, 94%, 40%);
  --accent-gold-light: hsl(45, 80%, 96%);
  
  --bg-neutral: hsl(45, 20%, 97%);
  --surface-white: hsl(0, 0%, 100%);
  
  --text-dark: hsl(220, 40%, 15%);
  --text-muted: hsl(220, 15%, 45%);
  --text-light: hsl(0, 0%, 95%);
  
  --border-color: hsl(220, 20%, 90%);
  --shadow-sm: 0 2px 8px rgba(15, 41, 90, 0.05);
  --shadow-md: 0 10px 30px -5px rgba(15, 41, 90, 0.08);
  --shadow-lg: 0 20px 40px -10px rgba(15, 41, 90, 0.15);
  
  /* Fonts */
  --font-headers: 'Outfit', sans-serif;
  --font-body: 'Montserrat', sans-serif;
  
  /* Dimensions */
  --border-radius-sm: 8px;
  --border-radius-md: 16px;
  --border-radius-lg: 24px;
}

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  background: transparent;
}

body {
  font-family: var(--font-body);
  background: transparent;
  color: var(--text-dark);
  line-height: 1.5;
  min-height: 100vh;
  overflow: hidden;
}

/* Floating Widget Root */
.chat-widget-root {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 16px;
  z-index: 999999;
}

/* Floating Action Button */
.chat-toggle-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--primary-navy) 0%, var(--accent-teal) 150%);
  color: var(--surface-white);
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.chat-toggle-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 20px 40px -8px rgba(15, 41, 90, 0.4);
}

.chat-toggle-btn .icon-close {
  display: none;
}

.chat-widget-root.open .chat-toggle-btn .icon-open {
  display: none;
}

.chat-widget-root.open .chat-toggle-btn .icon-close {
  display: inline-flex;
}

/* Gentle attention pulse while the widget is closed */
.chat-toggle-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent-teal);
  opacity: 0;
  animation: pulseRing 2.6s ease-out infinite;
  pointer-events: none;
}

.chat-widget-root.open .chat-toggle-btn::before {
  animation: none;
  opacity: 0;
}

@keyframes pulseRing {
  0% { transform: scale(0.95); opacity: 0.55; }
  80% { transform: scale(1.45); opacity: 0; }
  100% { opacity: 0; }
}

/* Greeting Teaser Bubble */
.chat-teaser {
  position: relative;
  display: none;
  align-items: center;
  gap: 10px;
  max-width: 250px;
  padding: 12px 14px;
  background: var(--surface-white);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-teaser.show {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
  animation: teaserPop 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Hide the teaser entirely once the chat panel is open */
.chat-widget-root.open .chat-teaser {
  display: none !important;
}

/* Little tail pointing down toward the floating button */
.chat-teaser::after {
  content: '';
  position: absolute;
  bottom: -7px;
  right: 22px;
  width: 14px;
  height: 14px;
  background: var(--surface-white);
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  transform: rotate(45deg);
}

.teaser-avatar {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-navy) 0%, var(--accent-teal) 150%);
  color: var(--surface-white);
  font-family: var(--font-headers);
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.teaser-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
}

.teaser-name {
  font-family: var(--font-headers);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-teal);
  letter-spacing: 0.01em;
}

.teaser-msg {
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-dark);
  line-height: 1.35;
}

.teaser-close {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--surface-white);
  color: var(--text-muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.2s ease, color 0.2s ease;
}

.teaser-close:hover {
  background: var(--bg-neutral);
  color: var(--text-dark);
}

@keyframes teaserPop {
  0% { transform: translateY(14px) scale(0.9); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* Chat Window Panel */
.chat-window {
  width: 380px;
  height: 640px;
  max-height: calc(100vh - 110px);
  max-width: calc(100vw - 32px);
  background: var(--surface-white);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  position: absolute;
  bottom: calc(100% + 16px);
  right: 0;
  transform-origin: bottom right;
  transform: translateY(16px) scale(0.96);
  opacity: 0;
  visibility: hidden;
  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), visibility 0.25s;
}

.chat-widget-root.open .chat-window {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* Chatbot Card */
.chatbot-card {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Close button shown inside each panel (lead form / chat header) */
.panel-close-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.panel-close-btn:hover {
  background: var(--bg-neutral);
  color: var(--primary-navy);
}

.lead-topbar .panel-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  color: rgba(255, 255, 255, 0.8);
}

.lead-topbar .panel-close-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--surface-white);
}

/* Lead Form Styles */
.form-container {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Branded gradient header (shared look with chat header) */
.lead-topbar,
.chat-header {
  background: linear-gradient(135deg, var(--primary-navy) 0%, var(--accent-teal) 150%);
  color: var(--surface-white);
  position: relative;
  flex-shrink: 0;
}

.lead-topbar {
  text-align: center;
  padding: 28px 24px 22px;
}

.topbar-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
}

.topbar-title {
  font-family: var(--font-headers);
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 4px;
}

.topbar-subtitle {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 500;
}

.form-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 24px 28px;
  animation: slideInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.form-intro {
  margin-bottom: 22px;
}

.form-intro h2 {
  font-family: var(--font-headers);
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-navy-dark);
  margin-bottom: 6px;
}

.form-intro p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Input Fields */
.input-group {
  margin-bottom: 20px;
}

.input-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-navy);
  margin-bottom: 6px;
}

.input-group label .required {
  color: #d9534f;
}

.input-group label .optional {
  font-weight: 400;
  color: var(--text-muted);
}

.input-wrapper {
  position: relative;
}

.input-wrapper input,
.input-wrapper textarea {
  width: 100%;
  padding: 13px 16px 13px 44px;
  border: 1.5px solid transparent;
  border-radius: 12px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-dark);
  background-color: var(--bg-neutral);
  transition: all 0.2s ease;
}

.input-wrapper textarea {
  padding-left: 16px;
  resize: vertical;
}

.input-wrapper input::placeholder,
.input-wrapper textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.input-wrapper input:focus,
.input-wrapper textarea:focus {
  outline: none;
  background-color: var(--surface-white);
  border-color: var(--accent-teal);
  box-shadow: 0 0 0 3px var(--accent-teal-light);
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 18px;
  pointer-events: none;
}

.input-help {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Button UI */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: var(--border-radius-sm);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-navy) 0%, var(--primary-navy-dark) 100%);
  color: var(--surface-white);
  box-shadow: 0 4px 14px rgba(15, 41, 90, 0.25);
  margin-top: 8px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(15, 41, 90, 0.3);
}

.btn-primary i {
  transition: transform 0.2s ease;
}

.btn-primary:hover i {
  transform: translateX(3px);
}

.btn-block {
  width: 100%;
}

/* Chat Layout */
.chat-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  animation: fadeIn 0.4s ease forwards;
}

/* Chat Header */
.chat-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.doctor-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.avatar-wrapper {
  position: relative;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

.avatar-text {
  width: 100%;
  height: 100%;
  background: var(--surface-white);
  color: var(--primary-navy);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-headers);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.5px;
  box-shadow: var(--shadow-sm);
}

.status-indicator {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--primary-navy);
}

.status-indicator.online {
  background-color: #4cd964;
  box-shadow: 0 0 0 2px rgba(80, 200, 120, 0.4);
}

.doctor-info {
  min-width: 0;
  overflow: hidden;
}

.doctor-info .dr-title,
.doctor-info h2 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doctor-info .dr-title {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 600;
  line-height: 1.4;
}

.doctor-info h2 {
  font-family: var(--font-headers);
  font-size: 15px;
  font-weight: 700;
  color: var(--surface-white);
  line-height: 1.3;
}

.doctor-info .dr-specialty {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 500;
  line-height: 1.4;
}

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

.header-actions .panel-close-btn {
  color: rgba(255, 255, 255, 0.8);
  flex-shrink: 0;
}

.header-actions .panel-close-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--surface-white);
}

/* Live status badge - confirms the assistant is connected to a real backend */
.live-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--surface-white);
  background: rgba(255, 59, 48, 0.18);
  border: 1px solid rgba(255, 59, 48, 0.45);
  padding: 4px 9px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #ff3b30;
  box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.6);
  animation: liveDotPulse 1.8s infinite;
}

@keyframes liveDotPulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.6); }
  70% { box-shadow: 0 0 0 6px rgba(255, 59, 48, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0); }
}

/* On narrow widths, hide the LIVE label and keep just the pulse dot to give the doctor's name room */
@media (max-width: 360px) {
  .live-badge {
    padding: 6px;
  }
  .live-badge-text {
    display: none;
  }
}

/* Messages Area */
.messages-area {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: linear-gradient(180deg, var(--bg-neutral) 0%, hsl(45, 24%, 95%) 100%);
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

/* Custom Scrollbar for Messages */
.messages-area::-webkit-scrollbar {
  width: 6px;
}

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

.messages-area::-webkit-scrollbar-thumb {
  background-color: rgba(15, 41, 90, 0.1);
  border-radius: 3px;
}

.messages-area::-webkit-scrollbar-thumb:hover {
  background-color: rgba(15, 41, 90, 0.25);
}

/* Message Bubbles */
.message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: slideInBubble 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.message.bot {
  align-self: flex-start;
}

.message.user {
  align-self: flex-end;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: 20px;
  font-size: 14px;
  line-height: 1.55;
  box-shadow: var(--shadow-sm);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.message.bot .message-bubble {
  background: linear-gradient(180deg, var(--surface-white) 0%, hsl(220, 30%, 99%) 100%);
  color: var(--text-dark);
  border-top-left-radius: 6px;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 14px -6px rgba(15, 41, 90, 0.12);
}

.message.user .message-bubble {
  background: linear-gradient(135deg, var(--accent-teal) 0%, var(--primary-navy-light) 130%);
  color: var(--surface-white);
  border-top-right-radius: 6px;
  border: none;
  box-shadow: 0 6px 16px -6px rgba(15, 87, 90, 0.45);
}

.message-bubble p {
  margin-bottom: 8px;
}

.message-bubble p:last-child {
  margin-bottom: 0;
}

.message-bubble strong {
  font-weight: 600;
}

.message-bubble ul {
  padding-left: 20px;
  margin-top: 6px;
  margin-bottom: 6px;
}

.message-bubble li {
  margin-bottom: 4px;
}

.message-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  align-self: flex-start;
}

.message.user .message-time {
  align-self: flex-end;
}

/* Suggestion Chips */
.chips-area {
  padding: 8px 16px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  white-space: nowrap;
  background-color: var(--bg-neutral);
  border-top: 1px solid var(--border-color);
}

.chips-area::-webkit-scrollbar {
  height: 4px;
}

.chips-area::-webkit-scrollbar-thumb {
  background: rgba(15, 41, 90, 0.08);
  border-radius: 2px;
}

.chip {
  padding: 6px 12px;
  background: var(--surface-white);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--primary-navy);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-sm);
}

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

/* Footer & Input Section */
.chat-footer {
  padding: 12px 16px;
  background-color: var(--surface-white);
  border-top: 1px solid var(--border-color);
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background-color: var(--bg-neutral);
  border: 1.5px solid transparent;
  border-radius: var(--border-radius-md);
  padding: 8px 12px;
  transition: all 0.2s ease;
}

.input-row:focus-within {
  background-color: var(--surface-white);
  border-color: var(--accent-teal);
  box-shadow: 0 0 0 3px var(--accent-teal-light);
}

.input-row textarea {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  font-family: var(--font-body);
  font-size: 14px;
  max-height: 120px;
  padding: 4px 0;
  color: var(--text-dark);
}

.input-row textarea:focus {
  outline: none;
}

.btn-send {
  background: linear-gradient(135deg, var(--accent-teal) 0%, hsl(187, 87%, 30%) 100%);
  color: var(--surface-white);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.btn-send:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(15, 87, 90, 0.3);
}

.btn-send:active {
  transform: scale(0.95);
}

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

.footer-note {
  text-align: center;
  margin-top: 8px;
  font-size: 10px;
  color: var(--text-muted);
}

/* Typing Indicator Animation */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 4px;
  align-items: center;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background-color: var(--text-muted);
  border-radius: 50%;
  opacity: 0.4;
  animation: bounceDot 1.4s infinite ease-in-out both;
}

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

/* Animations */
@keyframes bounceDot {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1.0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes slideInBubble {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Mobile & Embedding Breakpoints */
@media (max-width: 480px) {
  .chat-widget-root {
    bottom: 16px;
    right: 16px;
  }

  .chat-window {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
  }

  .form-container {
    padding: 24px 16px;
  }
}
