/* Cogi Widget Styles - AI Chat Widget by Alpha Cogs */
/* Version: 1.0.1 */

#cogi-widget-container {
  position: fixed;
}

#cogi-widget-container * {
  font-family: inherit;
}

.cogi-widget-bottom-right {
  bottom: 20px;
  right: 20px;
}

.cogi-widget-bottom-left {
  bottom: 20px;
  left: 20px;
}

.cogi-widget-top-right {
  top: 20px;
  right: 20px;
}

.cogi-widget-top-left {
  top: 20px;
  left: 20px;
}

.cogi-toggle-btn {
  border-radius: 50%;
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
  position: relative;
  z-index: 1;
  overflow: hidden;
}

.cogi-toggle-btn img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.cogi-chat-window {
  display: flex;
  flex-direction: column;
  background: white;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
  overflow: visible;
  animation: slideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(10px);
  position: absolute;
  bottom: 90px;
  right: 0;
  z-index: 2;
}

@keyframes cogi-pulse-shadow {
  0%, 100% {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 0 var(--glow-color, rgba(200, 0, 125, 0.5));
  }
  50% {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 15px 5px var(--glow-color, rgba(200, 0, 125, 0));
  }
}

@keyframes cogi-subtle-glow {
  0%, 100% {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  }
  50% {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 25px var(--glow-color, rgba(211, 118, 127, 0.8)), 0 0 35px var(--glow-color, rgba(211, 118, 127, 0.4));
  }
}

@keyframes cogi-bounce-attention {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.cogi-toggle-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

/* Comic speech bubble tail - now using SVG */
.cogi-comic-style .cogi-speech-tail {
  display: block;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.cogi-chat-window:not(.cogi-comic-style) .cogi-speech-tail {
  display: none;
}

@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.cogi-chat-window.closing {
  animation: slideDownFade 0.3s cubic-bezier(0.4, 0, 1, 1) forwards;
}

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

.cogi-header {
  padding: 12px 16px;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 2;
  border-radius: inherit;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.cogi-header-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cogi-header-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.cogi-header-content h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.2;
}

.cogi-header-content p {
  margin: 2px 0 0 0;
  font-size: 14px;
  opacity: 0.85;
  line-height: 1.2;
}

.cogi-close-btn {
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s;
}

.cogi-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.cogi-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  background: #f8f9fa;
  position: relative;
  z-index: 2;
  min-height: 0;
  max-height: 100%;
}

.cogi-message {
  margin-bottom: 16px;
  display: flex;
}

.cogi-message-new {
  animation: messageSlideIn 0.3s ease-out;
}

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

.cogi-message-user {
  justify-content: flex-end;
}

.cogi-message-assistant {
  justify-content: flex-start;
}

.cogi-message-content {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 12px;
  line-height: 1.6;
  font-size: 14px;
}

/* Ensure all child elements inherit color from parent - protection against external CSS */
.cogi-message-content *,
.cogi-message-content p,
.cogi-message-content h1,
.cogi-message-content h2,
.cogi-message-content h3,
.cogi-message-content h4,
.cogi-message-content h5,
.cogi-message-content h6,
.cogi-message-content li,
.cogi-message-content span,
.cogi-message-content div,
.cogi-message-content strong,
.cogi-message-content em,
.cogi-message-content b,
.cogi-message-content i {
  color: inherit !important;
}

.cogi-message-content p {
  margin: 0 0 12px 0;
}

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

.cogi-message-content h1,
.cogi-message-content h2,
.cogi-message-content h3 {
  margin: 16px 0 8px 0;
  font-weight: 600;
  line-height: 1.3;
}

.cogi-message-content h1:first-child,
.cogi-message-content h2:first-child,
.cogi-message-content h3:first-child {
  margin-top: 0;
}

.cogi-message-content h1 { font-size: 18px; }
.cogi-message-content h2 { font-size: 16px; }
.cogi-message-content h3 { font-size: 15px; }

.cogi-message-content ul,
.cogi-message-content ol {
  margin: 8px 0;
  padding-left: 24px;
}

.cogi-message-content ol {
  list-style-type: decimal;
  list-style-position: outside;
}

.cogi-message-content ul {
  list-style-type: disc;
  list-style-position: outside;
}

.cogi-message-content li {
  margin: 4px 0;
  line-height: 1.5;
}

.cogi-message-content strong {
  font-weight: 600;
}

.cogi-message-content code {
  background: rgba(0, 0, 0, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
}

.cogi-message-content pre {
  background: rgba(0, 0, 0, 0.08);
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
}

.cogi-message-content pre code {
  background: none;
  padding: 0;
  font-size: 12px;
  line-height: 1.5;
}

.cogi-message-content a {
  color: inherit;
  text-decoration: underline;
  opacity: 0.9;
}

.cogi-message-content a:hover {
  opacity: 1;
}

.cogi-message-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
}

.cogi-message-content th,
.cogi-message-content td {
  padding: 8px 12px;
  text-align: left;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.cogi-message-content th {
  font-weight: 600;
  background: rgba(0, 0, 0, 0.05);
}

.cogi-message-content tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.02);
}

.cogi-message-assistant .cogi-message-content th {
  background: rgba(255, 255, 255, 0.15);
}

.cogi-message-assistant .cogi-message-content td {
  border-color: rgba(255, 255, 255, 0.2);
}

.cogi-message-assistant .cogi-message-content tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.05);
}

.cogi-message-user .cogi-message-content {
  border-bottom-right-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.cogi-message-assistant .cogi-message-content {
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.cogi-message-assistant .cogi-message-content code {
  background: rgba(255, 255, 255, 0.2);
}

.cogi-message-assistant .cogi-message-content pre {
  background: rgba(255, 255, 255, 0.15);
}

.cogi-input-container {
  display: flex;
  padding: 16px;
  background: white;
  border-top: 1px solid #e0e0e0;
  gap: 8px;
  position: relative;
  z-index: 2;
  border-radius: inherit;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  box-sizing: border-box;
}

.cogi-char-counter {
  position: absolute;
  bottom: 4px;
  right: 70px;
  font-size: 11px;
  color: #666;
  font-weight: 500;
  pointer-events: none;
  z-index: 10;
  background: white;
  padding: 2px 6px;
  border-radius: 4px;
}

.cogi-attach-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid #e0e0e0;
  background: white;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.cogi-attach-btn:hover {
  background: #f8f9fa;
  border-color: #0066cc;
  color: #0066cc;
}

.cogi-voice-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid #e0e0e0;
  background: white;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.cogi-voice-btn:hover {
  background: #f8f9fa;
  border-color: #0066cc;
  color: #0066cc;
}

.cogi-voice-btn.cogi-recording {
  background: #ff4444;
  border-color: #ff4444;
  color: white;
  animation: pulse-recording 1s ease-in-out infinite;
}

@keyframes pulse-recording {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

.cogi-speak-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: currentColor;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  transition: all 0.2s;
  vertical-align: middle;
}

.cogi-speak-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.cogi-file-preview {
  padding: 12px 16px;
  background: #f8f9fa;
  border-top: 1px solid #e0e0e0;
  position: relative;
  z-index: 2;
}

.cogi-file-preview-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  background: white;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
}

.cogi-file-preview-item span {
  flex: 1;
  font-size: 14px;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cogi-file-remove {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: #ff4444;
  color: white;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cogi-file-remove:hover {
  background: #cc0000;
}

.cogi-drag-over {
  background: #e3f2fd !important;
  border: 2px dashed #0066cc;
}

.cogi-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #e0e0e0;
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
  box-sizing: border-box;
  min-width: 0;
}

.cogi-input:focus {
  border-color: #0066cc;
}

.cogi-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.cogi-send-btn:hover {
  transform: scale(1.05);
}

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

/* Thinking animation */
.cogi-thinking {
  display: inline-block;
  color: inherit !important;
}

.cogi-thinking::after {
  content: '...';
  animation: thinking 1.5s infinite;
  color: inherit !important;
}

@keyframes thinking {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* Typing animation (bouncing balls) */
.cogi-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.cogi-typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: currentColor;
  animation: typing-bounce 1.4s infinite ease-in-out;
}

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

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

@keyframes typing-bounce {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  40% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* Mobile responsive */
@media (max-width: 768px) {
  #cogi-widget-container.cogi-mobile-active {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    z-index: 999999 !important;
  }
  
  #cogi-widget-container.cogi-mobile-active .cogi-toggle-btn {
    display: none !important;
  }
  
  #cogi-widget-container.cogi-mobile-active .cogi-speech-tail {
    display: none !important;
  }
  
  .cogi-chat-window.cogi-mobile-fullscreen {
    width: 100vw !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    max-height: 100dvh !important;
    bottom: 0 !important;
    right: 0 !important;
    left: 0 !important;
    top: 0 !important;
    position: fixed !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
  }
  
  .cogi-mobile-fullscreen .cogi-header {
    border-radius: 0 !important;
    box-sizing: border-box !important;
  }
  
  .cogi-mobile-fullscreen .cogi-input-container {
    border-radius: 0 !important;
    box-sizing: border-box !important;
    width: 100% !important;
    padding: 12px !important;
    gap: 6px !important;
  }
  
  .cogi-mobile-fullscreen .cogi-attach-btn,
  .cogi-mobile-fullscreen .cogi-voice-btn {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    flex-shrink: 0 !important;
  }
  
  .cogi-mobile-fullscreen .cogi-send-btn {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    flex-shrink: 0 !important;
  }
  
  .cogi-mobile-fullscreen .cogi-input {
    min-width: 0 !important;
    flex: 1 !important;
    padding: 10px 14px !important;
  }
  
  .cogi-mobile-fullscreen .cogi-messages {
    flex: 1 !important;
    min-height: 300px !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    box-sizing: border-box !important;
  }
}


.cogi-handsfree-btn {
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s;
}

.cogi-handsfree-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Validation Form Styles */
.cogi-validation-form {
  padding: 24px;
  background: white;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  z-index: 2;
  border-radius: inherit;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.cogi-welcome-message {
  text-align: center;
  margin-bottom: 8px;
}

.cogi-greeting {
  font-size: 20px;
  font-weight: 600;
  color: #1f294d;
  margin: 0 0 8px 0;
  line-height: 1.3;
}

.cogi-tagline {
  font-size: 14px;
  color: #666;
  margin: 0 0 16px 0;
  line-height: 1.4;
}

.cogi-instructions {
  font-size: 13px;
  color: #555;
  margin: 0 0 8px 0;
  line-height: 1.4;
}

.cogi-chat-invite {
  font-size: 13px;
  color: #555;
  margin: 0 0 16px 0;
  line-height: 1.4;
}

#cogi-email-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
  box-sizing: border-box;
}

#cogi-email-input:focus {
  border-color: #1f294d;
}

.cogi-start-chat-btn {
  width: 100%;
  padding: 12px 16px;
  background: #1f294d;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
}

.cogi-start-chat-btn:hover {
  background: #2a3a5f;
}

.cogi-start-chat-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.cogi-error-message {
  color: #dc3545;
  font-size: 13px;
  margin: 0;
  text-align: center;
}

.cogi-privacy-note {
  font-size: 11px;
  color: #888;
  text-align: center;
  margin: 8px 0 0 0;
  line-height: 1.3;
}

.cogi-privacy-note a {
  color: #1f294d;
  text-decoration: none;
}

.cogi-privacy-note a:hover {
  text-decoration: underline;
}

/* Tooltip Styles */
.cogi-tooltip {
  position: absolute;
  bottom: 80px;
  right: 0;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  white-space: nowrap;
  z-index: 1;
  animation: tooltipFade 0.3s ease-in-out;
}

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