/* CSS Custom Properties for Theme Colors */
:root {
  --cwc-primary-color: #128000;
  --cwc-primary-hover: #0e6600;
  --cwc-primary-light: rgba(18, 128, 0, 0.2);
  --cwc-primary-light-bg: rgba(18, 128, 0, 0.05);
  --cwc-primary-link: #106a00;
}

/* Light Green Theme Variables */
.cwc-theme-light-green {
  --cwc-primary-color: #28a745;
  --cwc-primary-hover: #218838;
  --cwc-primary-light: rgba(40, 167, 69, 0.2);
  --cwc-primary-light-bg: rgba(40, 167, 69, 0.05);
  --cwc-primary-link: #1e7e34;
}

/* Red Theme Variables */
.cwc-theme-red {
  --cwc-primary-color: #8d0f15;
  --cwc-primary-hover: #6b0b10;
  --cwc-primary-light: rgba(141, 15, 21, 0.2);
  --cwc-primary-light-bg: rgba(141, 15, 21, 0.05);
  --cwc-primary-link: #6b0b10;
}

/* Chat Widget Container */
.cwc-chat-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

/* Chat Button */
.cwc-chat-button {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: var(--cwc-primary-color);
  color: white;
  border: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.cwc-chat-button:hover {
  transform: scale(1.05);
  background-color: var(--cwc-primary-color);
}

/* Chat Container */
.cwc-chat-container {
  width: 350px;
  height: 500px;
  background-color: white;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
  border: 1px solid #e0e0e0;
  border-bottom-left-radius: 4px;
  z-index: 10000;
}

/* Chat Header */
.cwc-chat-header {
  padding: 12px 15px;
  background-color: var(--cwc-primary-color);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cwc-header-title {
  font-size: 16px;
  font-weight: 500;
  margin: 0;
  text-align: center;
  flex: 1;
}

.cwc-close-btn {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

/* Form/Chat Toggle Button */
.cwc-form-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  cursor: pointer;
  padding: 8px 12px;
  line-height: 1;
  border-radius: 4px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
}

.cwc-btn-text {
  display: inline-block;
  white-space: nowrap;
}

.cwc-form-btn:hover {
  background-color: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

.cwc-form-btn:active {
  transform: scale(0.98);
}

.cwc-form-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.cwc-form-btn svg {
  vertical-align: middle;
  transition: transform 0.2s;
}

/* Animate icon on hover */
.cwc-form-btn:hover:not(:disabled) svg {
  transform: scale(1.1);
}

/* Form Container */
.cwc-form-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  flex: 1; /* Take up remaining space */
  overflow: hidden; /* Prevent container overflow */
}

/* Move Form Styling */
.cwc-move-form {
  flex: 1;
  padding: 20px 15px 15px; /* Adjust padding */
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: #f9f9f9;
  position: relative; /* Add positioning context */
  min-height: 400px; /* Ensure minimum height */
}

.cwc-form-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 10px;
}

.cwc-form-group label {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 5px;
  color: #333;
}

.cwc-required {
  color: #d32f2f;
  margin-left: 2px;
}

.cwc-date-format {
  font-size: 12px;
  color: #777;
  font-style: italic;
  margin-left: 5px;
  font-weight: normal;
}

.cwc-form-group input,
.cwc-form-group select {
  height: 38px;
  padding: 8px 12px;
  border: 1px solid #cfd8dc;
  border-radius: 4px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.cwc-form-group input:focus,
.cwc-form-group select:focus {
  border-color: var(--cwc-primary-color);
  outline: none;
  box-shadow: 0 0 0 2px var(--cwc-primary-light);
}

.cwc-input-error {
  border-color: #d32f2f !important;
}

.cwc-error-text {
  color: #d32f2f;
  font-size: 12px;
  margin-top: 3px;
}

/* Main submit button at bottom of form */
.cwc-submit-btn {
  margin-top: 25px;
  margin-bottom: 10px;
  background-color: var(--cwc-primary-color);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  align-self: center;
  width: calc(100% - 30px); /* Account for padding */
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  position: sticky; /* Make button sticky */
  bottom: 10px; /* Position at bottom */
  z-index: 5; /* Ensure button appears above other content */
  display: block !important; /* Force display */
}

.cwc-submit-btn:hover {
  background-color: var(--cwc-primary-hover);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  transform: none;
}

.cwc-submit-btn:active {
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
}


/* Move Size Select */
.cwc-move-size-select {
  width: 100%;
  box-sizing: border-box;
  height: 38px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 24 24%27 fill=%27none%27 stroke=%27%23777%27 stroke-width=%272%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27%3e%3cpolyline points=%276 9 12 15 18 9%27%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  padding-right: 30px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  text-indent: 4px; /* Adds a little space from the left edge */
}

.cwc-move-size-select:focus {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 24 24%27 fill=%27none%27 stroke=%27%23128000%27 stroke-width=%272%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27%3e%3cpolyline points=%276 9 12 15 18 9%27%3e%3c/polyline%3e%3c/svg%3e");
}

.cwc-theme-light-green .cwc-move-size-select:focus {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 24 24%27 fill=%27none%27 stroke=%27%2328a745%27 stroke-width=%272%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27%3e%3cpolyline points=%276 9 12 15 18 9%27%3e%3c/polyline%3e%3c/svg%3e");
}

.cwc-theme-red .cwc-move-size-select:focus {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 24 24%27 fill=%27none%27 stroke=%27%238d0f15%27 stroke-width=%272%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27%3e%3cpolyline points=%276 9 12 15 18 9%27%3e%3c/polyline%3e%3c/svg%3e");
}

/* Chat Messages */
.cwc-chat-messages {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background-color: white;
}

.cwc-message {
  padding: 10px 15px;
  border-radius: 18px;
  max-width: 80%;
  word-wrap: break-word;
}

.cwc-user-message {
  align-self: flex-end;
  background-color: var(--cwc-primary-color);
  color: white;
  border-bottom-right-radius: 4px;
  font-size: 13px;
}

.cwc-ai-message {
  align-self: flex-start;
  background-color: #f7f7f7;
  color: #333;
  border-bottom-left-radius: 4px;
  font-size: 15px !important;
  line-height: 1.5;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  max-width: 85%; /* Slightly wider */
}

/* Make sure images don't overflow */
.cwc-ai-message img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 0.5em 0;
}

/* Enhanced Markdown styling for AI messages */
.cwc-ai-message h1 { 
  font-size: 1.5em; 
  margin: 0.7em 0 0.5em;
  border-bottom: 1px solid #eaeaea; 
  padding-bottom: 0.3em;
  font-weight: 600;
}

.cwc-ai-message h2 { 
  font-size: 1.3em; 
  margin: 0.7em 0 0.5em; 
  font-weight: 600;
}

.cwc-ai-message h3 { 
  font-size: 1.1em; 
  margin: 0.7em 0 0.5em; 
  font-weight: 600;
}

.cwc-ai-message p { 
  font-size: 15px !important; 
  margin: 0.8em 0; 
  line-height: 1.5;
  white-space: pre-line; /* Preserve line breaks */
}

.cwc-ai-message a { 
  color: var(--cwc-primary-link); 
  text-decoration: none; 
  border-bottom: 1px dotted var(--cwc-primary-link);
  transition: all 0.2s ease;
}

.cwc-ai-message a:hover { 
  text-decoration: none;
  border-bottom: 1px solid var(--cwc-primary-link);
  background-color: var(--cwc-primary-light-bg);
}

/* Improved code styling */
.cwc-ai-message .cwc-inline-code {
  background-color: rgba(0, 0, 0, 0.04);
  padding: 2px 5px;
  border-radius: 3px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  color: #333;
}

.cwc-ai-message code {
  background-color: rgba(0, 0, 0, 0.04);
  padding: 2px 5px;
  border-radius: 3px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  color: #333;
}

.cwc-ai-message pre {
  background-color: #f6f8fa;
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  border: 1px solid #e8e8e8;
  margin: 0.8em 0;
}

.cwc-ai-message pre code {
  background-color: transparent;
  padding: 0;
  font-size: 13px;
  color: #333;
  display: block;
  line-height: 1.45;
}

/* Improve lists */
.cwc-ai-message ul, 
.cwc-ai-message ol {
  margin: 0.8em 0 0.8em 0.8em;
  padding-left: 1.5em;
}

.cwc-ai-message li {
  margin: 0.4em 0;
  font-size: 15px;
}

.cwc-ai-message ul li {
  list-style-type: disc;
}

.cwc-ai-message ol li {
  list-style-type: decimal;
}

/* Better blockquote styling */
.cwc-ai-message blockquote {
  border-left: 4px solid #dfe2e5;
  color: #5a5a5a;
  margin: 0.8em 0;
  padding: 0 0 0 1em;
  font-size: 15px;
}

/* Table improvements */
.cwc-ai-message table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
  overflow-x: auto;
  display: block;
  border: 1px solid #dfe2e5;
}

.cwc-ai-message th {
  background-color: #f6f8fa;
  font-weight: 600;
  text-align: left;
}

.cwc-ai-message th,
.cwc-ai-message td {
  border: 1px solid #dfe2e5;
  padding: 8px 12px;
  font-size: 14px;
}

.cwc-ai-message tr:nth-child(even) {
  background-color: #f8f8f8;
}

/* Horizontal rule */
.cwc-ai-message hr {
  height: 1px;
  background-color: #eaecef;
  border: none;
  margin: 1.5em 0;
}

/* Checkbox styling */
.cwc-ai-message input[type="checkbox"] {
  margin-right: 6px;
  vertical-align: middle;
  cursor: default;
}

/* Cursor Animation for Streaming Text */
.cwc-cursor {
  display: inline-block;
  width: 6px;
  height: 16px;
  background-color: #333;
  margin-left: 2px;
  vertical-align: middle;
  animation: blink 1s infinite;
}

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

/* Typing Indicator */
.cwc-typing-indicator {
  display: flex;
  align-items: center;
  align-self: flex-start;
  background-color: white;
  border-radius: 18px;
  padding: 10px 15px;
  margin-bottom: 10px;
}

/* Cleaner, minimalist typing dots */
.cwc-typing-dot {
  width: 6px;
  height: 6px;
  margin: 0 3px;
  border-radius: 50%;
  background-color: #999;
  opacity: 0.4;
  display: inline-block;
  animation: cwc-dotPulse 1s infinite ease-in-out;
}

.cwc-typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.cwc-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

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

/* Chat Input */
.cwc-chat-input {
  display: flex;
  padding: 8px;
  border-top: 1px solid #e0e0e0;
  background-color: #fff;
  align-items: flex-end; /* Align items to the bottom */
}

.cwc-chat-input textarea {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 18px;
  font-size: 14px;
  resize: none;
  max-height: 80px; /* Maximum height (approximately 3 lines) */
  min-height: 40px; /* Minimum height (1 line) */
  overflow-y: hidden; /* Hide scrollbar initially */
  line-height: 1.4;
  margin-right: 8px;
  transition: height 0.1s ease;
}

.cwc-chat-input textarea:focus {
  outline: none;
  border-color: var(--cwc-primary-color);
}

.cwc-chat-input button {
  background-color: var(--cwc-primary-color);
  color: white;
  border: none;
  border-radius: 18px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  height: 40px; /* Match the initial height of textarea */
  align-self: flex-end; /* Align to bottom */
}

.cwc-chat-input button:hover {
  background-color: var(--cwc-primary-hover);
}

.cwc-chat-input button:disabled {
  background-color: #cccccc;
  cursor: not-allowed;
}

/* Error Message */
.cwc-error-message {
  background-color: #ffeeee;
  color: #d32f2f;
  padding: 10px;
  margin: 5px;
  border-radius: 5px;
  font-size: 14px;
  text-align: center;
}

/* NEW: Inbox Button */
.cwc-inbox-button {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 10000; /* Ensure it's above other widget elements */
  background-color: var(--cwc-primary-color); /* Match theme color */
  color: white;
  border: none;
  border-radius: 50px; /* Pill shape */
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: inherit; /* Inherit from widget */
}

.cwc-inbox-button:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  background-color: var(--cwc-primary-hover); /* Darker shade on hover */
}

.cwc-inbox-button:active {
  transform: translateY(0) scale(1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Chat Icon */
.cwc-inbox-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Notification Bubble */
.cwc-notification-bubble {
  position: absolute;
  top: -8px;
  right: -8px;
  background-color: #ff3b30;
  color: white;
  font-size: 12px;
  font-weight: bold;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  padding: 0 5px;
}

.cwc-inbox-text {
  line-height: 1.2;
}

/* NEW: System Message Style */
.cwc-system-message {
  align-self: center; /* Center system messages */
  background-color: #f0f0f0; /* Neutral background */
  color: #555; /* Muted text color */
  border-radius: 4px; /* Less rounded */
  font-size: 13px;
  font-style: italic;
  text-align: center;
  width: auto; /* Adjust width to content */
  max-width: 90%; /* Prevent it from being too wide */
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .cwc-chat-container {
    width: 300px;
    height: 450px;
  }
  
  .cwc-form-group label {
    font-size: 13px;
  }
  
  .cwc-form-group input,
  .cwc-form-group select {
    font-size: 13px;
    height: 36px;
  }
  
  /* Adjust inbox button for smaller screens */
  .cwc-inbox-button {
    padding: 10px 15px;
    font-size: 14px;
    gap: 8px;
    right: 15px;
    bottom: 15px;
  }
  
  .cwc-inbox-icon {
    width: 20px;
    height: 20px;
  }
  
  /* Adjust form styling for mobile */
  .cwc-move-form {
    padding: 12px;
    gap: 10px;
  }
  
  .cwc-form-actions button {
    padding: 8px 16px;
    font-size: 13px;
  }
  
  /* Make button text smaller on mobile */
  .cwc-form-btn {
    padding: 6px 8px;
    font-size: 12px;
    gap: 5px;
  }
  
  .cwc-form-btn svg {
    width: 16px;
    height: 16px;
  }
}

.cwc-move-size-select {
  width: 100%; /* Or adjust as needed */
  box-sizing: border-box; /* Include padding and border in the element's total width and height */
}

/* Additional strong selector to ensure AI message font sizing */
.cwc-chat-widget .cwc-ai-message,
.cwc-chat-widget .cwc-ai-message p {
  font-size: 15px !important;
  line-height: 1.5;
} 
