/* Enhanced Chat Widget Styles v3.0 - Tech-Savvy Edition */

:root {
  --chat-primary: hsl(220, 50%, 50%);
  --chat-secondary: hsl(280, 60%, 60%);
  --chat-success: hsl(142, 76%, 36%);
  --chat-warning: hsl(43, 96%, 56%);
  --chat-error: hsl(0, 84%, 60%);
  --chat-bg-dark: rgba(26, 32, 44, 0.98);
  --chat-bg-glass: rgba(45, 55, 72, 0.85);
  --chat-border: rgba(255, 255, 255, 0.2);
  --chat-text-primary: #f7fafc;
  --chat-text-secondary: #cbd5e0;
  --chat-text-muted: #a0aec0;
  --chat-accent: hsl(180, 100%, 50%);
  --chat-tech: hsl(110, 100%, 50%);
}

/* Chat Widget Container */
#chat-widget-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 10000;
  font-family: 'Inter', 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace;
}

/* Enhanced Chat Open Button */
#open-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-secondary));
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 
    0 8px 25px rgba(0, 0, 0, 0.15),
    0 4px 10px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  position: relative;
  overflow: hidden;
  color: white;
  font-size: 1.5rem;
  font-weight: 600;
}

#open-chat.enhanced {
  position: relative;
}

#open-chat.enhanced::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(
    from 0deg,
    transparent,
    var(--chat-accent),
    transparent,
    var(--chat-tech),
    transparent
  );
  animation: rotate 3s linear infinite;
  z-index: -1;
}

#open-chat.enhanced::after {
  content: '';
  position: absolute;
  inset: 2px;
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-secondary));
  border-radius: 50%;
  z-index: -1;
}

.pulse-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  border: 2px solid var(--chat-accent);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: pulse-ring 2s ease-out infinite;
}

@keyframes rotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes pulse-ring {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.8);
    opacity: 0;
  }
}

#open-chat:hover {
  transform: scale(1.1) rotate(5deg);
  box-shadow: 
    0 12px 35px rgba(0, 0, 0, 0.25),
    0 6px 15px rgba(0, 0, 0, 0.15),
    0 0 30px var(--chat-accent);
}

/* Enhanced Chat Window */
.chat-window {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 420px;
  max-width: calc(100vw - 2rem);
  height: 600px;
  max-height: calc(100vh - 4rem);
  background: var(--chat-bg-dark);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--chat-border);
  border-radius: 1.5rem;
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.3),
    0 8px 25px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideInUp 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  z-index: 10001;
  color: var(--chat-text-primary);
}

.chat-window.enhanced {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* Enhanced Chat Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-secondary));
  color: white;
  border-radius: 1.5rem 1.5rem 0 0;
  position: relative;
  overflow: hidden;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-info {
  display: flex;
  flex-direction: column;
}

.bot-name {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1;
}

.bot-status {
  font-size: 0.75rem;
  opacity: 0.9;
  font-weight: 500;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-controls button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.header-controls button:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

/* Enhanced Chat Messages */
.chat-messages {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  background: linear-gradient(
    135deg,
    rgba(26, 32, 44, 0.4) 0%,
    rgba(45, 55, 72, 0.2) 100%
  );
  position: relative;
}

.chat-messages.enhanced {
  gap: 1rem;
  display: flex;
  flex-direction: column;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Enhanced Message Styling */
.chat-message {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  position: relative;
  animation: messageSlideIn 0.3s ease-out;
}

.chat-message.you-message {
  background: linear-gradient(135deg, var(--chat-primary), rgba(66, 153, 225, 0.8));
  color: white;
  margin-left: 2rem;
  border-bottom-right-radius: 0.25rem;
}

.chat-message.foci-message {
  background: var(--chat-bg-glass);
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin-right: 2rem;
  border-bottom-left-radius: 0.25rem;
}

.chat-message.system-message {
  background: rgba(var(--chat-tech), 0.1);
  border: 1px solid rgba(var(--chat-tech), 0.3);
  color: var(--chat-tech);
  text-align: center;
  font-size: 0.875rem;
  margin: 0.5rem 1rem;
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.message-header strong {
  font-weight: 700;
}

.timestamp {
  font-size: 0.75rem;
  opacity: 0.7;
  font-family: 'SF Mono', monospace;
}

.message-content {
  line-height: 1.5;
  font-size: 0.9rem;
}

/* Enhanced Typing Indicator */
.typing-indicator.advanced {
  padding: 1rem;
  margin-bottom: 1rem;
  background: var(--chat-bg-glass);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1rem;
  margin-right: 2rem;
}

.indicator-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--chat-text-secondary);
}

.dots {
  display: flex;
  gap: 0.25rem;
}

.dots::before,
.dots::after {
  content: '●';
  animation: typingDots 1.4s ease-in-out infinite;
}

.dots::before {
  animation-delay: 0s;
}

.dots::after {
  animation-delay: 0.2s;
  content: '●●';
}

.cursor {
  animation: blink 1s infinite;
  color: var(--chat-accent);
  font-weight: bold;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Enhanced Button Options */
.chat-btn-option.enhanced {
  display: block;
  width: 100%;
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, 
    rgba(66, 153, 225, 0.1), 
    rgba(147, 51, 234, 0.1)
  );
  border: 1px solid rgba(66, 153, 225, 0.3);
  border-radius: 1rem;
  color: var(--chat-text-primary);
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  position: relative;
  overflow: hidden;
}

.chat-btn-option.enhanced::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  transition: left 0.5s;
}

.chat-btn-option.enhanced:hover::before {
  left: 100%;
}

.chat-btn-option.enhanced:hover {
  background: linear-gradient(135deg, 
    rgba(66, 153, 225, 0.2), 
    rgba(147, 51, 234, 0.2)
  );
  border-color: rgba(66, 153, 225, 0.5);
  transform: translateY(-2px);
  box-shadow: 
    0 8px 20px rgba(66, 153, 225, 0.15),
    0 4px 8px rgba(0, 0, 0, 0.1);
}

.suggestion-text {
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--chat-text-primary);
}

.suggestion-category {
  font-size: 0.75rem;
  color: var(--chat-accent);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* Enhanced Input Area */
.chat-input {
  display: flex;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--chat-border);
  gap: 0.75rem;
}

#chat-input-field {
  flex: 1;
  padding: 0.875rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 1rem;
  color: var(--chat-text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: all 0.3s ease;
  font-family: inherit;
}

#chat-input-field:focus {
  border-color: var(--chat-accent);
  box-shadow: 
    0 0 0 3px rgba(var(--chat-accent), 0.1),
    0 4px 12px rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.08);
}

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

#chat-send-btn {
  padding: 0.875rem 1.5rem;
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-secondary));
  border: none;
  border-radius: 1rem;
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.9rem;
  position: relative;
  overflow: hidden;
}

#chat-send-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

#chat-send-btn:hover::before {
  left: 100%;
}

#chat-send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(66, 153, 225, 0.3);
}

#chat-send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Enhanced Footer */
.chat-footer {
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.3);
  border-top: 1px solid var(--chat-border);
  font-size: 0.75rem;
  text-align: center;
}

.footer-info {
  color: var(--chat-text-muted);
}

.chat-footer a {
  color: var(--chat-accent);
  text-decoration: none;
  font-weight: 600;
}

.chat-footer a:hover {
  text-decoration: underline;
}

/* Advanced Animations */
@keyframes messageSlideIn {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes typingDots {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes slideInUp {
  0% {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Tech-Savvy Enhancements */
.chat-message.foci-message.typing .message-content {
  background: linear-gradient(
    -45deg,
    transparent 40%,
    rgba(var(--chat-tech), 0.1) 50%,
    transparent 60%
  );
  background-size: 200% 200%;
  animation: shimmer 2s ease-in-out infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 200%; }
  100% { background-position: -200% -200%; }
}

/* Code Syntax Highlighting */
.chat-message code {
  background: rgba(0, 0, 0, 0.3);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-family: 'SF Mono', 'Monaco', 'Cascadia Code', monospace;
  color: var(--chat-tech);
  font-size: 0.85em;
}

.chat-message pre {
  background: rgba(0, 0, 0, 0.4);
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 0.5rem 0;
  border-left: 4px solid var(--chat-tech);
}

/* Link Enhancements */
.chat-contact-link {
  color: var(--chat-accent) !important;
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px dotted var(--chat-accent);
  transition: all 0.2s ease;
}

.chat-contact-link:hover {
  color: white !important;
  background: var(--chat-accent);
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
  border-bottom: none;
}

/* Responsive Design */
@media (max-width: 480px) {
  #chat-widget-container {
    bottom: 1rem;
    right: 1rem;
  }
  
  .chat-window {
    width: calc(100vw - 2rem);
    height: calc(100vh - 2rem);
    bottom: 1rem;
    right: 1rem;
    border-radius: 1rem;
  }
  
  #open-chat {
    width: 56px;
    height: 56px;
  }
  
  .chat-header {
    padding: 0.875rem 1rem;
  }
  
  .chat-input {
    padding: 0.875rem;
  }
  
  #chat-input-field {
    font-size: 1rem; /* Prevent zoom on iOS */
  }
  
  #chat-send-btn {
    padding: 0.875rem 1.25rem;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-contrast: high) {
  .chat-window {
    border: 2px solid white;
    background: black;
  }
  
  .chat-header {
    background: white;
    color: black;
  }
  
  #chat-input-field {
    border: 2px solid white;
    background: black;
  }
}

/* Focus Management */
.chat-window:focus-within {
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.3),
    0 8px 25px rgba(0, 0, 0, 0.2),
    0 0 0 3px rgba(var(--chat-accent), 0.3);
}

/* Performance Optimizations */
.chat-messages {
  contain: layout style paint;
}

.chat-message {
  contain: layout style paint;
  will-change: transform, opacity;
}

/* Dark Mode Enhancements */
@media (prefers-color-scheme: dark) {
  :root {
    --chat-bg-dark: rgba(17, 24, 39, 0.98);
    --chat-bg-glass: rgba(31, 41, 55, 0.85);
  }
}

/* High DPI Display Support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .chat-header-icon,
  .chat-icon {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* Print Styles */
@media print {
  #chat-widget-container {
    display: none;
  }
}