/*
 * ChatCMMC — Jun Cyber Design System
 * Brand Colors: Deep Purple + Vibrant Orange
 * ─────────────────────────────────────────
 */

/* ── Google Fonts ──────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Custom Properties ─────────────── */
:root {
  /* Jun Cyber Brand */
  --jc-purple-deep: #0f0520;
  --jc-purple-dark: #1a0a2e;
  --jc-purple-primary: #4c1c71;
  --jc-purple-mid: #2d1250;
  --jc-purple-light: #6b3fa0;
  --jc-purple-glow: rgba(107, 63, 160, 0.3);

  --jc-orange: #ff7a00;
  --jc-orange-hover: #ff9233;
  --jc-orange-glow: rgba(255, 122, 0, 0.25);
  --jc-orange-bright: #ff9233;

  --jc-white: #ffffff;
  --jc-gray-50: #fafafa;
  --jc-gray-100: #f5f5f7;
  --jc-gray-200: #e5e5ea;
  --jc-gray-300: #d1d1d6;
  --jc-gray-500: #8e8e93;
  --jc-gray-700: #48484a;
  --jc-gray-900: #1c1c1e;
  --jc-gray-400: #aeaeb2;
  --jc-gray-600: #636366;

  /* Layout */
  --max-chat-width: 840px;
  --header-height: 64px;
  --input-area-height: auto;
  --border-radius: 16px;
  --border-radius-sm: 10px;
  --border-radius-xs: 6px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.12);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.15);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.25);
  --shadow-glow-orange: 0 0 20px var(--jc-orange-glow);
  --shadow-glow-purple: 0 0 30px var(--jc-purple-glow);

  /* Glass / Landing */
  --glass-bg: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.08);
}

/* ── Reset & Base ──────────────────────── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: linear-gradient(170deg, var(--jc-purple-deep) 0%, var(--jc-purple-dark) 40%, #12062a 100%);
  color: var(--jc-white);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Custom Scrollbar ──────────────────── */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--jc-purple-light);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--jc-orange);
}

/* ── Disclaimer Banner ─────────────────── */
.disclaimer-banner {
  background: linear-gradient(90deg, var(--jc-purple-primary), var(--jc-purple-mid));
  padding: 8px 20px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 400;
  color: rgba(255,255,255,0.85);
  letter-spacing: 0.02em;
  line-height: 1.5;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.disclaimer-banner strong {
  color: var(--jc-orange);
  font-weight: 600;
}

/* ── Header ────────────────────────────── */
.app-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(15, 5, 32, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
  z-index: 100;
}

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

.header-logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--jc-orange), var(--jc-purple-light));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  color: var(--jc-white);
  box-shadow: var(--shadow-glow-orange);
}

.header-title {
  display: flex;
  flex-direction: column;
}

.header-title h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.header-title span {
  font-size: 0.7rem;
  color: var(--jc-gray-500);
  font-weight: 400;
  letter-spacing: 0.03em;
}

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

.header-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  font-size: 0.72rem;
  color: var(--jc-gray-500);
  font-weight: 500;
  transition: var(--transition-fast);
}

.header-badge:hover {
  background: rgba(255,255,255,0.08);
  color: var(--jc-white);
}

.status-dot {
  width: 6px;
  height: 6px;
  background: #34c759;
  border-radius: 50%;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.header-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: linear-gradient(135deg, var(--jc-orange), #e86e00);
  color: var(--jc-white);
  text-decoration: none;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  transition: var(--transition-fast);
  box-shadow: var(--shadow-glow-orange);
}

.header-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 30px var(--jc-orange-glow);
}

/* ── Chat Container ────────────────────── */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: var(--max-chat-width);
  width: 100%;
  margin: 0 auto;
  padding: 0 16px;
  overflow: hidden;
  min-height: 0;
}

/* ── Messages Area ─────────────────────── */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

/* ── Welcome Section ───────────────────── */
.welcome-section {
  text-align: center;
  padding: 48px 20px 32px;
  animation: fadeInUp 0.6s ease-out;
}

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

.welcome-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  background: linear-gradient(135deg, var(--jc-orange), var(--jc-purple-light));
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  box-shadow: var(--shadow-glow-orange);
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.welcome-section h2 {
  font-size: 1.65rem;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--jc-white), var(--jc-gray-300));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-section p {
  font-size: 0.92rem;
  color: var(--jc-gray-500);
  max-width: 520px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ── Suggested Questions ───────────────── */
.suggested-questions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 16px 0 8px;
  animation: fadeInUp 0.6s ease-out 0.2s both;
}

.suggested-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 24px;
  color: var(--jc-gray-300);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.suggested-chip:hover {
  background: rgba(255, 122, 0, 0.1);
  border-color: var(--jc-orange);
  color: var(--jc-orange);
  transform: translateY(-1px);
}

.suggested-chip .chip-icon {
  font-size: 0.9rem;
}

/* ── Message Bubbles ───────────────────── */
.message {
  display: flex;
  gap: 12px;
  padding: 4px 0;
  animation: messageSlide 0.3s ease-out;
}

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

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  margin-top: 2px;
}

.message.user .message-avatar {
  background: linear-gradient(135deg, var(--jc-purple-light), var(--jc-purple-primary));
  order: 2;
}

.message.bot .message-avatar {
  background: linear-gradient(135deg, var(--jc-orange), #e86e00);
  box-shadow: 0 0 12px var(--jc-orange-glow);
}

.message-content {
  flex: 1;
  max-width: calc(100% - 50px);
}

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

.message.user .message-bubble {
  background: var(--jc-purple-mid);
  border: 1px solid rgba(107, 63, 160, 0.3);
  border-radius: var(--border-radius) var(--border-radius-xs) var(--border-radius) var(--border-radius);
  color: var(--jc-white);
}

.message.bot .message-bubble {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--border-radius-xs) var(--border-radius) var(--border-radius) var(--border-radius);
  color: var(--jc-gray-100);
}

.message-bubble {
  padding: 14px 18px;
  font-size: 0.9rem;
  line-height: 1.65;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* ── Markdown Styles in Messages ───────── */
.message-bubble h1,
.message-bubble h2,
.message-bubble h3 {
  margin: 12px 0 6px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.message-bubble h1 { font-size: 1.15rem; }
.message-bubble h2 { font-size: 1.05rem; }
.message-bubble h3 { font-size: 0.95rem; color: var(--jc-orange); }

.message-bubble p {
  margin: 6px 0;
}

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

.message-bubble li {
  margin: 4px 0;
}

.message-bubble strong {
  color: var(--jc-orange);
  font-weight: 600;
}

.message-bubble code {
  background: rgba(255,255,255,0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 0.85em;
}

.message-bubble pre {
  background: rgba(0,0,0,0.3);
  padding: 12px 16px;
  border-radius: var(--border-radius-xs);
  overflow-x: auto;
  margin: 8px 0;
}

.message-bubble pre code {
  background: none;
  padding: 0;
}

.message-bubble a {
  color: var(--jc-orange);
  text-decoration: none;
}

.message-bubble a:hover {
  text-decoration: underline;
}

.message-bubble blockquote {
  border-left: 3px solid var(--jc-orange);
  padding-left: 12px;
  margin: 8px 0;
  color: var(--jc-gray-300);
  font-style: italic;
}

/* ── Sources Citation ──────────────────── */
.message-sources {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.sources-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--jc-gray-500);
  cursor: pointer;
  padding: 4px 0;
  transition: var(--transition-fast);
  background: none;
  border: none;
  font-family: inherit;
}

.sources-toggle:hover {
  color: var(--jc-orange);
}

.sources-list {
  display: none;
  margin-top: 6px;
  padding: 8px 12px;
  background: rgba(0,0,0,0.2);
  border-radius: var(--border-radius-xs);
}

.sources-list.expanded {
  display: block;
  animation: fadeInUp 0.2s ease-out;
}

.sources-list .source-item {
  font-size: 0.75rem;
  color: var(--jc-gray-500);
  padding: 3px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.source-item::before {
  content: '📄';
  font-size: 0.7rem;
}

/* ── Typing Indicator ──────────────────── */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 0;
  align-items: center;
}

.typing-indicator .dot {
  width: 7px;
  height: 7px;
  background: var(--jc-purple-light);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-indicator .dot:nth-child(1) { animation-delay: 0s; }
.typing-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; background: var(--jc-orange); }
}

/* ── Input Area ────────────────────────── */
.input-area {
  padding: 12px 0 20px;
  flex-shrink: 0;
}

.input-container {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--border-radius);
  padding: 10px 12px 10px 18px;
  transition: var(--transition-fast);
}

.input-container:focus-within {
  border-color: var(--jc-orange);
  box-shadow: var(--shadow-glow-orange);
  background: rgba(255,255,255,0.06);
}

#chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--jc-white);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  line-height: 1.5;
  resize: none;
  max-height: 120px;
  min-height: 24px;
  padding: 4px 0;
}

#chat-input::placeholder {
  color: var(--jc-gray-500);
}

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--jc-orange), #e86e00);
  color: var(--jc-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
  flex-shrink: 0;
  font-size: 18px;
}

.send-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: var(--shadow-glow-orange);
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

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

.input-hint {
  text-align: center;
  padding-top: 8px;
  font-size: 0.7rem;
  color: var(--jc-gray-700);
}

/* ── Footer ────────────────────────────── */
.app-footer {
  padding: 12px 24px;
  text-align: center;
  font-size: 0.72rem;
  color: var(--jc-gray-700);
  border-top: 1px solid rgba(255,255,255,0.04);
  flex-shrink: 0;
}

.app-footer a {
  color: var(--jc-gray-500);
  text-decoration: none;
  transition: var(--transition-fast);
}

.app-footer a:hover {
  color: var(--jc-orange);
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 6px;
}

/* ── Disclaimer Modal ──────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: linear-gradient(170deg, var(--jc-purple-dark), var(--jc-purple-deep));
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 36px;
  max-width: 520px;
  width: 90%;
  box-shadow: var(--shadow-lg), var(--shadow-glow-purple);
  animation: modalSlide 0.4s ease-out;
}

@keyframes modalSlide {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal p {
  font-size: 0.88rem;
  color: var(--jc-gray-300);
  line-height: 1.7;
  margin-bottom: 12px;
}

.modal .highlight {
  color: var(--jc-orange);
  font-weight: 600;
}

.modal-accept-btn {
  width: 100%;
  padding: 14px;
  margin-top: 20px;
  background: linear-gradient(135deg, var(--jc-orange), #e86e00);
  color: var(--jc-white);
  border: none;
  border-radius: 12px;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.modal-accept-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow-orange);
}

/* ── Lead Capture Form ─────────────────── */
.lead-modal {
  max-width: 480px;
}

.form-group {
  margin-bottom: 12px;
}

.lead-input {
  width: 100%;
  padding: 13px 16px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  color: var(--jc-white);
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  transition: var(--transition-fast);
  outline: none;
}

.lead-input:focus {
  border-color: var(--jc-orange);
  background: rgba(255,255,255,0.08);
  box-shadow: 0 0 12px var(--jc-orange-glow);
}

.lead-input::placeholder {
  color: var(--jc-gray-500);
}

.lead-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  cursor: pointer;
}

.lead-select option {
  background: var(--jc-purple-dark);
  color: var(--jc-white);
}

.lead-error {
  margin-top: 8px;
  padding: 10px 14px;
  background: rgba(255, 59, 48, 0.15);
  border: 1px solid rgba(255, 59, 48, 0.3);
  border-radius: 8px;
  color: #ff6b6b;
  font-size: 0.8rem;
  text-align: center;
}

.lead-error.hidden {
  display: none;
}

.lead-skip {
  display: block;
  width: 100%;
  padding: 10px;
  margin-top: 10px;
  background: none;
  border: none;
  color: var(--jc-gray-500);
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  cursor: pointer;
  transition: var(--transition-fast);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.lead-skip:hover {
  color: var(--jc-gray-300);
}

.lead-privacy {
  font-size: 0.72rem !important;
  color: var(--jc-gray-700) !important;
  text-align: center;
  margin-top: 16px !important;
  margin-bottom: 0 !important;
  line-height: 1.5 !important;
}

/* ── Responsive ────────────────────────── */
@media (max-width: 768px) {
  .app-header {
    padding: 0 14px;
  }

  .header-cta {
    display: none;
  }

  .header-badge {
    font-size: 0.68rem;
    padding: 5px 10px;
  }

  .welcome-section {
    padding: 32px 12px 20px;
  }

  .welcome-section h2 {
    font-size: 1.3rem;
  }

  .suggested-questions {
    flex-direction: column;
    align-items: center;
  }

  .chat-container {
    padding: 0 8px;
  }

  .message-bubble {
    padding: 12px 14px;
    font-size: 0.87rem;
  }

  .disclaimer-banner {
    font-size: 0.68rem;
    padding: 6px 12px;
  }
}

@media (max-width: 480px) {
  .header-badge {
    display: none;
  }

  .header-logo {
    width: 30px;
    height: 30px;
    font-size: 13px;
    border-radius: 8px;
  }

  .header-title h1 {
    font-size: 1rem;
  }

  .welcome-icon {
    width: 56px;
    height: 56px;
    font-size: 24px;
    border-radius: 16px;
  }
}
