/* 
 * Cemtaş Medikal - Premium AI Assistant CSS Stylesheet
 * Style Language: Midnight Ultra Dynamic vNext (Frosted Glassmorphism, Spatial UI, Cyberpunk Neon Glows)
 */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Space+Grotesk:wght@500;600;700;800&display=swap');

:root {
  --chat-bg-dark: rgba(10, 20, 20, 0.85); /* Deep slate-graphite with dark teal tint */
  --chat-panel-blur: 24px;
  --chat-accent: #10b981; /* Premium Emerald/Teal green */
  --chat-accent-glow: rgba(16, 185, 129, 0.35);
  --chat-text-primary: #f8fafc;
  --chat-text-muted: #94a3b8;
  --chat-border: rgba(255, 255, 255, 0.08);
  --chat-glass-inner: rgba(255, 255, 255, 0.04);
  --chat-glass-inner-hover: rgba(255, 255, 255, 0.08);
  --chat-shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.4), 0 0 40px rgba(16, 185, 129, 0.05);
  --chat-font-title: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --chat-font-body: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  --chat-transition-fluid: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================
   FLOATING ACTION BUTTON (FAB) TRIGGER
   ========================================== */
#cemtas-chat-trigger {
  position: fixed;
  bottom: 24px; /* Positioned nicely below the desktop FAB container */
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0d4f4f 0%, #10b981 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 99999;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 
    0 8px 32px rgba(13, 79, 79, 0.3),
    0 0 0 1px rgba(16, 185, 129, 0.2),
    inset 0 2px 4px rgba(255, 255, 255, 0.2);
  transition: var(--chat-transition-fluid);
  will-change: transform, box-shadow;
}

#cemtas-chat-trigger:hover {
  transform: translateY(-5px) scale(1.05);
  box-shadow: 
    0 12px 40px rgba(13, 79, 79, 0.4),
    0 0 25px var(--chat-accent-glow),
    inset 0 2px 6px rgba(255, 255, 255, 0.3);
}

#cemtas-chat-trigger:active {
  transform: translateY(1px) scale(0.95);
}

#cemtas-chat-trigger i {
  color: #ffffff;
  font-size: 26px;
  transition: var(--chat-transition-fluid);
}

#cemtas-chat-trigger:hover i {
  transform: rotate(15deg);
}

/* Trigger Pulse Ripple Animation */
#cemtas-chat-trigger::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid var(--chat-accent);
  opacity: 0;
  animation: triggerRipple 3s ease-out infinite;
  pointer-events: none;
}

@keyframes triggerRipple {
  0% { transform: scale(1); opacity: 0.5; }
  50% { opacity: 0; transform: scale(1.4); }
  100% { opacity: 0; transform: scale(1.6); }
}

/* Floating Greeting Badge */
#cemtas-chat-badge {
  position: absolute;
  right: 80px;
  top: 12px;
  background: var(--chat-bg-dark);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--chat-border);
  padding: 10px 16px;
  border-radius: 14px 14px 2px 14px;
  color: var(--chat-text-primary);
  font-family: var(--chat-font-body);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateX(15px);
  transition: var(--chat-transition-fluid);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

#cemtas-chat-badge.visible {
  opacity: 1;
  transform: translateX(0);
}

#cemtas-chat-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chat-accent);
  box-shadow: 0 0 8px var(--chat-accent);
  animation: badgeDotPulse 1.5s infinite alternate;
}

@keyframes badgeDotPulse {
  0% { transform: scale(0.8); opacity: 0.5; }
  100% { transform: scale(1.2); opacity: 1; }
}


/* ==========================================
   CHATBOX WIDGET WINDOW
   ========================================== */
#cemtas-chat-box {
  position: fixed;
  bottom: 104px; /* Opened precisely above the trigger button */
  right: 24px;
  width: 400px;
  height: 580px;
  border-radius: 24px;
  background: var(--chat-bg-dark);
  backdrop-filter: blur(var(--chat-panel-blur));
  -webkit-backdrop-filter: blur(var(--chat-panel-blur));
  border: 1px solid var(--chat-border);
  box-shadow: var(--chat-shadow-lg);
  z-index: 99998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(30px) scale(0.95);
  visibility: hidden;
  transition: 
    opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
    visibility 0.4s;
  will-change: transform, opacity;
  font-family: var(--chat-font-body);
}

#cemtas-chat-box.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
}

/* Ambient light leak background effect inside chat */
#cemtas-chat-box::before {
  content: '';
  position: absolute;
  top: -150px;
  right: -150px;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.08) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ==========================================
   CHAT HEADER
   ========================================== */
.chat-header {
  padding: 16px 20px;
  background: rgba(13, 79, 79, 0.3);
  border-bottom: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 10;
}

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

.chat-header-avatar {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.01) 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 2px 4px rgba(255,255,255,0.05);
}

.chat-header-avatar i {
  color: var(--chat-accent);
  font-size: 18px;
  filter: drop-shadow(0 0 5px var(--chat-accent));
}

.chat-header-status-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--chat-accent);
  border: 2px solid #071717;
  box-shadow: 0 0 8px var(--chat-accent);
}

.chat-header-details h3 {
  font-family: var(--chat-font-title);
  color: var(--chat-text-primary);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0;
}

.chat-header-details p {
  color: var(--chat-text-muted);
  font-size: 10px;
  font-weight: 500;
  margin: 2px 0 0 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

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

.chat-header-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: var(--chat-glass-inner);
  color: var(--chat-text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--chat-transition-fluid);
}

.chat-header-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

/* ==========================================
   CHAT MESSAGES CONTAINER
   ========================================== */
.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* Custom Scrollbar for Chat Window */
.chat-messages::-webkit-scrollbar {
  width: 5px;
}
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ==========================================
   CHAT BUBBLES & MARKDOWN RENDER
   ========================================== */
.chat-bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 13px;
  line-height: 1.6;
  position: relative;
  word-wrap: break-word;
  animation: bubbleReveal 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
  will-change: transform, opacity;
}

@keyframes bubbleReveal {
  0% { transform: translateY(10px) scale(0.98); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* AI Message Bubble */
.chat-bubble.ai {
  align-self: flex-start;
  background: var(--chat-glass-inner);
  border: 1px solid var(--chat-border);
  color: #e2e8f0;
  border-bottom-left-radius: 4px;
}

/* User Message Bubble */
.chat-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #0d4f4f 0%, #10b981 100%);
  border: 1px solid rgba(255,255,255,0.1);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.15);
}

/* Markdown formatting inside bubbles */
.chat-bubble h3 {
  font-family: var(--chat-font-title);
  font-size: 14px;
  margin: 0 0 8px 0;
  color: #ffffff;
  font-weight: 700;
}
.chat-bubble p {
  margin: 0 0 8px 0;
}
.chat-bubble p:last-child {
  margin-bottom: 0;
}
.chat-bubble ul, .chat-bubble ol {
  margin: 0 0 10px 0;
  padding-left: 20px;
}
.chat-bubble ul:last-child, .chat-bubble ol:last-child {
  margin-bottom: 0;
}
.chat-bubble li {
  margin-bottom: 4px;
}
.chat-bubble li:last-child {
  margin-bottom: 0;
}

/* Elegant glassmorphic markdown links */
.chat-bubble a {
  color: #34d399;
  text-decoration: underline;
  font-weight: 700;
  transition: var(--chat-transition-fluid);
}
.chat-bubble a:hover {
  color: #ffffff;
  text-shadow: 0 0 8px rgba(52, 211, 153, 0.4);
}
.chat-bubble.user a {
  color: #e2e8f0;
  text-decoration: underline;
}
.chat-bubble.user a:hover {
  color: #ffffff;
}

/* Timestamp element */
.chat-time {
  font-size: 9px;
  color: var(--chat-text-muted);
  margin-top: 4px;
  display: block;
  text-align: right;
  font-weight: 500;
}
.chat-bubble.user .chat-time {
  color: rgba(255, 255, 255, 0.6);
}

/* ==========================================
   QUICK REPLY SUGGESTIONS
   ========================================== */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 20px 12px 20px;
  position: relative;
  z-index: 10;
}

.suggestion-chip {
  background: var(--chat-glass-inner);
  border: 1px solid var(--chat-border);
  color: #cbd5e1;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--chat-transition-fluid);
  display: flex;
  align-items: center;
  gap: 6px;
}

.suggestion-chip:hover {
  background: var(--chat-glass-inner-hover);
  border-color: var(--chat-accent);
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.1);
}

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

/* ==========================================
   TYPING INDICATOR
   ========================================== */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--chat-text-muted);
  border-radius: 50%;
  animation: typingBounce 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; }

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

/* ==========================================
   FOOTER CHAT INPUT
   ========================================== */
.chat-footer {
  padding: 16px 20px;
  background: rgba(13, 79, 79, 0.1);
  border-top: 1px solid var(--chat-border);
  position: relative;
  z-index: 10;
}

.chat-input-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--chat-border);
  border-radius: 16px;
  padding: 4px 6px 4px 14px;
  transition: var(--chat-transition-fluid);
}

.chat-input-wrapper:focus-within {
  border-color: var(--chat-accent);
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.15);
}

#cemtas-chat-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--chat-text-primary);
  font-family: var(--chat-font-body);
  font-size: 13px;
  outline: none;
  padding: 10px 0;
  resize: none;
  max-height: 80px;
  height: 20px;
}

#cemtas-chat-input::placeholder {
  color: var(--chat-text-muted);
}

.chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #0d4f4f 0%, #10b981 100%);
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--chat-transition-fluid);
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.2);
}

.chat-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 14px rgba(16, 185, 129, 0.3);
}

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

.chat-send-btn i {
  font-size: 14px;
  transition: var(--chat-transition-fluid);
}

.chat-send-btn:hover i {
  transform: translateX(2px) translateY(-1px);
}


/* ==========================================
   RESPONSIVENESS & MOBILE LAYOUT (WCAG 2.2)
   ========================================== */
@media (max-width: 767px) {
  #cemtas-chat-trigger {
    bottom: 96px; /* Sits nicely above the mobile sticky action bar */
    right: 16px;
    width: 56px;
    height: 56px;
  }
  
  #cemtas-chat-badge {
    display: none !important; /* Hide badge on mobile to prevent clutter */
  }

  #cemtas-chat-box {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
    width: 100% !important;
    height: 100% !important;
    border-radius: 0;
    z-index: 999999; /* Full overlap for flawless navigation */
    transform: translateY(100%);
    border: none;
  }

  #cemtas-chat-box.open {
    transform: translateY(0);
  }

  .chat-header {
    padding: 16px;
    border-radius: 0;
  }

  .chat-messages {
    padding: 16px;
  }

  .chat-footer {
    padding: 12px 16px;
    /* Safely pad bottom for iPhones and mobile notches */
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}
