/* ═══════════════════════════════════════════════════════
   PRYSM — Global Custom Styles
   ═══════════════════════════════════════════════════════ */

/* ── Toolbar Buttons ── */
.toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  border-radius: 6px;
  color: #94a3b8;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  font-size: 13px;
  padding: 0 4px;
  white-space: nowrap;
}
.toolbar-btn:hover {
  background: rgba(255,255,255,0.07);
  color: #f8fafc;
}
.toolbar-btn.active {
  background: rgba(99,102,241,0.2);
  color: #818cf8;
}
.toolbar-select {
  background: #0a0a0f;
  border: 1px solid #1e1e2e;
  color: #94a3b8;
  border-radius: 6px;
  font-size: 12px;
  padding: 3px 4px;
  height: 28px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}
.toolbar-select:hover, .toolbar-select:focus {
  border-color: rgba(99,102,241,0.4);
  color: #f8fafc;
}
.toolbar-divider {
  width: 1px;
  height: 20px;
  background: #1e1e2e;
  margin: 0 4px;
  flex-shrink: 0;
}

/* ── Sheet Tabs ── */
.sheet-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  font-size: 12px;
  color: #64748b;
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
  user-select: none;
  position: relative;
}
.sheet-tab:hover {
  background: rgba(255,255,255,0.05);
  color: #94a3b8;
}
.sheet-tab.active {
  background: #0a0a0f;
  color: #f8fafc;
  font-weight: 500;
}
.sheet-tab .tab-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2a3e; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a4e; }

/* ── Code Editor (CodeMirror) ── */
.cm-editor {
  height: 100%;
  font-size: 13px;
}
.cm-editor .cm-content {
  font-family: 'Fira Code', 'JetBrains Mono', 'Cascadia Code', monospace;
  caret-color: #818cf8;
  padding: 12px 0;
}
.cm-editor.cm-focused .cm-cursor { border-left-color: #6366f1; }
.cm-editor .cm-activeLine { background: rgba(99,102,241,0.06); }
.cm-editor .cm-activeLineGutter { background: rgba(99,102,241,0.06); }
.cm-editor .cm-gutters {
  background: #0d0d14;
  border-right: 1px solid #1e1e2e;
  color: #475569;
}
.cm-editor .cm-gutter { min-width: 40px; }
.cm-editor .cm-lineNumbers .cm-gutterElement { padding: 0 12px; }
.cm-selectionBackground, ::selection { background: rgba(99,102,241,0.25) !important; }
.cm-matchingBracket { color: #a78bfa !important; font-weight: bold; }

/* ── Mapping Canvas ── */
#mappingCanvas {
  position: relative;
  overflow: hidden;
  flex: 1;
}
.mapping-field-row {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.1s;
  color: #94a3b8;
  border: 1px solid transparent;
}
.mapping-field-row:hover {
  background: rgba(99,102,241,0.08);
  color: #f8fafc;
}
.mapping-field-row.connected {
  color: #10b981;
  border-color: rgba(16,185,129,0.2);
}
.mapping-field-row.connected-error {
  color: #ef4444;
  border-color: rgba(239,68,68,0.2);
}
.mapping-connector-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #475569;
  cursor: crosshair;
  flex-shrink: 0;
  transition: background 0.1s, transform 0.1s;
}
.mapping-connector-dot:hover, .mapping-connector-dot.active {
  background: #6366f1;
  transform: scale(1.3);
}

/* ── AI Chat ── */
.chat-message {
  max-width: 85%;
  animation: fadeIn 0.2s ease;
}
.chat-message.user {
  margin-left: auto;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  border-radius: 16px 16px 4px 16px;
  padding: 10px 14px;
}
.chat-message.assistant {
  background: #1a1a24;
  border: 1px solid #1e1e2e;
  color: #e2e8f0;
  border-radius: 4px 16px 16px 16px;
  padding: 12px 16px;
}
.chat-message pre {
  background: #0a0a0f;
  border: 1px solid #1e1e2e;
  border-radius: 8px;
  padding: 12px;
  margin: 8px 0;
  overflow-x: auto;
}
.chat-message code {
  font-family: 'Fira Code', monospace;
  font-size: 12px;
}
.chat-message p { margin: 0 0 8px; }
.chat-message p:last-child { margin-bottom: 0; }
.chat-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: #6366f1;
  animation: blink 1s infinite;
  vertical-align: text-bottom;
  margin-left: 2px;
}
@keyframes blink { 0%,50% { opacity: 1; } 51%,100% { opacity: 0; } }

/* ── Doc Editor ── */
.doc-editor-toolbar button {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  transition: background 0.1s, color 0.1s;
  font-size: 13px;
  cursor: pointer;
  background: transparent;
  border: none;
}
.doc-editor-toolbar button:hover { background: rgba(255,255,255,0.07); color: #f8fafc; }
.doc-editor-toolbar button.active { background: rgba(99,102,241,0.2); color: #818cf8; }
.markdown-preview h1 { font-size: 1.75rem; font-weight: 700; color: #f8fafc; margin: 1.5rem 0 0.75rem; }
.markdown-preview h2 { font-size: 1.4rem; font-weight: 600; color: #f8fafc; margin: 1.25rem 0 0.5rem; border-bottom: 1px solid #1e1e2e; padding-bottom: 0.5rem; }
.markdown-preview h3 { font-size: 1.15rem; font-weight: 600; color: #e2e8f0; margin: 1rem 0 0.5rem; }
.markdown-preview p { color: #94a3b8; margin: 0.75rem 0; line-height: 1.7; }
.markdown-preview ul, .markdown-preview ol { color: #94a3b8; margin: 0.75rem 0; padding-left: 1.5rem; }
.markdown-preview li { margin: 0.25rem 0; }
.markdown-preview code { background: #0a0a0f; border: 1px solid #1e1e2e; border-radius: 4px; padding: 2px 5px; font-family: monospace; font-size: 0.875em; color: #a78bfa; }
.markdown-preview pre { background: #0a0a0f; border: 1px solid #1e1e2e; border-radius: 10px; padding: 16px; margin: 1rem 0; overflow-x: auto; }
.markdown-preview pre code { background: none; border: none; padding: 0; color: #e2e8f0; }
.markdown-preview blockquote { border-left: 3px solid #6366f1; padding: 4px 16px; margin: 1rem 0; color: #64748b; }
.markdown-preview table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
.markdown-preview th { background: #1a1a24; color: #f8fafc; padding: 8px 12px; text-align: left; border: 1px solid #1e1e2e; font-size: 13px; }
.markdown-preview td { padding: 8px 12px; border: 1px solid #1e1e2e; color: #94a3b8; font-size: 13px; }
.markdown-preview a { color: #6366f1; text-decoration: underline; }
.markdown-preview strong { color: #f8fafc; font-weight: 600; }
.markdown-preview hr { border: 0; border-top: 1px solid #1e1e2e; margin: 1.5rem 0; }

/* ── Graph Editor ── */
.data-panel-section {
  border-bottom: 1px solid #1e1e2e;
  padding: 12px;
}
.data-panel-section:last-child { border-bottom: none; }
.axis-drop-zone {
  border: 2px dashed #1e1e2e;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: #475569;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.axis-drop-zone.dragover, .axis-drop-zone:hover {
  border-color: rgba(99,102,241,0.4);
  background: rgba(99,102,241,0.05);
  color: #94a3b8;
}
.axis-drop-zone.has-value {
  border-color: rgba(99,102,241,0.3);
  background: rgba(99,102,241,0.08);
  color: #818cf8;
}

/* ── Contract Editor ── */
.rule-row {
  background: #0a0a0f;
  border: 1px solid #1e1e2e;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
  transition: border-color 0.15s;
}
.rule-row:hover { border-color: rgba(99,102,241,0.3); }
.rule-row-handle {
  cursor: grab;
  color: #475569;
  padding: 0 4px;
}
.rule-row-handle:active { cursor: grabbing; }

/* ── Status Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-active   { background: rgba(16,185,129,0.15); color: #34d399; border: 1px solid rgba(16,185,129,0.2); }
.badge-draft    { background: rgba(71,85,105,0.3); color: #94a3b8; border: 1px solid rgba(71,85,105,0.3); }
.badge-paused   { background: rgba(245,158,11,0.15); color: #fbbf24; border: 1px solid rgba(245,158,11,0.2); }
.badge-archived { background: rgba(239,68,68,0.1); color: #f87171; border: 1px solid rgba(239,68,68,0.2); }
.badge-error    { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.2); }
.badge-success  { background: rgba(16,185,129,0.15); color: #34d399; border: 1px solid rgba(16,185,129,0.2); }
.badge-warning  { background: rgba(245,158,11,0.15); color: #fbbf24; border: 1px solid rgba(245,158,11,0.2); }
.badge-info     { background: rgba(99,102,241,0.15); color: #818cf8; border: 1px solid rgba(99,102,241,0.2); }

/* ── Language Badges ── */
.lang-python     { background: rgba(59,130,246,0.15); color: #93c5fd; }
.lang-javascript { background: rgba(234,179,8,0.15); color: #fde68a; }
.lang-sql        { background: rgba(249,115,22,0.15); color: #fdba74; }
.lang-php        { background: rgba(168,85,247,0.15); color: #d8b4fe; }
.lang-r          { background: rgba(20,184,166,0.15); color: #5eead4; }
.lang-bash       { background: rgba(34,197,94,0.15); color: #86efac; }
.lang-java       { background: rgba(239,68,68,0.15); color: #fca5a5; }
.lang-cpp        { background: rgba(99,102,241,0.15); color: #a5b4fc; }
.lang-julia      { background: rgba(236,72,153,0.15); color: #f9a8d4; }

/* ── Animations ── */
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 8px rgba(99,102,241,0.3); }
  50% { box-shadow: 0 0 20px rgba(99,102,241,0.6); }
}
.pulse-glow { animation: pulse-glow 2s infinite; }

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, #1a1a24 25%, #232334 50%, #1a1a24 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}

/* ── Utilities ── */
.truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.gradient-text {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.glass {
  background: rgba(19,19,26,0.8);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(30,30,46,0.8);
}

/* ── File Upload Dropzone ── */
.upload-zone {
  border: 2px dashed #1e1e2e;
  border-radius: 16px;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: rgba(99,102,241,0.5);
  background: rgba(99,102,241,0.04);
}

/* ── Progress Bar ── */
.progress-bar { background: #1e1e2e; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #6366f1, #8b5cf6); transition: width 0.3s ease; }

/* ── Connections ── */
.connection-card { transition: border-color 0.15s, box-shadow 0.15s; }
.connection-card:hover { border-color: rgba(99,102,241,0.3); box-shadow: 0 0 20px rgba(99,102,241,0.06); }
.conn-type-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }

/* ── Toast Notifications ── */
.toast {
  background: #1a1a24;
  border: 1px solid #1e1e2e;
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  max-width: 380px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  pointer-events: all;
  animation: slideInRight 0.2s ease;
  cursor: pointer;
  transition: opacity 0.2s;
}
.toast.hiding { opacity: 0; transform: translateX(20px); transition: opacity 0.2s, transform 0.2s; }
.toast-icon { width: 18px; height: 18px; flex-shrink: 0; }
.toast-message { flex: 1; font-size: 13px; color: #e2e8f0; }
.toast-close { color: #475569; flex-shrink: 0; cursor: pointer; }
.toast-close:hover { color: #94a3b8; }
.toast.success { border-color: rgba(16,185,129,0.3); }
.toast.success .toast-icon { color: #10b981; }
.toast.error   { border-color: rgba(239,68,68,0.3); }
.toast.error   .toast-icon { color: #ef4444; }
.toast.warning { border-color: rgba(245,158,11,0.3); }
.toast.warning .toast-icon { color: #f59e0b; }
.toast.info    { border-color: rgba(99,102,241,0.3); }
.toast.info    .toast-icon { color: #6366f1; }
.toast.loading { border-color: rgba(99,102,241,0.3); }
.toast.loading .toast-icon { color: #6366f1; animation: spin 0.8s linear infinite; }

@keyframes slideInRight { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
