/* =========================================================
   Chat Interface Styling - Improved Design
   ========================================================= */

:root {
  --brand-dark: #0D2C48;
  --brand-mid: #2D5652;
  --brand-light: #96D3CC;
  --text-dark: #0D2C48;
  --text-light: #FFFFFF;
  --border-grey: #D9D9D9;
  --bg-grey: #F5F5F5;
  --shadow: 0 4px 25px rgba(0, 0, 0, 0.05);
}

/* Chat Interface Layout */
.chat-interface {
  background: #fff;
  border: 1px solid var(--border-grey);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  height: 100%;
  box-shadow: var(--shadow);
  font-family: 'Chivo', sans-serif;
}

/* Welcome Message */
.chat-welcome-message {
  background: var(--bg-grey);
  color: var(--text-dark);
  padding: 15px 20px;
  border-radius: 20px 20px 0 0;
  font-family: 'Chivo', sans-serif;
  font-size: 14px;
  text-align: center;
  border-bottom: 1px solid var(--border-grey);
}

/* Quick Actions - moved to bottom */
.quick-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 4px 20px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border-grey);
}

/* Mobile quick actions - ensure single line fit */
@media (max-width: 768px) {
  .quick-actions {
    gap: 2px;
    padding: 3px 8px;
    justify-content: center;
    flex-wrap: nowrap; /* Force single line */
    overflow-x: auto; /* Allow horizontal scroll if needed */
  }
}

.quick-action-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  background: #fff;
  color: var(--text-dark);
  border: 1px solid var(--border-grey);
  border-radius: 12px;
  cursor: pointer;
  font-weight: 500;
  font-size: 12px;
  font-family: 'Chivo', sans-serif;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1;
}


.quick-action-chip:hover {
  background: rgba(150, 211, 204, 0.1);
  border-color: var(--brand-light);
  color: var(--brand-dark);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.quick-action-chip:active {
  transform: translateY(0);
}

.quick-action-chip i {
  font-size: 10px;
  color: var(--brand-mid);
}

/* Chat Messages */
.chat-messages {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  max-height: 400px;
  font-family: 'Chivo', sans-serif;
  scroll-behavior: smooth;
}

.chat-message {
  margin-bottom: 16px;
  padding: 12px 18px;
  border-radius: 20px;
  max-width: 85%;
  font-size: 15px;
  line-height: 1.6;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  word-wrap: break-word;
  overflow-wrap: break-word;
  animation: fadeIn 0.3s ease;
}

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

.user-message {
  background: var(--brand-light);
  color: var(--text-dark);
  margin-left: auto;
  text-align: left;
  max-width: 70%;
  font-weight: 450;
}

.bot-message {
  background: #f8f9fa;
  color: var(--text-dark);
  border: none;
  margin-right: auto;
  max-width: 90%;
  position: relative;
}

.bot-message::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--brand-mid);
  border-radius: 3px;
  opacity: 0.3;
}

.thinking-message {
  background: rgba(150, 211, 204, 0.15);
  border: 1px solid rgba(150, 211, 204, 0.3);
  font-size: 13px;
  padding: 8px 14px;
  max-width: fit-content;
  min-width: 150px;
  opacity: 0.9;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 0.7; }
}

/* Chat Input */
.chat-input {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 0 0 20px 20px;
  background: rgba(249, 250, 251, 0.8);
  backdrop-filter: blur(10px);
}

.chat-mode-selector,
.model-selector {
  border: 1px solid var(--border-grey);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 12px;
  font-family: 'Chivo', sans-serif;
  background: #fff;
  color: var(--text-dark);
}

.chat-input-field {
  flex: 1;
  border: 2px solid transparent;
  border-radius: 20px;
  padding: 12px 18px;
  font-family: 'Chivo', sans-serif;
  font-size: 15px;
  background: white;
  color: var(--text-dark);
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.chat-input-field:focus {
  outline: none;
  border-color: var(--brand-light);
  box-shadow: 0 2px 12px rgba(150, 211, 204, 0.2);
}

.chat-input-field::placeholder {
  color: #9CA3AF;
  font-family: 'Chivo', sans-serif;
}

.chat-send-btn {
  background: var(--brand-mid);
  border: none;
  border-radius: 50% !important;
  width: 44px;
  height: 44px;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(45, 86, 82, 0.2);
  min-width: 44px;
  max-width: 44px;
  position: relative;
  overflow: hidden;
}

.chat-send-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.chat-send-btn:hover {
  background: var(--brand-dark);
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(45, 86, 82, 0.3);
}

.chat-send-btn:hover::before {
  width: 50px;
  height: 50px;
}

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

.chat-send-btn i {
  font-size: 16px;
  z-index: 1;
}

/* Mobile chat send button */
#mobile-chat-send {
  background: var(--brand-mid);
  border: none;
  border-radius: 50% !important; /* Force circular shape */
  width: 40px;
  height: 40px;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  min-width: 40px; /* Ensure it stays square */
  max-width: 40px;
}

#mobile-chat-send:hover {
  background: var(--brand-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(45, 86, 82, 0.3);
}

#mobile-chat-send i {
  font-size: 14px;
}

/* New Chat Button Styling - Minimalist Design */
.new-chat-btn {
  background: none;
  border: none;
  padding: 8px;
  margin-right: 10px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 8px;
  width: 40px;
  height: 40px;
}

.new-chat-btn:hover {
  background: rgba(45, 86, 82, 0.1);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.new-chat-btn:active {
  transform: translateY(0);
}

.new-chat-icon {
  width: 24px;
  height: 24px;
  transition: all 0.2s ease;
}

.new-chat-btn:hover .new-chat-icon {
  transform: scale(1.1);
}

/* Mobile new chat button */
.mobile-chat-controls .new-chat-btn {
  padding: 6px;
  margin-right: 5px;
  margin-left: 5px;
  width: 36px;
  height: 36px;
}

.mobile-chat-controls .new-chat-icon {
  width: 20px;
  height: 20px;
}

/* =========================================================
   Mobile FAB and Modal Styling
   ========================================================= */

.chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--brand-mid);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 1000;
}

.chat-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.mobile-chat-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: white;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.mobile-chat-modal.show {
  transform: translateY(0);
}

.mobile-chat-header {
  padding: 16px;
  background: var(--bg-grey);
  border-bottom: 1px solid var(--border-grey);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mobile-chat-header h3 {
  margin: 0;
  font-size: 18px;
  color: var(--text-dark);
}

.mobile-chat-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-dark);
  cursor: pointer;
}

.mobile-chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mobile-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

.mobile-chat-input {
  padding: 12px;
  border-top: 1px solid var(--border-grey);
  background: white;
}

/* =========================================================
   Web Search Results Styling
   ========================================================= */

.web-search-results {
  margin: 10px 0;
  padding: 12px;
  border: 1px solid var(--brand-light);
  border-radius: 8px;
  background: #f8fffe;
}

.web-search-results h6 {
  color: var(--brand-dark);
  margin-bottom: 10px;
  font-weight: 600;
}

.web-search-results h6 i {
  color: var(--brand-mid);
  margin-right: 8px;
}

.search-result-item {
  margin-bottom: 8px;
  padding: 8px;
  border-radius: 6px;
  background: white;
  border: 1px solid #e0f2f1;
}

.search-result-item:last-child {
  margin-bottom: 0;
}

.search-query {
  font-size: 14px;
  color: var(--text-dark);
  margin-bottom: 4px;
}

.search-status {
  font-size: 12px;
  color: var(--brand-mid);
  margin-bottom: 6px;
}

.search-citations {
  font-size: 13px;
  color: var(--text-dark);
}

.search-citations ul {
  margin: 4px 0 0 0;
  padding-left: 20px;
}

.search-citations li {
  margin-bottom: 3px;
}

.search-citations a {
  color: var(--brand-mid);
  text-decoration: none;
}

.search-citations a:hover {
  color: var(--brand-dark);
  text-decoration: underline;
}

/* =========================================================
   Tool Use Indicators
   ========================================================= */

.tool-use-indicators {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-grey);
}

.tool-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--bg-grey);
  border-radius: 12px;
  font-size: 12px;
  color: var(--brand-mid);
  border: 1px solid var(--border-grey);
}

.tool-indicator i {
  font-size: 11px;
  color: var(--brand-dark);
}

.tool-indicator span {
  font-weight: 500;
}

/* =========================================================
   Mobile Chat Improvements
   ========================================================= */

@media (max-width: 768px) {
  /* Chat messages container */
  .chat-messages {
    padding: 16px;
  }
  
  /* All messages on mobile */
  .chat-message {
    font-size: 14px;
    padding: 10px 16px;
    margin-bottom: 12px;
  }
  
  /* Thinking message - more compact */
  .thinking-message {
    padding: 6px 12px;
    font-size: 12px;
    max-width: fit-content;
    min-width: 120px;
    margin-bottom: 8px;
  }
  
  /* User message on mobile */
  .user-message {
    max-width: 85%;
  }
  
  /* Bot message on mobile - wider for better readability */
  .bot-message {
    max-width: 100%;
  }
  
  /* Quick action chips - better spacing and alignment */
  .quick-actions {
    gap: 8px;
    padding: 8px 16px;
    justify-content: space-between;
    width: 100%;
  }
  
  .quick-action-chip {
    padding: 10px 12px;
    font-size: 12px;
    gap: 6px;
    flex: 1;
    max-width: none;
    border-radius: 14px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }
  
  .quick-action-chip i {
    font-size: 11px;
    flex-shrink: 0;
  }
  
  /* Chat input field mobile optimization */
  .chat-input-field {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 12px 16px;
    border-radius: 20px;
    background: white;
  }
  
  /* Chat input area */
  .chat-input {
    padding: 12px 16px;
    gap: 10px;
  }
  
  /* Mobile modal specific styles */
  .mobile-chat-messages {
    padding: 16px;
  }
  
  .mobile-chat-messages .thinking-message {
    max-width: 60%;
  }
  
  .mobile-chat-messages .user-message {
    max-width: 80%;
  }
  
  .mobile-chat-messages .bot-message {
    max-width: 98%;
  }
  
  /* Hide bot message accent line on mobile for cleaner look */
  .bot-message::before {
    display: none;
  }
}
