/* Conversational Interface Styles */
/* Following AGENTS.md recommendations for modular CSS */

.conversational-enabled {
  background: #ffffff !important; /* White background from page load */
  border: 2px solid #4682b4;
  border-radius: 12px;
  transition: all 0.3s ease;
  position: relative;
}

.conversational-enabled:focus {
  border-color: #2c5282;
  box-shadow: 0 0 0 3px rgba(70, 130, 180, 0.1);
  background: #ffffff !important; /* Ensure white stays on focus */
}

.conversational-enabled::before {
  content: "💬";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  opacity: 0.6;
  pointer-events: none;
}

/* Conversational detection indicator */
.conversational-detected {
  border-color: #9c27b0 !important;
  box-shadow: 0 0 0 3px rgba(156, 39, 176, 0.2) !important;
  background: linear-gradient(135deg, #fce4ec 0%, #f8bbd9 20%, #ffffff 20%, #ffffff 100%) !important;
}

.conversational-detected::placeholder {
  color: #9c27b0 !important;
  font-weight: 600 !important;
}

/* Animations for mobile feedback */
@keyframes pulse {
  0% { transform: translateX(-50%) scale(1); opacity: 1; }
  50% { transform: translateX(-50%) scale(1.05); opacity: 0.9; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Enhanced conversational feedback for mobile */
.conversational-feedback {
  animation: fadeInDown 0.3s ease-out;
  font-size: 14px;
  line-height: 1.4;
  border: none;
  backdrop-filter: blur(10px);
}

.conversational-feedback.listening {
  animation: pulse 1.5s infinite;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

/* Mobile optimizations */
@media (max-width: 768px) {
  .conversational-feedback {
    top: 10px;
    font-size: 13px;
    padding: 10px 16px;
    max-width: 95vw;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
  }
  
  .voice-button {
    width: 56px;
    height: 56px;
    font-size: 18px;
  }
  
  .conversational-enabled::before {
    font-size: 18px;
    right: 12px;
  }
}

/* Voice Button Styles */
.voice-button {
  background: linear-gradient(135deg, #4682b4 0%, #2c5282 100%);
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(70, 130, 180, 0.3);
  margin-left: 12px;
  position: relative;
  overflow: hidden;
}

.voice-button:hover {
  background: linear-gradient(135deg, #2c5282 0%, #1a365d 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(70, 130, 180, 0.4);
}

.voice-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(70, 130, 180, 0.3);
}

.voice-button.listening {
  background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
  animation: pulse-listening 1.5s infinite;
}

.voice-button.listening::after {
  content: "";
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-radius: 50%;
  border: 2px solid #e53e3e;
  animation: ripple 1.5s infinite;
}

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

@keyframes ripple {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(1.4);
    opacity: 0;
  }
}

/* Conversational Suggestions */
.conversational-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  margin-top: 4px;
  max-height: 200px;
  overflow-y: auto;
  display: none;
}

.suggestion-item {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  transition: background-color 0.2s ease;
  font-size: 14px;
  color: #4a5568;
}

.suggestion-item:hover {
  background-color: #f8f9fa;
  color: #2d3748;
}

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

.suggestion-item::before {
  content: "💡";
  margin-right: 8px;
  opacity: 0.7;
}

/* Conversational Feedback */
.conversational-feedback {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 500;
  z-index: 10000;
  display: none;
  max-width: 400px;
  text-align: center;
  animation: slideInDown 0.3s ease;
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.conversational-feedback.success {
  background: linear-gradient(135deg, #38a169 0%, #2f855a 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(56, 161, 105, 0.3);
}

.conversational-feedback.error {
  background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(229, 62, 62, 0.3);
}

.conversational-feedback.info {
  background: linear-gradient(135deg, #4682b4 0%, #2c5282 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(70, 130, 180, 0.3);
}

/* Search Container Integration */
.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between; /* Better distribution */
  gap: 12px;
  width: 100%;
}

/* Ensure theme button stays in position */
.theme-btn {
  flex-shrink: 0; /* Prevent button from shrinking */
  align-self: center; /* Center vertically */
}

/* Responsive Design */
@media (max-width: 768px) {
  .voice-button {
    width: 44px;
    height: 44px;
    margin-left: 8px;
  }
  
  .conversational-feedback {
    max-width: 300px;
    font-size: 14px;
    padding: 10px 20px;
  }
  
  .conversational-suggestions {
    font-size: 13px;
  }
  
  .suggestion-item {
    padding: 10px 14px;
  }
}

@media (max-width: 480px) {
  .voice-button {
    width: 40px;
    height: 40px;
  }
  
  .conversational-feedback {
    max-width: 250px;
    left: 20px;
    right: 20px;
    transform: none;
  }
}

/* Dark Theme Support */
body.dark-theme .conversational-enabled {
  background: #ffffff !important; /* Keep white even in dark theme for better readability */
  border-color: #4a5568;
  color: #000000; /* Ensure text remains readable on white background */
}

body.dark-theme .conversational-enabled:focus {
  border-color: #63b3ed;
  background: #ffffff !important; /* Keep white on focus in dark theme */
  color: #000000; /* Ensure text remains readable */
}

body.dark-theme .conversational-suggestions {
  background: #2d3748;
  border-color: #4a5568;
  color: #e2e8f0;
}

body.dark-theme .suggestion-item {
  border-bottom-color: #4a5568;
  color: #cbd5e0;
}

body.dark-theme .suggestion-item:hover {
  background-color: #4a5568;
  color: #e2e8f0;
}

/* Accessibility Enhancements */
.voice-button:focus {
  outline: 2px solid #4682b4;
  outline-offset: 2px;
}

.conversational-enabled:focus {
  outline: none; /* Custom focus styling above */
}

.suggestion-item:focus {
  background-color: #e2e8f0;
  outline: 2px solid #4682b4;
  outline-offset: -2px;
}

/* Animation for enhanced UX */
.conversational-suggestions {
  animation: fadeInUp 0.2s ease;
}

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

/* Voice Input States */
.voice-input-active .search-input {
  border-color: #e53e3e;
  box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.1);
}

.voice-input-processing {
  position: relative;
}

.voice-input-processing::after {
  content: "Bearbetar...";
  position: absolute;
  top: 100%;
  left: 0;
  font-size: 12px;
  color: #4682b4;
  margin-top: 4px;
  animation: blink 1s infinite;
}

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

/* Integration with existing theme system */
:root {
  --conversational-primary: #4682b4;
  --conversational-secondary: #2c5282;
  --conversational-success: #38a169;
  --conversational-error: #e53e3e;
  --conversational-bg: #f8f9fa;
  --conversational-border: #e2e8f0;
}

body.dark-theme {
  --conversational-primary: #63b3ed;
  --conversational-secondary: #4299e1;
  --conversational-bg: #2d3748;
  --conversational-border: #4a5568;
}

/* Advanced Conversational Interface Styles */
.conversational-response {
  background: linear-gradient(135deg, #e8f5e8 0%, #f0f8f0 100%);
  border: 1px solid #c8e6c9;
  border-radius: 12px;
  padding: 16px;
  margin: 12px 0;
  box-shadow: 0 2px 8px rgba(0, 128, 0, 0.1);
  position: relative;
  overflow: hidden;
}

.conversational-response::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: #4caf50;
}

/* Different tones for conversational responses */
.conversational-response.encouraging {
  background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
  border-color: #ffcc02;
}

.conversational-response.encouraging::before {
  background: #ff9800;
}

.conversational-response.supportive {
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
  border-color: #2196f3;
}

.conversational-response.supportive::before {
  background: #2196f3;
}

.conversational-response.inspiring {
  background: linear-gradient(135deg, #f3e5f5 0%, #e1bee7 100%);
  border-color: #9c27b0;
}

.conversational-response.inspiring::before {
  background: #9c27b0;
}

.conversational-response.educational {
  background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%);
  border-color: #4caf50;
}

.conversational-response.educational::before {
  background: #4caf50;
}

.conversational-response.compassionate {
  background: linear-gradient(135deg, #fce4ec 0%, #f8bbd9 100%);
  border-color: #e91e63;
}

.conversational-response.compassionate::before {
  background: #e91e63;
}

.response-message {
  font-size: 16px;
  line-height: 1.6;
  color: #2e7d32;
  margin-bottom: 12px;
  font-weight: 500;
}

.conversational-response.encouraging .response-message {
  color: #e65100;
}

.conversational-response.supportive .response-message {
  color: #0d47a1;
}

.conversational-response.inspiring .response-message {
  color: #4a148c;
}

.conversational-response.compassionate .response-message {
  color: #880e4f;
}

/* Response suggestions */
.response-suggestions {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(76, 175, 80, 0.2);
}

.suggestions-title {
  font-size: 14px;
  font-weight: 600;
  color: #388e3c;
  margin-bottom: 8px;
}

.suggestion-btn {
  display: inline-block;
  background: #ffffff;
  border: 1px solid #4caf50;
  border-radius: 20px;
  padding: 6px 12px;
  margin: 4px 8px 4px 0;
  font-size: 13px;
  color: #2e7d32;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
}

.suggestion-btn:hover {
  background: #4caf50;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(76, 175, 80, 0.3);
}

/* Action buttons */
.response-actions {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(76, 175, 80, 0.2);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.action-btn {
  background: linear-gradient(135deg, #4caf50 0%, #66bb6a 100%);
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.action-btn.create_reminder {
  background: linear-gradient(135deg, #2196f3 0%, #42a5f5 100%);
}

.action-btn.set_goal {
  background: linear-gradient(135deg, #ff9800 0%, #ffb74d 100%);
}

.action-btn.track_progress {
  background: linear-gradient(135deg, #9c27b0 0%, #ba68c8 100%);
}

.action-btn.start_conversation {
  background: linear-gradient(135deg, #4caf50 0%, #66bb6a 100%);
}

/* Follow-up question */
.response-followup {
  margin-top: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  font-style: italic;
  color: #2e7d32;
  border-left: 3px solid #4caf50;
}

/* Coaching-specific styles */
.coaching-response {
  position: relative;
}

.coaching-response::after {
  content: '🌱';
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 20px;
  opacity: 0.6;
}

.reminder-response::after {
  content: '⏰';
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 20px;
  opacity: 0.6;
}

/* Animation for new responses */
@keyframes slideInFromBottom {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.conversational-response {
  animation: slideInFromBottom 0.4s ease-out;
}

/* Success/error state styling */
.response-success {
  border-color: #4caf50;
  background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%);
}

.response-error {
  border-color: #f44336;
  background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
}

.response-error .response-message {
  color: #c62828;
}

.response-error::before {
  background: #f44336;
}

/* Responsive design for advanced features */
@media (max-width: 768px) {
  .conversational-response {
    padding: 12px;
    margin: 8px 0;
  }
  
  .response-message {
    font-size: 15px;
  }
  
  .action-btn {
    padding: 8px 12px;
    font-size: 13px;
  }
  
  .response-actions {
    flex-direction: column;
  }
  
  .action-btn {
    width: 100%;
  }
}

/* Reminder and Coaching Visualizations */
.reminder-visualization {
  margin-top: 16px;
  padding: 12px;
  background: rgba(33, 150, 243, 0.1);
  border-radius: 8px;
  border-left: 3px solid #2196f3;
}

.reminder-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reminder-detail {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.detail-label {
  font-weight: 600;
  color: #1976d2;
  font-size: 14px;
}

.detail-value {
  color: #424242;
  font-size: 14px;
  font-weight: 500;
}

.coaching-visualization {
  margin-top: 16px;
  padding: 12px;
  background: rgba(156, 39, 176, 0.1);
  border-radius: 8px;
  border-left: 3px solid #9c27b0;
}

.coaching-insights {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.coaching-insight {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 16px;
  font-size: 13px;
  color: #6a1b9a;
  font-weight: 500;
}

/* Interactive Info Gathering */
.info-gathering-form {
  margin-top: 16px;
  padding: 16px;
  background: rgba(255, 193, 7, 0.1);
  border-radius: 8px;
  border-left: 3px solid #ffc107;
}

.info-input {
  margin-bottom: 12px;
}

.info-input label {
  display: block;
  font-weight: 600;
  color: #f57c00;
  margin-bottom: 4px;
  font-size: 14px;
}

.info-input input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ffb74d;
  border-radius: 6px;
  font-size: 14px;
  background: white;
}

.info-input input:focus {
  outline: none;
  border-color: #ff9800;
  box-shadow: 0 0 0 2px rgba(255, 152, 0, 0.2);
}

.complete-reminder {
  margin-top: 12px;
  background: linear-gradient(135deg, #ff9800 0%, #ffb74d 100%);
}

/* Card highlighting for reminder creation */
.highlighted {
  animation: highlightPulse 2s ease-in-out;
  border: 2px solid #4caf50 !important;
  box-shadow: 0 0 20px rgba(76, 175, 80, 0.5) !important;
}

@keyframes highlightPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.5);
  }
  50% {
    transform: scale(1.02);
    box-shadow: 0 0 30px rgba(76, 175, 80, 0.8);
  }
}

/* Animation states */
.reminder-success {
  border-color: #4caf50 !important;
  background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%) !important;
}

.coaching-active {
  border-color: #9c27b0 !important;
  background: linear-gradient(135deg, #f3e5f5 0%, #e1bee7 100%) !important;
}

/* Dark theme support */
body.dark-theme .conversational-response {
  background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
  border-color: #63b3ed;
  color: #e2e8f0;
}

body.dark-theme .response-message {
  color: #e2e8f0;
}

body.dark-theme .suggestion-btn {
  background: #4a5568;
  border-color: #63b3ed;
  color: #e2e8f0;
}

body.dark-theme .suggestion-btn:hover {
  background: #63b3ed;
  color: #1a202c;
}

body.dark-theme .reminder-visualization {
  background: rgba(99, 179, 237, 0.2);
  border-color: #63b3ed;
}

body.dark-theme .coaching-visualization {
  background: rgba(183, 104, 200, 0.2);
  border-color: #b768c8;
}

body.dark-theme .info-gathering-form {
  background: rgba(237, 137, 54, 0.2);
  border-color: #ed8936;
}

body.dark-theme .info-input input {
  background: #4a5568;
  border-color: #ed8936;
  color: #e2e8f0;
}

/* Loading states */
.conversational-response.loading {
  opacity: 0.7;
  pointer-events: none;
}

.conversational-response.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  border: 2px solid #4caf50;
  border-top: 2px solid transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  transform: translate(-50%, -50%);
}

@keyframes spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}