/* K1 Speed Chat Widget Styles */
/* Save this as: k1-chat-styles.css */

/* Import the default n8n chat styles */
@import url('https://cdn.jsdelivr.net/npm/@n8n/chat/dist/style.css');

/* Custom CSS to style the n8n chat widget */
body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Ensure chat widget container is positioned correctly */
.n8n-chat,
.chat-window-wrapper {
    position: fixed !important;
    bottom: 80px !important;
    right: 20px !important;
    z-index: 9999 !important;
}

/* Override n8n chat CSS variables with K1 Speed branding */
:root {
    /* Primary Colors - K1 Red */
    --chat--color-primary: #E31837;
    --chat--color-primary-shade-50: #FF4D4D;
    --chat--color-primary-shade-100: #C71432;
    
    /* Secondary Colors */
    --chat--color-secondary: #E31837;
    --chat--color-secondary-shade-50: #FF4D4D;
    
    /* Base Colors */
    --chat--color-white: #FFFFFF;
    --chat--color-light: #F5F5F5;
    --chat--color-light-shade-50: #EBEBEB;
    --chat--color-light-shade-100: #E0E0E0;
    --chat--color-medium: #6B6B6B;
    --chat--color-dark: #2C2C2C;
    --chat--color-disabled: #CCCCCC;
    --chat--color-typing: #6B6B6B;
    
    /* Spacing and Layout */
    --chat--spacing: 1rem;
    --chat--border-radius: 12px;
    --chat--transition-duration: 0.3s;
    
    /* Window Size */
    --chat--window--width: 400px;
    --chat--window--height: 600px;
    
    /* Header Styles */
    --chat--header-height: 60px;
    --chat--header--padding: 16px 20px;
    --chat--header--background: #E31837;
    --chat--header--color: #FFFFFF;
    --chat--header--border-top: none;
    --chat--header--border-bottom: none;
    --chat--heading--font-size: 1.25rem;
    --chat--subtitle--font-size: 0.875rem;
    --chat--subtitle--line-height: 1.4;
    
    /* Message Styles */
    --chat--message--font-size: 0.9375rem;
    --chat--message--padding: 12px 16px;
    --chat--message--border-radius: 12px;
    --chat--message-line-height: 1.5;
    
    /* Bot Message */
    --chat--message--bot--background: #EFEFEF;
    --chat--message--bot--color: #2C2C2C;
    --chat--message--bot--border: none;
    
    /* User Message */
    --chat--message--user--background: #E31837;
    --chat--message--user--color: #FFFFFF;
    --chat--message--user--border: none;
    
    /* Code blocks in messages */
    --chat--message--pre--background: rgba(0, 0, 0, 0.05);
    
    /* Toggle Button (Chat Button) */
    --chat--toggle--background: #FFFFFF;
    --chat--toggle--hover--background: #F5F5F5;
    --chat--toggle--active--background: #EBEBEB;
    --chat--toggle--color: #E31837;
    --chat--toggle--size: 64px;
    
    /* Input Area */
    --chat--textarea--height: 50px;
}

/* ===== CHAT WINDOW ===== */
.chat-window {
    border-radius: 12px !important;
    overflow: hidden !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15) !important;
    width: 450px !important;
    height: 80vh !important;
}

/* Mobile: Fullscreen chat window when open */
@media (max-width: 768px) {
    .chat-window {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }
}

/* ===== HEADER ===== */
/* Compact header layout with logo and title side by side */
.chat-header {
  background: linear-gradient(135deg, #E31837 0%, #C71432 100%) !important;
  border-radius: 12px 12px 0 0 !important;
  padding: 8px 16px !important; /* reduced padding for compactness */
  display: flex !important;
  align-items: center !important; /* vertically center all items */
  gap: 8px !important; /* space between logo and text */
  min-height: 40px !important; /* minimal header height */
}

/* Mobile: No top border radius for fullscreen and add close button */
@media (max-width: 768px) {
    .chat-header {
        border-radius: 0 !important;
        padding: 12px 56px 12px 16px !important;
        min-height: 50px !important;
        position: relative !important;
    }
    
    /* Add close button on mobile */
    .chat-header::after {
        content: "✕" !important;
        position: absolute !important;
        right: 12px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        width: 36px !important;
        height: 36px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        color: #FFFFFF !important;
        font-size: 24px !important;
        font-weight: 300 !important;
        cursor: pointer !important;
        border-radius: 50% !important;
        transition: background-color 0.2s ease !important;
        background-color: rgba(255, 255, 255, 0.15) !important;
        z-index: 10 !important;
    }
}

/* Logo as a pseudo-element on the left */
.chat-header::before {
  content: '';
  width: 32px;
  height: 32px;
  background-color: #fff;
  border-radius: 6px;
  background-image: url('https://cm4-production-assets.s3.amazonaws.com/1750609599151-k1speed-logo.webp');
  background-size: 24px 24px;
  background-repeat: no-repeat;
  background-position: center;
  flex-shrink: 0; /* prevent shrinking */
  display: block;
}

/* Container to keep header text vertical and aligned to the left */
.chat-header > * {
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin: 0; /* Remove default margins for compactness */
}

/* Main header title styling */
.chat-header h1 {
  font-size: 1rem !important; /* fits well in the minimal header */
  font-weight: 600 !important;
  color: #FFFFFF !important;
  margin: 0 !important;
  white-space: nowrap; /* prevent wrapping next to logo */
  line-height: 1.1;
}

/* Subtitle hidden for minimal header */
/* Remove 'display:none' if subtitle is desired */
.chat-header p {
  display: none;
}
    

/* ===== MESSAGES ===== */
.chat-body {
    background-color: #FFFFFF !important;
    padding: 16px !important;
    overflow-y: auto !important;
    flex: 1 !important;
}

/* Mobile: Adjust padding and ensure proper scrolling */
@media (max-width: 768px) {
    .chat-body {
        padding: 12px !important;
        height: calc(100vh - 50px - 80px) !important; /* subtract header and footer */
    }
}

.chat-messages-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
}

/* Bot messages */
.chat-message-from-bot {
    background-color: #EFEFEF !important;
    color: #2C2C2C !important;
    border-radius: 16px 16px 16px 4px !important;
    padding: 12px 16px !important;
    max-width: 100% !important;
    align-self: flex-start !important;
    font-size: 0.9375rem !important;
    line-height: 1.5 !important;
    display: flex !important;
    align-items: flex-start !important;
    gap: 8px !important;
}

/* Add K1 icon to bot messages */
.chat-message-from-bot::before {
    content: '';
    width: 28px;
    height: 28px;
    min-width: 28px;
    background-color: transparent;
    border-radius: 4px;
    display: block;
    background-image: url('https://cm4-production-assets.s3.amazonaws.com/1750609599151-k1speed-logo.webp');
    background-size: 20px;
    background-repeat: no-repeat;
    background-position: center;
}

/* User messages */
.chat-message-from-user {
    background-color: #E31837 !important;
    color: #FFFFFF !important;
    border-radius: 16px 16px 4px 16px !important;
    padding: 12px 16px !important;
    max-width: 100% !important;
    align-self: flex-end !important;
    font-size: 0.9375rem !important;
    line-height: 1.5 !important;
}

/* Message content */
.chat-message-markdown,
.chat-message-markdown p {
    margin: 0 !important;
    line-height: 1.5 !important;
}

/* Make links clickable */
.chat-message a {
    color: inherit !important;
    text-decoration: underline !important;
    cursor: pointer !important;
    pointer-events: auto !important;
}

.chat-message-from-bot a {
    color: #E31837 !important;
    font-weight: 500 !important;
}

.chat-message-from-user a {
    color: #FFFFFF !important;
}

.chat-message a:hover {
    opacity: 0.8 !important;
}

/* Custom scrollbar */
.chat-body::-webkit-scrollbar {
    width: 6px !important;
}

.chat-body::-webkit-scrollbar-track {
    background: #F5F5F5 !important;
}

.chat-body::-webkit-scrollbar-thumb {
    background: #CCCCCC !important;
    border-radius: 3px !important;
}

.chat-body::-webkit-scrollbar-thumb:hover {
    background: #999999 !important;
}

/* ===== FOOTER / INPUT ===== */
.chat-footer {
    border-top: 1px solid #E0E0E0 !important;
    padding: 16px !important;
    background-color: #FFFFFF !important;
}

.custom-footer-text {
    text-align: center !important;
    font-size: 11px !important;
    color: #999999 !important;
    margin-top: 12px !important;
    padding-top: 8px !important;
    border-top: 1px solid #F0F0F0 !important;
}

.chat-input {
    position: relative !important;
}

.chat-inputs {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

/* Input textarea */
.chat-input textarea {
    border: 2px solid #E31837 !important;
    border-radius: 28px !important;
    padding: 12px 48px 12px 20px !important;
    font-size: 14px !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    resize: none !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

.chat-input textarea:focus {
    outline: none !important;
    border-color: #C71432 !important;
    box-shadow: 0 0 0 3px rgba(227, 24, 55, 0.1) !important;
}

.chat-input textarea::placeholder {
    color: #999999 !important;
}

/* Send button */
.chat-input-send-button {
    background-color: transparent !important;
    color: #2C2C2C !important;
    border: none !important;
    border-radius: 50% !important;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    position: absolute !important;
    right: 8px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
}

.chat-input-send-button:not(:disabled):hover {
    background-color: #F5F5F5 !important;
}

.chat-input-send-button:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}

.chat-input-send-button svg {
    fill: #2C2C2C !important;
    color: #2C2C2C !important;
    width: 20px !important;
    height: 20px !important;
}

/* ===== TOGGLE BUTTON (Floating Chat Button) ===== */

/* Hide the existing SVG icon */
.chat-window-toggle svg {
  display: none !important;
}

/* Style the toggle button container */
.chat-window-toggle {
  width: 180px !important;
  height: 64px !important;
  border-radius: 32px !important;
  background-color: #FFFFFF !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  padding: 0 20px 0 16px !important;
  gap: 12px !important;
  transition: all 0.3s ease !important;
}

.chat-window-toggle:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2) !important;
  transform: translateY(-2px) !important;
}

/* Add logo as a pseudo-element (closed state) */
.chat-window-toggle::before {
  content: "" !important;
  width: 32px !important;
  height: 32px !important;
  background-image: url('https://cm4-production-assets.s3.amazonaws.com/1750609599151-k1speed-logo.webp') !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  background-size: contain !important;
  flex-shrink: 0 !important;
  transition: all 0.3s ease !important;
}

/* Add text (closed state) */
.chat-window-toggle::after {
  content: "May I Help You?" !important;
  color: #2C2C2C !important;
  font-weight: 500 !important;
  font-size: 14px !important;
  white-space: nowrap !important;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
  transition: all 0.3s ease !important;
}

/* ===== OPEN STATE (Down Arrow) ===== */

/* When chat is open, change to smaller circular button */
.chat-window-toggle.chat-open {
  width: 56px !important;
  height: 56px !important;
  border-radius: 50% !important;
  padding: 0 !important;
  justify-content: center !important;
  background-color: #E31837 !important;
}

/* Hide logo when open */
.chat-window-toggle.chat-open::before {
  display: none !important;
}

/* Change text to down arrow when open */
.chat-window-toggle.chat-open::after {
  content: "▼" !important;
  color: #FFFFFF !important;
  font-size: 20px !important;
  font-weight: bold !important;
  margin: 0 !important;
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
    /* Hide toggle button on mobile when chat is open */
    .chat-window-toggle.chat-open {
        display: none !important;
    }
    
    /* Ensure messages are readable on mobile */
    .chat-message-from-bot,
    .chat-message-from-user {
        max-width: 100% !important;
        font-size: 15px !important;
    }
    
    /* Adjust input for mobile */
    .chat-input textarea {
        font-size: 16px !important; /* Prevents zoom on iOS */
    }
}

.proactive-message-bubble {
  position: absolute;
  bottom: 70px; /* adjust as needed to sit nicely above toggle */
  right: 0;
  background: #FFFFFF;
  border-radius: 12px;
  padding: 12px 20px;
  max-width: 260px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  font-size: 14px;
  color: #1F1F1F;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  font-weight: 400;
  white-space: normal;
  z-index: 10001;
  line-height: 1.5;
}

