
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  margin: 0;
  padding: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
}

.cloudflare-header {
  background: linear-gradient(135deg, #f38020 0%, #f5af19 100%);
  color: white;
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.cf-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.cf-logo {
  font-size: 1.2rem;
}

.cf-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
}

.cf-indicator {
  font-size: 0.8rem;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

header {
  text-align: center;
  color: white;
  margin-bottom: 30px;
}

header h1 {
  font-size: 2.5rem;
  margin: 0;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.user-identity {
  margin: 20px 0;
  padding: 15px;
  background: rgba(255,255,255,0.15);
  border-radius: 15px;
  backdrop-filter: blur(15px);
  border: 1px solid rgba(255,255,255,0.2);
}

.user-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  color: white;
}

.username-section {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-icon {
  font-size: 1.2rem;
}

.username {
  font-weight: 600;
  font-size: 1rem;
  min-width: 80px;
}

.edit-btn, .copy-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.3s;
  backdrop-filter: blur(5px);
}

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

.user-id-section {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.id-label {
  color: rgba(255,255,255,0.8);
}

.user-id {
  font-family: 'Courier New', monospace;
  background: rgba(0,0,0,0.2);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  padding: 30px;
  border-radius: 15px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.3);
  max-width: 400px;
  width: 90%;
}

.modal-content h3 {
  margin: 0 0 20px 0;
  color: #2c3e50;
  text-align: center;
}

.modal-content input {
  width: 100%;
  padding: 12px;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  font-size: 1rem;
  margin-bottom: 20px;
  outline: none;
  box-sizing: border-box;
}

.modal-content input:focus {
  border-color: #667eea;
}

.welcome-modal {
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(10px);
}

.welcome-content {
  max-width: 600px;
  width: 95%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 25px 50px rgba(0,0,0,0.4);
}

.welcome-header {
  text-align: center;
  padding: 30px 30px 20px;
  background: rgba(255,255,255,0.1);
}

.welcome-header h2 {
  margin: 0 0 10px 0;
  font-size: 1.8rem;
  font-weight: 700;
}

.welcome-header p {
  margin: 0;
  font-size: 1rem;
  opacity: 0.9;
}

.welcome-body {
  padding: 30px;
}

.welcome-body p {
  text-align: center;
  margin: 0 0 20px 0;
  font-size: 1.1rem;
}

.welcome-body input {
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 12px;
  font-size: 1.1rem;
  margin-bottom: 25px;
  box-sizing: border-box;
  background: white;
  color: #333;
  text-align: center;
}

.welcome-body input:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.3);
}

.welcome-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 15px;
  margin-top: 20px;
}

.feature-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.1);
  padding: 12px;
  border-radius: 10px;
  font-size: 0.9rem;
}

.feature-icon {
  font-size: 1.2rem;
}

.welcome-actions {
  padding: 0 30px 30px;
  text-align: center;
}

.welcome-start-btn {
  background: #f38020;
  color: white;
  border: none;
  padding: 15px 40px;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 15px rgba(243,128,32,0.4);
}

.welcome-start-btn:hover {
  background: #e6730e;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(243,128,32,0.5);
}

.welcome-start-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.save-btn, .cancel-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s;
  flex: 1;
}

.save-btn {
  background: #28a745;
  color: white;
}

.save-btn:hover {
  background: #218838;
}

.cancel-btn {
  background: #6c757d;
  color: white;
}

.cancel-btn:hover {
  background: #5a6268;
}

.chat-container {
  background: white;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  overflow: hidden;
  margin-bottom: 30px;
}

.messages {
  height: 400px;
  overflow-y: auto;
  padding: 20px;
  border-bottom: 1px solid #eee;
  scroll-behavior: smooth;
}

.message {
  margin: 15px 0;
  display: flex;
  gap: 10px;
}

.message.user {
  justify-content: flex-end;
}

.message.agent {
  justify-content: flex-start;
}

.message.system {
  justify-content: center;
}

.message-content {
  max-width: 70%;
  padding: 12px 18px;
  border-radius: 18px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  word-wrap: break-word;
  line-height: 1.4;
}

.message.user .message-content {
  background: #667eea;
  color: white;
}

.message.agent .message-content {
  background: #f5f5f5;
  color: #333;
}

.message.system .message-content {
  background: #e3f2fd;
  color: #1565c0;
  border: 1px solid #bbdefb;
  max-width: 90%;
}

.plan-view {
  background: #f8f9fa;
  border-top: 1px solid #eee;
  padding: 20px;
  margin-top: 10px;
  border-radius: 0 0 15px 15px;
}

.plan-view h3 {
  margin: 0 0 15px 0;
  color: #495057;
  font-size: 1.2rem;
}

.plan-steps {
  margin-top: 20px;
}

.plan-steps h5 {
  margin: 0 0 15px 0;
  color: #495057;
  font-size: 1.1rem;
}

.step-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 10px 0;
  padding: 12px;
  border-radius: 8px;
  border-left: 4px solid #dee2e6;
  background: white;
}

.step-content {
  flex: 1;
}

.step-item.completed {
  border-left-color: #28a745;
  background: #f8fff9;
}

.step-item.in_progress {
  border-left-color: #ffc107;
  background: #fffef5;
}

.step-item.failed {
  border-left-color: #dc3545;
  background: #fff5f5;
}

.step-icon {
  font-size: 1.2rem;
  margin-top: 2px;
}

.step-desc {
  font-weight: 500;
  color: #495057;
  margin-bottom: 5px;
}

.step-thinking {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  padding: 6px 10px;
  background: rgba(102, 126, 234, 0.1);
  border-radius: 12px;
  font-size: 0.85rem;
  color: #667eea;
  animation: pulse 2s infinite;
}

.thinking-indicator {
  font-size: 0.9rem;
}

.thinking-text {
  font-style: italic;
}

.step-result {
  margin-top: 8px;
  padding: 15px;
  background: rgba(0,0,0,0.05);
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #333;
  max-width: 100%;
  word-wrap: break-word;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid rgba(0,0,0,0.1);
}

.step-result h4 {
  margin: 0 0 10px 0;
  color: #495057;
  font-size: 1rem;
}

.step-result p {
  margin: 8px 0;
}

.step-result strong {
  color: #495057;
}

.itinerary-content {
  white-space: pre-wrap;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  background: #f8f9fa;
  padding: 15px;
  border-radius: 8px;
  border-left: 4px solid #667eea;
  margin: 10px 0;
  overflow-y: auto;
  word-wrap: break-word;
}

.itinerary-section {
  margin: 15px 0;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  background: white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.itinerary-section strong {
  display: block;
  padding: 12px 15px;
  background: #667eea;
  color: white;
  margin: 0;
  border-radius: 8px 8px 0 0;
  font-size: 16px;
}

.expandable-content {
  max-height: 200px;
  overflow: hidden;
  transition: max-height 0.3s ease-in-out;
}

.expandable-content.expanded {
  max-height: none;
  overflow: visible;
}

.expandable-result {
  position: relative;
}

.expand-btn {
  background: #28a745;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 0 0 8px 8px;
  width: 100%;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
}

.expand-btn:hover {
  background: #218838;
}

.thinking-bubble {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 15px 20px;
  margin: 10px 0;
  border-radius: 20px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  animation: pulse 2s infinite;
}

.thinking-content {
  display: flex;
  align-items: center;
  gap: 15px;
}

.thinking-dots {
  display: flex;
  gap: 5px;
}

.thinking-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.7);
  animation: bounce 1.4s infinite ease-in-out;
}

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

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

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

.agent-status {
  background: #f8f9fa;
  border: 2px solid #667eea;
  border-radius: 12px;
  padding: 15px;
  margin: 10px 0;
  font-size: 0.9rem;
}

.status-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-weight: 600;
}

.status-icon {
  font-size: 1.2rem;
}

.connection-indicator {
  margin-left: auto;
  font-size: 0.8rem;
}

.connection-indicator.connected {
  color: #28a745;
}

.connection-indicator.disconnected {
  color: #dc3545;
}

.status-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.status-item {
  display: flex;
  justify-content: space-between;
}

.status-item .label {
  font-weight: 500;
  color: #666;
}

.input-container {
  padding: 20px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

#messageInput {
  flex: 1;
  border: 2px solid #e9ecef;
  border-radius: 10px;
  padding: 12px;
  resize: vertical;
  font-family: inherit;
  outline: none;
  min-height: 20px;
  max-height: 120px;
  transition: border-color 0.3s;
}

#messageInput:focus {
  border-color: #667eea;
}

#sendButton {
  background: #667eea;
  color: white;
  border: none;
  border-radius: 10px;
  padding: 12px 24px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s;
  white-space: nowrap;
}

#sendButton:hover:not(:disabled) {
  background: #5a6fd8;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

#sendButton:disabled {
  background: #ccc;
  cursor: not-allowed;
}

@media (max-width: 768px) {
  .container {
    padding: 10px;
  }

  header h1 {
    font-size: 1.8rem;
  }

  .user-info {
    flex-direction: column;
    gap: 15px;
    text-align: center;
  }

  .username-section, .user-id-section {
    justify-content: center;
  }

  .input-container {
    flex-direction: column;
    align-items: stretch;
  }

  .message-content {
    max-width: 85%;
  }
}

.cloudflare-footer {
  background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
  color: white;
  margin-top: 40px;
  padding: 40px 0 20px;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 30px;
  padding: 0 20px;
}

.footer-section h4 {
  margin: 0 0 10px 0;
  color: #f38020;
  font-size: 1.1rem;
}

.footer-section p {
  margin: 0;
  color: #d1d5db;
  line-height: 1.5;
  font-size: 0.9rem;
}

.footer-bottom {
  text-align: center;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid #4b5563;
  color: #9ca3af;
  font-size: 0.85rem;
}

@media (max-width: 768px) {
  .cloudflare-header {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }

  .footer-content {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}
