/* Custom styles for KitchenMate */

* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  touch-action: pan-y;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #5568d3 0%, #65408b 100%);
}

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

.pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Input focus effects */
input:focus, textarea:focus, select:focus {
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Button hover effects */
button:not(:disabled) {
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Loading spinner */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.fa-spin {
  animation: spin 1s linear infinite;
}

/* Card hover effects */
.ingredient-card:hover {
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* Gradient backgrounds */
.gradient-purple {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

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

.gradient-blue {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

/* Mobile optimizations */
@media (max-width: 640px) {
  .max-w-md {
    max-width: 100%;
  }
  
  input, textarea, select {
    font-size: 16px; /* Prevent zoom on iOS */
  }
}

/* Safe area for iOS */
@supports (padding: max(0px)) {
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* Prevent text selection on buttons */
button {
  -webkit-user-select: none;
  user-select: none;
}

/* Image upload preview */
.preview-image {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
}

/* Progress bar animation */
.progress-bar {
  transition: width 0.5s ease-in-out;
}

/* Checkbox styling */
input[type="checkbox"] {
  cursor: pointer;
  accent-color: #667eea;
}

/* Details/summary styling */
details summary {
  list-style: none;
}

details summary::-webkit-details-marker {
  display: none;
}

details[open] summary {
  margin-bottom: 0.5rem;
}

/* Category filter buttons */
.category-filter-btn {
  border: 2px solid transparent;
  transition: all 0.2s ease;
  background-color: #f3f4f6;
  color: #6b7280;
}

.category-filter-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.category-filter-btn.active {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
  font-weight: 700;
}

/* Horizontal scroll for filter buttons */
#categoryFilterInventory,
#categoryFilterShopping {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#categoryFilterInventory::-webkit-scrollbar,
#categoryFilterShopping::-webkit-scrollbar {
  display: none;
}

/* ============= CHATBOT STYLES ============= */

/* Chatbot floating button */
#chatbotButton {
  position: fixed !important;
  bottom: 80px !important;
  right: 24px !important;
  width: 64px !important;
  height: 64px !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  color: white !important;
  border: none !important;
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5) !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 28px !important;
  transition: all 0.3s ease !important;
  z-index: 99999 !important;
  padding: 0 !important;
  line-height: 1 !important;
}

#chatbotButton i {
  font-size: 28px !important;
  line-height: 1 !important;
}

#chatbotButton:hover {
  transform: scale(1.15) !important;
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.7) !important;
}

#chatbotButton.open {
  transform: rotate(90deg) !important;
}

/* Chatbot button */
#chatbotButton {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  z-index: 999999;
  padding: 0;
  touch-action: none;
  user-select: none;
}

#chatbotButton:active {
  cursor: grabbing;
}

#chatbotButton.dragging {
  transition: none;
  cursor: grabbing;
}

/* Chatbot container (sidebar) */
#chatbotContainer {
  position: fixed;
  top: 0;
  right: 0;
  width: 450px;
  max-width: 100vw;
  height: 100vh;
  background: white;
  border-radius: 0;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
  flex-direction: column;
  overflow: hidden;
  z-index: 99998;
  transition: transform 0.3s ease;
  transform: translateX(100%);
}

/* Fullscreen mode */
#chatbotContainer.fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  bottom: 0;
  right: 0;
  border-radius: 0;
}

/* Chatbot header */
.chatbot-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chatbot-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chatbot-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chatbot-action-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  font-size: 16px;
}

.chatbot-action-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.chatbot-action-btn:active {
  transform: scale(0.95);
}

/* Chatbot messages area */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #f9fafb;
  scroll-behavior: smooth;
  min-height: 0;
}

/* Scroll to bottom button */
.scroll-to-bottom {
  position: absolute;
  bottom: 140px;
  right: 30px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #667eea;
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all 0.2s ease;
}

.scroll-to-bottom.show {
  display: flex;
}

.scroll-to-bottom:hover {
  transform: scale(1.1);
  background: #764ba2;
}

/* Message bubbles */
.chat-message {
  display: flex;
  gap: 8px;
  animation: slideIn 0.3s ease;
}

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

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

.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.chat-message.user .chat-avatar {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.chat-bubble {
  max-width: 90%;
  padding: 12px 16px;
  border-radius: 16px;
  background: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  word-wrap: break-word;
  white-space: pre-wrap;
  overflow-x: auto;
}

.chat-message.user .chat-bubble {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  max-width: 75%;
}

.chat-bubble p {
  margin: 0;
  line-height: 1.5;
  font-size: 14px;
}

/* Recipe formatting in chat */
.chat-bubble strong {
  color: #667eea;
  font-weight: 700;
  display: block;
  margin-top: 16px;
  margin-bottom: 6px;
  font-size: 15px;
}

.chat-bubble strong:first-child {
  margin-top: 0;
  font-size: 16px;
  color: #764ba2;
}

.chat-bubble ul, .chat-bubble ol {
  margin: 8px 0;
  padding-left: 24px;
}

.chat-bubble li {
  margin: 6px 0;
  line-height: 1.7;
  font-size: 13px;
}

.chat-bubble hr {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 16px 0;
}

.chat-bubble em {
  font-style: italic;
  color: #6b7280;
}

/* Scrollbar styling for chatbot */
.chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: #667eea;
  border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: #764ba2;
}

/* Chatbot input area */
.chatbot-input {
  padding: 16px 20px 20px 20px;
  background: white;
  border-top: 2px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.chatbot-input-wrapper {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chatbot-input textarea {
  flex: 1;
  padding: 14px 16px;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  font-size: 15px;
  outline: none;
  transition: all 0.2s ease;
  font-family: inherit;
  resize: none;
  min-height: 100px;
  max-height: 200px;
  line-height: 1.5;
}

.chatbot-input textarea:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.chatbot-input-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: #6b7280;
}

.chatbot-char-count {
  font-size: 12px;
  color: #9ca3af;
}

/* Voice button */
.chatbot-voice-btn {
  width: 48px;
  height: 100px;
  border-radius: 12px;
  background: white;
  color: #667eea;
  border: 2px solid #667eea;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: all 0.3s ease;
  flex-shrink: 0;
  margin-right: 8px;
}

.chatbot-voice-btn:hover {
  background: #f3f4f6;
  transform: translateY(-2px);
}

.chatbot-voice-btn.listening {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  border-color: #ef4444;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
  }
}

.chatbot-send {
  width: 56px;
  height: 100px;
  border-radius: 12px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.chatbot-send:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.chatbot-send:active:not(:disabled) {
  transform: translateY(0);
}

.chatbot-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #9ca3af;
}

/* Quick actions */
.chatbot-quick-actions {
  display: none;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ca3af;
  animation: typing 1.4s infinite;
}

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

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

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

/* Mobile responsive */
@media (max-width: 640px) {
  #chatbotContainer {
    width: 100vw;
    max-width: 100vw;
  }
  
  #chatbotButton {
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
  }
}
