/* ============================================================================
   Calera ICX — VLN Infinite Context Bridge V2 UI Stylesheet
   Theme: Premium Light-Mode Glassmorphism
   ============================================================================ */

:root {
  /* Light Theme Color Palette */
  --bg-dark: #f8fafc;
  --bg-surface: rgba(255, 255, 255, 0.85);
  --bg-surface-elevated: #ffffff;
  --bg-card: rgba(241, 245, 249, 0.8);
  --bg-input: #ffffff;
  
  --border-subtle: #e2e8f0;
  --border-bright: #cbd5e1;
  --border-glow: rgba(2, 132, 199, 0.35);

  --accent-cyan: #0284c7;
  --accent-indigo: #4f46e5;
  --accent-purple: #7c3aed;
  --accent-green: #16a34a;
  --accent-amber: #d97706;
  --accent-red: #dc2626;

  --gradient-primary: linear-gradient(135deg, #0284c7 0%, #4f46e5 100%);
  --gradient-glow: linear-gradient(135deg, rgba(2, 132, 199, 0.1) 0%, rgba(79, 70, 229, 0.1) 100%);

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;

  /* Fonts */
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Fira Code', monospace;

  /* Dimensions & Shadows */
  --header-height: 64px;
  --sidebar-width: 340px;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --shadow-glass: 0 4px 20px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.06), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Background Gradients & Soft Radial Highlights */
body::before {
  content: '';
  position: absolute;
  top: -10%;
  left: -10%;
  width: 50vw;
  height: 50vw;
  background: radial-gradient(circle, rgba(2, 132, 199, 0.06) 0%, rgba(248, 250, 252, 0) 70%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: absolute;
  bottom: -10%;
  right: -10%;
  width: 50vw;
  height: 50vw;
  background: radial-gradient(circle, rgba(79, 70, 229, 0.06) 0%, rgba(248, 250, 252, 0) 70%);
  pointer-events: none;
  z-index: 0;
}

/* Header & Navigation Bar */
.app-header {
  position: relative;
  z-index: 10;
  height: var(--header-height);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-glass);
}

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

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 132, 199, 0.08);
  border: 1px solid rgba(2, 132, 199, 0.2);
  border-radius: var(--radius-md);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.company-name {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--accent-cyan);
}

.product-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.version-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(79, 70, 229, 0.1);
  color: var(--accent-indigo);
  border: 1px solid rgba(79, 70, 229, 0.25);
}

/* System Status Bar */
.system-status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(241, 245, 249, 0.9);
  padding: 6px 16px;
  border-radius: 30px;
  border: 1px solid var(--border-subtle);
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-ready {
  background: #dcfce7;
  color: var(--accent-green);
  border: 1px solid rgba(22, 163, 74, 0.25);
}
.status-ready .status-dot {
  background: var(--accent-green);
  box-shadow: 0 0 6px var(--accent-green);
}

.status-initializing {
  background: #fef3c7;
  color: var(--accent-amber);
  border: 1px solid rgba(217, 119, 6, 0.25);
}
.status-initializing .status-dot {
  background: var(--accent-amber);
  animation: pulse 1.5s infinite;
}

.status-error {
  background: #fee2e2;
  color: var(--accent-red);
  border: 1px solid rgba(220, 38, 38, 0.25);
}
.status-error .status-dot {
  background: var(--accent-red);
}

.status-neutral {
  background: #e2e8f0;
  color: var(--text-muted);
  border: 1px solid var(--border-bright);
}
.status-neutral .status-dot {
  background: var(--text-muted);
}

@keyframes pulse {
  0% { opacity: 0.4; }
  50% { opacity: 1.0; }
  100% { opacity: 0.4; }
}

.metric-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.chip-label {
  color: var(--text-dim);
  font-size: 9px;
  letter-spacing: 0.5px;
}

.chip-val {
  color: var(--accent-cyan);
  font-weight: 600;
}

/* Header Right Controls */
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.btn-primary {
  background: var(--gradient-primary);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.25);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.35);
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-main);
  border-color: var(--border-bright);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.btn-secondary:hover {
  background: #f1f5f9;
  border-color: var(--accent-cyan);
}

.btn-secondary-outline {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border-subtle);
}
.btn-secondary-outline:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-main);
  border-color: var(--border-bright);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  background: #ffffff;
  color: var(--text-muted);
  border-color: var(--border-subtle);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.btn-icon:hover, .btn-icon.active {
  background: rgba(2, 132, 199, 0.08);
  color: var(--accent-cyan);
  border-color: rgba(2, 132, 199, 0.3);
}

.btn-icon-subtle {
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  color: var(--text-dim);
  border: none;
  border-radius: var(--radius-sm);
}
.btn-icon-subtle:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-main);
}

/* App Layout Grid */
.app-layout {
  position: relative;
  z-index: 1;
  height: calc(100vh - var(--header-height));
  display: flex;
  overflow: hidden;
}

/* Main Chat Container */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* Welcome Card */
.welcome-card {
  max-width: 680px;
  margin: 40px auto;
  text-align: center;
  padding: 36px 32px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.welcome-icon {
  margin-bottom: 16px;
  display: inline-flex;
}

.welcome-card h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-main);
}

.welcome-card p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  text-align: left;
}

.feature-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 16px;
  border-radius: var(--radius-md);
}

.feature-tag {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-cyan);
  letter-spacing: 0.5px;
}

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

/* Message Rows */
.msg-row {
  display: flex;
  gap: 14px;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}

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

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 700;
  font-size: 13px;
}

.msg-row.user .msg-avatar {
  background: var(--gradient-primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
}

.msg-row.assistant .msg-avatar {
  background: rgba(2, 132, 199, 0.1);
  border: 1px solid rgba(2, 132, 199, 0.25);
  color: var(--accent-cyan);
}

.msg-bubble {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 75%;
}

.msg-content {
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.6;
}

.msg-row.user .msg-content {
  background: var(--gradient-primary);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.2);
  border-top-right-radius: 4px;
}

.msg-row.user .msg-content strong {
  color: #ffffff;
}

.msg-row.assistant .msg-content {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  box-shadow: var(--shadow-glass);
  border-top-left-radius: 4px;
}

/* Markdown formatting inside messages */
.msg-content p {
  margin-bottom: 10px;
}
.msg-content p:last-child {
  margin-bottom: 0;
}
.msg-content strong {
  color: var(--accent-cyan);
}
.msg-content code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  color: #0f172a;
}
.msg-content pre {
  margin: 10px 0;
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-md);
  padding: 12px;
  overflow-x: auto;
  position: relative;
}
.msg-content pre code {
  background: transparent;
  padding: 0;
  border: none;
  font-size: 12.5px;
  color: #f8fafc;
}

/* Turn Metadata Footer Badge */
.msg-meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  padding: 0 4px;
}

.meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  background: #f1f5f9;
  border: 1px solid var(--border-subtle);
  font-size: 10px;
  color: var(--text-muted);
}

.meta-badge.highlight {
  color: var(--accent-cyan);
  background: rgba(2, 132, 199, 0.08);
  border-color: rgba(2, 132, 199, 0.25);
}

/* System Messages */
.msg-row.system {
  justify-content: center;
  max-width: 100%;
}
.msg-row.system .msg-content {
  background: rgba(2, 132, 199, 0.08);
  border: 1px solid rgba(2, 132, 199, 0.2);
  color: var(--accent-cyan);
  font-size: 12px;
  padding: 8px 16px;
  border-radius: 20px;
}

/* Sticky Input Area */
.input-container {
  padding: 16px 24px 24px 24px;
  background: linear-gradient(to top, var(--bg-dark) 80%, rgba(248, 250, 252, 0));
}

.chat-form {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #ffffff;
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-form:focus-within {
  border-color: var(--accent-cyan);
  box-shadow: 0 10px 30px rgba(2, 132, 199, 0.15);
}

.form-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
}

.toggle-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.toggle-switch input {
  display: none;
}

.toggle-slider {
  width: 32px;
  height: 18px;
  background: #cbd5e1;
  border-radius: 10px;
  position: relative;
  transition: background 0.2s ease;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent-cyan);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(14px);
}

.toggle-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.toolbar-hint {
  font-size: 11px;
  color: var(--text-dim);
}

.toolbar-hint code {
  font-family: var(--font-mono);
  background: #f1f5f9;
  padding: 1px 4px;
  border-radius: 3px;
  color: var(--text-muted);
}

.input-box-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding-top: 4px;
}

#user-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  max-height: 160px;
  min-height: 24px;
}

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

.input-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-send {
  height: 36px;
  padding: 0 16px;
}

/* Telemetry Sidebar */
.telemetry-sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background: #ffffff;
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.03);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.telemetry-sidebar.collapsed {
  transform: translateX(100%);
  position: absolute;
  right: 0;
}

.sidebar-header {
  height: 56px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-header h3 {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.telemetry-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
}

.card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-item.full-width {
  grid-column: span 2;
}

.stat-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
}

.stat-value.highlight {
  color: var(--accent-cyan);
}

.stat-value-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.font-mono {
  font-family: var(--font-mono);
}

/* Progress Bar */
.progress-bar-container {
  width: 100%;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
  margin: 4px 0;
}

.progress-bar {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-card {
  width: 100%;
  max-width: 580px;
  background: #ffffff;
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.12);
  padding: 24px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-main);
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.form-group input,
.form-group textarea {
  background: #f8fafc;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s ease;
}

.form-group textarea {
  font-family: var(--font-mono);
  font-size: 12.5px;
  resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--accent-cyan);
  background: #ffffff;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 10px;
}

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

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--accent-cyan);
  border-radius: 50%;
  animation: typingBounce 1.2s infinite ease-in-out;
}

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

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* Toast Notifications */
.toast-notification {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 150;
  background: #ffffff;
  border: 1px solid var(--accent-cyan);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  color: var(--text-main);
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
