/* AI Assistant Chat Widget Styles */
/* Simplified version without CSS variables for daily_paper */

.ai-assistant {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family: Arial, sans-serif;
}

/* Chat Toggle Button */
.ai-assistant__toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a73e8 0%, #667eea 100%);
  border: none;
  color: white;
  font-size: 28px;
  cursor: grab;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.ai-assistant__toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.ai-assistant__toggle:active {
  cursor: grabbing;
}

.ai-assistant__toggle--active {
  background: #333;
}

/* Chat Window */
.ai-assistant__window {
  position: fixed;
  width: min(380px, 90vw);
  height: min(500px, 70vh);
  min-width: 280px;
  min-height: 300px;
  max-width: 90vw;
  max-height: 70vh;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #ddd;
  overscroll-behavior: contain;
}

.ai-assistant__window--open {
  display: flex;
  animation: slideUp 0.3s ease-out;
}

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

/* Chat Header */
.ai-assistant__header {
  flex: 0 0 auto;
  padding: 16px;
  background: linear-gradient(135deg, #1a73e8 0%, #667eea 100%);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.ai-assistant__title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-assistant__status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  animation: pulse 2s infinite;
}

.ai-assistant__status--offline {
  background: #ef4444;
  animation: none;
}

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

.ai-assistant__header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-assistant__new-session {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.3s;
  white-space: nowrap;
}

.ai-assistant__new-session:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
}

.ai-assistant__close {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.3s;
}

.ai-assistant__close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Chat Messages */
.ai-assistant__messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  background: #f5f5f5;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overscroll-behavior: contain;
}

.ai-message {
  display: flex;
  gap: 8px;
  animation: fadeIn 0.3s ease-out;
}

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

.ai-message--user {
  flex-direction: row-reverse;
}

.ai-message__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}

.ai-message--assistant .ai-message__avatar {
  background: linear-gradient(135deg, #1a73e8 0%, #667eea 100%);
  color: white;
}

.ai-message--user .ai-message__avatar {
  background: #ddd;
  color: #333;
}

.ai-message__content {
  max-width: 70%;
  padding: 8px 12px;
  border-radius: 12px;
  line-height: 1.5;
  font-size: 14px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
}

.ai-message--assistant .ai-message__content {
  background: white;
  color: #333;
  border-bottom-left-radius: 4px;
}

.ai-message--user .ai-message__content {
  background: #1a73e8;
  color: white;
  border-bottom-right-radius: 4px;
}

/* Context badge for user messages */
.ai-message__context-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.05);
  order: 10;
}

.ai-message--has-context.ai-message--user {
  gap: 0;
}

.ai-message--has-context.ai-message--user .ai-message__avatar {
  margin-left: 8px;
}

.ai-message--has-context.ai-message--user .ai-message__content {
  margin-left: 2px;
}

/* Markdown formatting */
.ai-message__content strong {
  font-weight: 600;
}

.ai-message__content em {
  font-style: italic;
}

.ai-message__content code {
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 0.9em;
}

.ai-message__content a {
  color: #1a73e8;
  text-decoration: underline;
}

.ai-message__content a:hover {
  color: #667eea;
}

.ai-message__content ol,
.ai-message__content ul {
  margin: 8px 0;
  padding-left: 20px;
}

.ai-message__content li {
  margin: 4px 0;
}

.ai-message__content h1,
.ai-message__content h2,
.ai-message__content h3 {
  margin: 12px 0 8px 0;
  font-weight: 600;
}

/* Typing Indicator */
.ai-message__typing {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
}

.ai-message__typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #999;
  animation: typing 1.4s infinite;
}

.ai-message__typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.ai-message__typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-10px);
  }
}

/* Chat Input */
.ai-assistant__input-container {
  flex: 0 0 auto;
  padding: 16px;
  background: white;
  border-top: 1px solid #ddd;
  display: flex;
  gap: 8px;
  position: relative;
}

.ai-assistant__input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 8px;
  transition: border-color 0.3s;
}

.ai-assistant__input-wrapper:focus-within {
  border-color: #1a73e8;
}

.ai-context-tag-display {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.ai-assistant__input {
  flex: 1;
  padding: 4px 8px;
  border: none;
  font-size: 14px;
  font-family: Arial, sans-serif;
  min-height: 32px;
  max-height: 100px;
  overflow-y: auto;
  overflow-x: hidden;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.ai-assistant__input:focus {
  outline: none;
}

.ai-assistant__input:empty:before {
  content: attr(data-placeholder);
  color: #999;
  opacity: 0.6;
  pointer-events: none;
}

.ai-assistant__input[contenteditable="false"] {
  background: #f5f5f5;
  cursor: not-allowed;
  opacity: 0.6;
}

.ai-assistant__send {
  padding: 8px 16px;
  background: #1a73e8;
  color: white;
  border: none;
  border-radius: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-assistant__send:hover:not(:disabled) {
  background: #667eea;
  transform: translateY(-1px);
}

.ai-assistant__send:disabled {
  background: #ddd;
  cursor: not-allowed;
  transform: none;
}

/* Resize Handles */
.ai-assistant__resize-handle {
  position: absolute;
  z-index: 10;
  user-select: none;
  display: none;
}

.ai-assistant__resize-handle--active {
  display: block;
}

.ai-assistant__resize-handle--nw {
  top: 0;
  left: 0;
  width: 20px;
  height: 20px;
  cursor: nw-resize;
}

.ai-assistant__resize-handle--ne {
  top: 0;
  right: 0;
  width: 20px;
  height: 20px;
  cursor: ne-resize;
}

.ai-assistant__resize-handle--sw {
  bottom: 0;
  left: 0;
  width: 20px;
  height: 20px;
  cursor: sw-resize;
}

.ai-assistant__resize-handle--se {
  bottom: 0;
  right: 0;
  width: 20px;
  height: 20px;
  cursor: se-resize;
}

.ai-assistant__resize-handle--nw::after,
.ai-assistant__resize-handle--ne::after,
.ai-assistant__resize-handle--sw::after,
.ai-assistant__resize-handle--se::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  background: rgba(26, 115, 232, 0.3);
  border: 1px solid rgba(26, 115, 232, 0.5);
  border-radius: 2px;
}

.ai-assistant__resize-handle--nw::after {
  top: 4px;
  left: 4px;
}

.ai-assistant__resize-handle--ne::after {
  top: 4px;
  right: 4px;
}

.ai-assistant__resize-handle--sw::after {
  bottom: 4px;
  left: 4px;
}

.ai-assistant__resize-handle--se::after {
  bottom: 4px;
  right: 4px;
}

/* Mention Dropdown */
.ai-mention-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  width: 100%;
  max-height: 200px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.15);
  overflow-y: auto;
  z-index: 1000;
  margin-bottom: 4px;
}

.ai-mention-dropdown__title {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: linear-gradient(to bottom, rgba(26, 115, 232, 0.03), transparent);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  position: sticky;
  top: 0;
  z-index: 1;
}

.ai-mention-dropdown__option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.ai-mention-dropdown__option:last-child {
  border-bottom: none;
}

.ai-mention-dropdown__option:hover {
  background: linear-gradient(to right, rgba(26, 115, 232, 0.08), rgba(26, 115, 232, 0.04));
}

.ai-mention-dropdown__option--highlighted {
  background: linear-gradient(to right, rgba(26, 115, 232, 0.12), rgba(26, 115, 232, 0.06));
  border-left: 3px solid #1a73e8;
  padding-left: 9px;
}

.ai-mention-dropdown__icon {
  font-size: 20px;
  flex-shrink: 0;
}

.ai-mention-dropdown__label {
  font-size: 14px;
  color: #333;
  font-weight: 500;
}

/* Context tag styles */
.ai-context-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  user-select: none;
  margin: 0 2px;
  white-space: nowrap;
}

.ai-context-tag--paper {
  background-color: rgba(70, 130, 180, 0.2);
  color: #3a6b9e;
  border: 1px solid rgba(70, 130, 180, 0.4);
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .ai-assistant {
    bottom: 12px;
    right: 12px;
  }

  .ai-assistant__window {
    width: min(calc(100vw - 24px), 90vw);
    height: min(400px, 70vh);
  }

  .ai-assistant__toggle {
    width: 50px;
    height: 50px;
    font-size: 24px;
  }
}
