/* Theme via CSS variables — override in your app */
.pragchat-root {
  --pragchat-bg: #f5f5f7;
  --pragchat-surface: #ffffff;
  --pragchat-text: #1d1d1f;
  --pragchat-muted: #6e6e73;
  --pragchat-accent: #007aff;
  --pragchat-border: rgba(0, 0, 0, 0.08);
  --pragchat-warn: #ff9500;
  --pragchat-danger: #ff3b30;
  font-family: var(--font-sans, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
  font-size: 15px;
  line-height: 1.35;
}

.pragchat-root[data-theme="dark"] {
  --pragchat-bg: #0b0f19;
  --pragchat-surface: rgba(18, 24, 38, 0.85);
  --pragchat-text: #f8fafc;
  --pragchat-muted: #94a3b8;
  --pragchat-accent: #6366f1;
  --pragchat-border: rgba(255, 255, 255, 0.1);
  --pragchat-warn: #f59e0b;
  --pragchat-danger: #ef4444;
}

.pragchat-panel {
  position: fixed;
  z-index: 99999;
  width: min(400px, 100vw - 32px);
  max-height: min(560px, 100vh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--pragchat-surface);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  color: var(--pragchat-text);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  border: 1px solid var(--pragchat-border);
  overflow: hidden;
}

.pragchat-panel[data-position="bottom-right"] {
  bottom: 24px;
  right: 24px;
}

.pragchat-panel[data-position="bottom-left"] {
  bottom: 24px;
  left: 24px;
}

.pragchat-header {
  padding: 12px 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--pragchat-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pragchat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--pragchat-bg);
}

.pragchat-message-shell {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.pragchat-message-shell[data-align="end"] {
  align-items: flex-end;
}

.pragchat-message-actions {
  display: flex;
  align-items: center;
}

.pragchat-message-actions[data-align="end"] {
  justify-content: flex-end;
}

.pragchat-bubble {
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--pragchat-surface);
  border: 1px solid var(--pragchat-border);
}

.pragchat-bubble-user {
  align-self: flex-end;
  background: var(--pragchat-accent);
  color: #fff;
  border: none;
}

.pragchat-data-table {
  width: 100%;
  font-size: 12px;
  border-collapse: collapse;
}

.pragchat-data-table th,
.pragchat-data-table td {
  border: 1px solid var(--pragchat-border);
  padding: 4px 6px;
  text-align: left;
  word-break: break-word;
}

.pragchat-warning {
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 149, 0, 0.12);
  color: var(--pragchat-warn);
  font-size: 13px;
}

.pragchat-warning[data-severity="high"] {
  background: rgba(255, 59, 48, 0.12);
  color: var(--pragchat-danger);
}

.pragchat-confirm {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pragchat-confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.pragchat-btn {
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 500;
  cursor: pointer;
  font-size: 14px;
}

.pragchat-btn-primary {
  background: var(--pragchat-accent);
  color: #fff;
}

.pragchat-btn-secondary {
  background: transparent;
  color: var(--pragchat-muted);
  border: 1px solid var(--pragchat-border);
}

.pragchat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--pragchat-border);
  background: var(--pragchat-surface);
}

.pragchat-input {
  flex: 1;
  border: 1px solid var(--pragchat-border);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  background: var(--pragchat-bg);
  color: var(--pragchat-text);
}

.pragchat-copy-btn {
  border: 1px solid var(--pragchat-border);
  border-radius: 999px;
  padding: 4px 10px;
  background: transparent;
  color: var(--pragchat-muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.pragchat-fab {
  position: fixed;
  z-index: 99998;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--pragchat-accent);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.pragchat-fab[data-position="bottom-right"] {
  bottom: 24px;
  right: 24px;
}

.pragchat-fab[data-position="bottom-left"] {
  bottom: 24px;
  left: 24px;
}

.pragchat-toast {
  font-size: 12px;
  color: var(--pragchat-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pragchat-empty,
.pragchat-loading,
.pragchat-status-row {
  margin: 0;
  color: var(--pragchat-muted);
  font-size: 13px;
}

.pragchat-status-row {
  padding: 0 12px 12px;
  background: var(--pragchat-surface);
}

.pragchat-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Star Fox Dialogue & Transmission Screen CSS */
.pragchat-transmission {
  background: #060a12;
  border-bottom: 2px solid var(--pragchat-border);
  padding: 12px 16px;
  display: flex;
  gap: 16px;
  align-items: center;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 16px rgba(0, 0, 0, 0.95);
  animation: pragchatCRTFlicker 0.15s infinite;
}

/* CRT Curved Vignette & Screen Overlay */
.pragchat-transmission::after {
  content: " ";
  display: block;
  position: absolute;
  top: 0; left: 0; bottom: 0; right: 0;
  background: radial-gradient(circle, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.75) 100%);
  pointer-events: none;
  z-index: 2;
}

/* CRT Screen Scanline Grid */
.pragchat-transmission::before {
  content: " ";
  display: block;
  position: absolute;
  top: 0; left: 0; bottom: 0; right: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.35) 50%), linear-gradient(90deg, rgba(0, 209, 255, 0.06), rgba(0, 255, 0, 0.02), rgba(255, 0, 0, 0.06));
  background-size: 100% 3px, 3px 100%;
  pointer-events: none;
  z-index: 2;
}

@keyframes pragchatCRTFlicker {
  0% { opacity: 0.985; }
  50% { opacity: 1.0; }
  100% { opacity: 0.985; }
}

.pragchat-retro-scanline {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: rgba(0, 209, 255, 0.18);
  box-shadow: 0 0 10px rgba(0, 209, 255, 0.35);
  animation: pragchatScanlineSweep 4.5s linear infinite;
  pointer-events: none;
  z-index: 3;
}

@keyframes pragchatScanlineSweep {
  0% { transform: translateY(-100px); }
  100% { transform: translateY(220px); }
}

.pragchat-avatar-frame {
  position: relative;
  width: 135px;
  height: 90px;
  border: 2px solid #3b82f6;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
  background: #040810;
  flex-shrink: 0;
}

.pragchat-avatar-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pragchat-meta-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 1;
}

.pragchat-meta-status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pragchat-meta-status {
  font-size: 10px;
  color: #64748b;
  font-family: monospace;
  font-weight: bold;
  letter-spacing: 1px;
}

.pragchat-meta-status[data-active="true"] {
  color: #10b981;
}

.pragchat-audio-bars {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  height: 8px;
}

.pragchat-audio-bar {
  width: 2px;
  height: 2px;
  background: #10b981;
  box-shadow: 0 0 4px #10b981;
  animation: pragchatAudioPulse 0.4s infinite ease-in-out;
}

@keyframes pragchatAudioPulse {
  0%, 100% { height: 2px; }
  50% { height: 10px; }
}

.pragchat-meta-title {
  font-size: 12px;
  font-weight: 800;
  color: #e2e8f0;
  margin: 2px 0 0;
  font-family: monospace;
}

.pragchat-meta-location {
  font-size: 9px;
  color: #3b82f6;
  font-family: monospace;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Inline Layout overrides for dashboard embedding */
.pragchat-root.pragchat-inline {
  position: relative !important;
  inset: auto !important;
  pointer-events: auto !important;
  width: 100%;
  height: 100%;
}

.pragchat-panel.pragchat-inline {
  position: relative !important;
  inset: auto !important;
  width: 100% !important;
  height: 100% !important;
  max-height: none !important;
  box-shadow: none !important;
  border: none !important;
}

.pragchat-sound-toggle:hover,
.pragchat-music-toggle:hover {
  opacity: 1 !important;
  transform: scale(1.2);
}

@keyframes pragchatWave {
  0%, 100% {
    height: 12px;
  }
  50% {
    height: 36px;
  }
}
