:root {
  --cf-orange: #f38020;
  --cf-orange-hover: #fa8b28;
  --cf-orange-dim: rgba(243, 128, 32, 0.15);
  --cf-orange-glow: rgba(243, 128, 32, 0.35);
  
  --bg-app: #080b11;
  --bg-surface: #0e131d;
  --bg-card: #151c28;
  --bg-card-hover: #1c2536;
  --bg-input: #121824;

  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-medium: rgba(255, 255, 255, 0.12);
  --border-highlight: rgba(243, 128, 32, 0.4);

  --text-primary: #f0f4fc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-info: #3b82f6;
  --color-purple: #8b5cf6;
  --color-teal: #06b6d4;

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 25px rgba(243, 128, 32, 0.18);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(243, 128, 32, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(14, 165, 233, 0.06) 0%, transparent 40%);
  -webkit-font-smoothing: antialiased;
}

#app {
  width: 100%;
  max-width: 1020px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.6);
  position: relative;
}

/* Header */
.app-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-medium);
  background: rgba(14, 19, 29, 0.85);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 20;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-wrapper {
  width: 44px;
  height: 44px;
  background: var(--cf-orange-dim);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
}

.cf-logo {
  width: 28px;
  height: 28px;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.title-row h1 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.version-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--cf-orange);
  background: var(--cf-orange-dim);
  border: 1px solid var(--border-highlight);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.subtitle {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  transition: all 0.2s ease;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-success);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
  animation: pulse-ring 2s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

@keyframes pulse-ring {
  0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-action-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.icon-action-btn.danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.4);
}

/* Quick Troubleshoot Bar */
.troubleshoot-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  background: var(--bg-app);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
  white-space: nowrap;
}

.troubleshoot-bar::-webkit-scrollbar {
  height: 4px;
}

.troubleshoot-bar::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 4px;
}

.bar-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

.chips-container {
  display: flex;
  gap: 8px;
}

.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.chip:hover {
  background: var(--cf-orange-dim);
  color: var(--cf-orange);
  border-color: var(--border-highlight);
  transform: translateY(-1px);
}

.chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.chip-dot.warning { background: var(--color-warning); }
.chip-dot.danger { background: var(--color-danger); }
.chip-dot.info { background: var(--color-info); }
.chip-dot.purple { background: var(--color-purple); }
.chip-dot.teal { background: var(--color-teal); }
.chip-dot.success { background: var(--color-success); }

/* Messages Viewport */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

#messages::-webkit-scrollbar {
  width: 6px;
}

#messages::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 6px;
}

/* Hero Welcome Card */
.hero-welcome {
  background: linear-gradient(180deg, rgba(21, 28, 40, 0.9) 0%, rgba(14, 19, 29, 0.6) 100%);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.hero-welcome::before {
  content: "";
  position: absolute;
  top: -60px;
  right: -60px;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, var(--cf-orange-glow) 0%, transparent 70%);
  pointer-events: none;
}

.hero-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--cf-orange);
  background: var(--cf-orange-dim);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  margin-bottom: 12px;
  border: 1px solid var(--border-highlight);
}

.hero-welcome h2 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
  margin-bottom: 8px;
}

.hero-welcome p {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 680px;
  margin-bottom: 22px;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.feature-card {
  background: rgba(14, 19, 29, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  gap: 12px;
  transition: all 0.2s ease;
}

.feature-card:hover {
  border-color: var(--border-medium);
  background: var(--bg-card);
}

.feature-icon {
  font-size: 22px;
  flex-shrink: 0;
}

.feature-body h4 {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.feature-body p {
  font-size: 11px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
}

/* Chat Messages */
.message {
  max-width: 85%;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.65;
  animation: message-fade 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  word-wrap: break-word;
}

@keyframes message-fade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--cf-orange) 0%, #dc6608 100%);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(243, 128, 32, 0.35);
  font-weight: 500;
}

.message.assistant {
  align-self: flex-start;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-card);
}

.message.assistant.typing {
  color: var(--text-muted);
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 8px;
}

.message code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: rgba(0, 0, 0, 0.35);
  color: #fdba74;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.message pre {
  background: #090d14;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin: 12px 0;
  overflow-x: auto;
}

.message pre code {
  background: transparent;
  padding: 0;
  color: #f1f5f9;
  border: none;
  font-size: 12px;
}

.message ul, .message ol {
  margin: 10px 0 10px 20px;
}

.message li {
  margin-bottom: 4px;
}

.doc-citation {
  display: block;
  margin-top: 10px;
  padding: 8px 12px;
  background: rgba(243, 128, 32, 0.08);
  border-left: 3px solid var(--cf-orange);
  border-radius: 4px;
  font-size: 12px;
  color: #fbd38d;
}

.doc-citation a {
  color: var(--cf-orange);
  text-decoration: underline;
  word-break: break-all;
}

/* Footer / Input Area */
.app-footer {
  padding: 16px 24px;
  background: rgba(14, 19, 29, 0.95);
  border-top: 1px solid var(--border-medium);
  backdrop-filter: blur(16px);
}

.input-container {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 6px 8px 6px 16px;
  transition: all 0.2s ease;
}

.input-container:focus-within {
  border-color: var(--cf-orange);
  box-shadow: 0 0 0 3px var(--cf-orange-dim);
}

.input-icon {
  color: var(--text-muted);
  display: flex;
  align-items: center;
}

#input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  padding: 8px 0;
}

#input::placeholder {
  color: var(--text-muted);
}

#send-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  background: var(--cf-orange);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

#send-btn:hover:not(:disabled) {
  background: var(--cf-orange-hover);
  transform: translateY(-1px);
}

#send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.input-hints {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
  padding: 0 4px;
}

.input-hints strong {
  color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
  #app {
    border: none;
  }
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .header-right {
    width: 100%;
    justify-content: space-between;
  }
  .message {
    max-width: 92%;
  }
  .features-grid {
    grid-template-columns: 1fr;
  }
}
