/* Chat Interface Styles - Ultra Simplified Mobile First */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #fafafa;
  overflow: hidden;
  position: relative;
}

/* Ultra-Simple Header */
.chat-header {
  background: white;
  border-bottom: 1px solid #f0f0f0;
  padding: 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 100%;
  margin: 0;
}

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

.ai-avatar {
  width: 2rem;
  height: 2rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.header-left h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0;
}

/* Settings Button */
.settings-btn {
  width: 2.5rem;
  height: 2.5rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: #6b7280;
}

.settings-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #374151;
}

/* Header Buttons */
.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #f8fafc;
  color: #374151;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.new-chat-btn:hover {
  background: #f1f5f9;
  border-color: #d1d5db;
  transform: translateY(-1px);
}

.new-chat-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Messages - Pure Scrollable Area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  padding-bottom: 6rem; /* Account for fixed input height */
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
}

.message {
  display: flex;
  gap: 0.75rem;
  max-width: 85%;
}

.user-message {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.ai-message {
  align-self: flex-start;
}

.message-avatar {
  flex-shrink: 0;
}

.user-avatar {
  width: 2rem;
  height: 2rem;
  background: #3b82f6;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.75rem;
  font-weight: 500;
}

.message-content {
  background: white;
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  position: relative;
}

.user-message .message-content {
  background: #3b82f6;
  color: white;
  border-bottom-right-radius: 0.25rem;
}

.ai-message .message-content {
  border-bottom-left-radius: 0.25rem;
}

.message-content p {
  margin: 0 0 0.5rem 0;
  line-height: 1.5;
}

.timestamp {
  font-size: 0.75rem;
  color: #9ca3af;
  display: block;
}

.user-message .timestamp {
  color: rgba(255, 255, 255, 0.8);
}

/* Book Suggestions */
.book-suggestions {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

/* Enhanced Book Cards - Mobile First Design */
.book-card {
  background: white;
  border-radius: 1rem;
  padding: 1rem;
  margin: 0.75rem 0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  border: 1px solid #e5e7eb;
  transition: all 0.2s ease;
}

.book-card:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  transform: translateY(-1px);
}

.book-cover {
  width: 48px;
  height: 64px;
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
  box-shadow: 0 2px 4px rgba(139, 92, 246, 0.2);
}

.book-cover svg {
  color: white;
  width: 24px;
  height: 24px;
}

.book-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: #111827;
  margin: 0 0 0.25rem 0;
  line-height: 1.3;
}

.book-author {
  font-size: 0.875rem;
  color: #6b7280;
  margin: 0 0 0.75rem 0;
  font-weight: 500;
}

.book-pitch {
  font-size: 0.875rem;
  color: #374151;
  line-height: 1.5;
  margin: 0 0 1rem 0;
}

/* Enhanced Book Details */
.book-why,
.book-confidence,
.book-genre,
.book-length,
.book-difficulty {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin: 0.5rem 0;
  font-size: 0.8rem;
  line-height: 1.4;
}

.book-why strong,
.book-confidence strong,
.book-genre strong,
.book-length strong,
.book-difficulty strong {
  color: #374151;
  font-weight: 600;
  margin-right: 0.25rem;
}

/* Improved Book Actions */
.book-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e5e7eb;
}

.action-btn {
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  background: white;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.action-btn:hover {
  background: #f9fafb;
  border-color: #9ca3af;
  transform: translateY(-1px);
}

.action-btn svg {
  width: 16px;
  height: 16px;
}

.like-btn:hover {
  background: #dcfce7;
  color: #16a34a;
}

.dislike-btn:hover {
  background: #fee2e2;
  color: #dc2626;
}

.save-btn:hover {
  background: #dbeafe;
  color: #2563eb;
}

/* Sticky Input - Ultra Simple - STICK TO BOTTOM */
.chat-input {
  background: white;
  border-top: 1px solid #f0f0f0;
  padding: 1rem;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  flex-shrink: 0;
}

.input-container {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

#chat-input {
  flex: 1;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  resize: none;
  min-height: 2.75rem;
  max-height: 7.5rem;
  font-family: inherit;
  line-height: 1.5;
  background: #f8fafc;
}

#chat-input:focus {
  outline: none;
  border-color: #3b82f6;
  background: white;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Send Button */
.send-btn {
  width: auto;
  height: 2.75rem;
  padding: 0 1.5rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-weight: 600;
  font-size: 0.875rem;
  gap: 0.5rem;
  flex-shrink: 0;
}

.send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.send-btn.primary-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.send-btn.refine-btn {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.send-btn .btn-text {
  display: block;
}

/* Advanced Options Button */
.advanced-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  background: #f8fafc;
  color: #6b7280;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
}

.advanced-btn:hover {
  background: #f1f5f9;
  border-color: #d1d5db;
  color: #374151;
  transform: translateY(-1px);
}

.advanced-btn svg {
  width: 18px;
  height: 18px;
}

/* Advanced Options Panel */
.advanced-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid #f0f0f0;
  padding: 1rem;
  z-index: 15;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
}

.advanced-panel.open {
  transform: translateY(0);
}

.advanced-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e5e7eb;
}

.advanced-header h4 {
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
  margin: 0;
}

.close-advanced {
  width: 1.5rem;
  height: 1.5rem;
  background: #f3f4f6;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  transition: all 0.2s;
}

.close-advanced:hover {
  background: #e5e7eb;
  color: #374151;
}

.advanced-section {
  margin-bottom: 1rem;
}

.advanced-section h5 {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  margin: 0 0 0.5rem 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Tone Chips in Advanced Panel */
.tone-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tone-chip {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  background: #f8fafc;
  color: #475569;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.tone-chip:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.tone-chip.active {
  background: #3b82f6;
  border-color: #3b82f6;
  color: white;
}

/* Quick Suggestions in Advanced Panel */
.quick-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.suggestion-btn {
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.suggestion-btn:hover {
  background: #fde68a;
  border-color: #f59e0b;
  transform: translateY(-1px);
}

/* Preference Item in Advanced Panel */
.preference-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
}

.preference-item label {
  font-size: 0.75rem;
  color: #374151;
  margin: 0;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 2.5rem;
  height: 1.25rem;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: 0.3s;
  border-radius: 1.25rem;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 1rem;
  width: 1rem;
  left: 0.125rem;
  bottom: 0.125rem;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked + .toggle-slider {
  background-color: #3b82f6;
}

input:checked + .toggle-slider:before {
  transform: translateX(1.25rem);
}

/* Settings Panel - Left Side */
.settings-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  pointer-events: none;
  transition: all 0.3s ease;
}

.settings-panel.open {
  pointer-events: all;
}

.settings-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.settings-panel.open .settings-overlay {
  opacity: 1;
}

.settings-content {
  position: absolute;
  top: 0;
  left: -320px;
  width: 320px;
  height: 100%;
  background: white;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
  overflow-y: auto;
  transition: left 0.3s ease;
  padding: 1.5rem;
}

.settings-panel.open .settings-content {
  left: 0;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e5e7eb;
}

.settings-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0;
}

.close-settings {
  width: 2rem;
  height: 2rem;
  background: #f3f4f6;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  transition: all 0.2s;
}

.close-settings:hover {
  background: #e5e7eb;
  color: #374151;
}

.settings-section {
  margin-bottom: 2rem;
}

.settings-section h4 {
  font-size: 1rem;
  font-weight: 600;
  color: #374151;
  margin: 0 0 1rem 0;
}

/* Auth Buttons */
.auth-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.auth-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
  background: white;
  color: #374151;
}

.auth-btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.signin-btn {
  color: #3b82f6;
  border-color: #3b82f6;
}

.signin-btn:hover {
  background: #eff6ff;
}

.signup-btn {
  color: #059669;
  border-color: #059669;
}

.signup-btn:hover {
  background: #ecfdf5;
}

/* Typing Indicator */
.typing {
  opacity: 0.7;
}

.typing-dots {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.typing-dots span {
  width: 0.5rem;
  height: 0.5rem;
  background: #9ca3af;
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

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

/* Responsive Design */
@media (min-width: 768px) {
  .settings-content {
    width: 400px;
    left: -400px;
  }
  
  .chat-messages {
    padding: 1.5rem 2rem;
  }
  
  .chat-input {
    padding: 1.5rem 2rem;
  }
  
  .book-suggestions {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  }
}

@media (min-width: 1024px) {
  .chat-messages {
    padding: 2rem 3rem;
  }
  
  .chat-input {
    padding: 2rem 3rem;
  }
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 2px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

.settings-content::-webkit-scrollbar {
  width: 4px;
}

.settings-content::-webkit-scrollbar-track {
  background: transparent;
}

.settings-content::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 2px;
}

.settings-content::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* User Context - Improved Design */
.user-context {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
  border-radius: 0.75rem;
  border: 1px solid #bae6fd;
}

.context-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.context-tag {
  padding: 0.375rem 0.75rem;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: white;
  border-radius: 1.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
  transition: all 0.2s ease;
}

.context-tag:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

.history-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border-radius: 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

.feedback-summary {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #bae6fd;
}

.feedback-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: #0c4a6e;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.feedback-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.5rem;
  background: white;
  border-radius: 0.5rem;
  margin: 0.25rem 0;
  border: 1px solid #e0f2fe;
}

.feedback-icon {
  font-size: 1rem;
}

.feedback-text {
  color: #0c4a6e;
  font-size: 0.75rem;
  font-weight: 500;
}

/* Book Card Structure */
.book-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.book-main-info {
  flex: 1;
  min-width: 0;
}

.book-content {
  margin-bottom: 1rem;
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .book-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.5rem;
  }
  
  .book-cover {
    margin-bottom: 0.5rem;
  }
  
  .book-actions {
    justify-content: center;
  }
}

/* Debug Messages */
.debug-message {
  background: #fef3c7;
  border: 1px solid #fde68a;
}

.debug-avatar {
  width: 2rem;
  height: 2rem;
  background: #f59e0b;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: white;
}

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

.debug-title {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: #92400e;
}

.debug-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.25rem;
  color: #92400e;
  transition: all 0.2s ease;
}

.debug-toggle:hover {
  background: rgba(245, 158, 11, 0.1);
}

.debug-toggle svg {
  transition: transform 0.2s ease;
}

.debug-content.collapsed .debug-toggle svg {
  transform: rotate(-90deg);
}

.debug-content {
  max-height: 500px;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.debug-content.collapsed {
  max-height: 0;
}

.debug-json {
  background: #1f2937;
  color: #f9fafb;
  padding: 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  line-height: 1.4;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.debug-text {
  background: #f3f4f6;
  color: #374151;
  padding: 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  border: 1px solid #e5e7eb;
}

/* Advanced Panel Options */
.option-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #e5e7eb;
}

.option-item:last-child {
  border-bottom: none;
}

.option-label {
  font-size: 0.875rem;
  color: #374151;
  font-weight: 500;
  flex: 1;
}

/* Disabled toggle switch */
.toggle-switch input:disabled + .toggle-slider {
  background-color: #9ca3af;
  cursor: not-allowed;
}

.toggle-switch input:disabled + .toggle-slider:before {
  background-color: #d1d5db;
}

/* Debug Indicator */
.debug-indicator {
  margin-left: 0.5rem;
}

.debug-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: 'Monaco', 'Menlo', monospace;
}
