/* =====================================================
   Flock Agent UI — Global Styles
   ===================================================== */

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

/* --- Reset & base --- */
*, *::before, *::after {
  box-sizing: border-box;
}

body, input, button, select, textarea {
  font-family: 'Inter', 'PingFang SC', 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}

:root {
  font-family: 'Inter', 'PingFang SC', 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.5;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Light theme (default) ---- */
[data-theme="light"] {
  color-scheme: light;
  --flock-bg-deepest: #f2f4f7;
  --flock-bg-deep: rgba(242, 244, 247, 0.9);
  --flock-bg-base: #ffffff;
  --flock-bg-raised: #ffffff;
  --flock-bg-surface: #f9fafb;
  --flock-bg-hover: rgba(16, 24, 40, 0.04);
  --flock-border-subtle: rgba(16, 24, 40, 0.05);
  --flock-border-dim: rgba(16, 24, 40, 0.08);
  --flock-border-base: rgba(16, 24, 40, 0.14);
  --flock-text-muted: #9ca3af; /* zinc-400 */
  --flock-text-dim: #6b7280; /* zinc-500 */
  --flock-text-secondary: #3f3f46; /* zinc-700 */
  --flock-text-primary: #18181b; /* zinc-900 */
  --flock-text-bright: #09090b; /* zinc-950 */
  --flock-accent: #155aef; /* Dify classic core blue */
  --flock-accent-soft: rgba(21, 90, 239, 0.08);
  --mantine-color-dimmed: #6b7280;
}

/* ---- Dark theme ---- */
[data-theme="dark"] {
  color-scheme: dark;
  --flock-bg-deepest: #161618; /* Dify app-detail-bg core titanium dark */
  --flock-bg-deep: #1c1c1f;
  --flock-bg-base: #222225;
  --flock-bg-raised: #2a2b2f;
  --flock-bg-surface: #1c1c1f;
  --flock-bg-hover: rgba(255, 255, 255, 0.06);
  --flock-border-subtle: rgba(255, 255, 255, 0.04);
  --flock-border-dim: rgba(255, 255, 255, 0.08);
  --flock-border-base: rgba(255, 255, 255, 0.15);
  --flock-text-muted: #52525b; /* zinc-600 */
  --flock-text-dim: #a1a1aa; /* zinc-400 */
  --flock-text-secondary: #d4d4d8; /* zinc-300 */
  --flock-text-primary: #f4f4f5; /* zinc-100 */
  --flock-text-bright: #ffffff;
  --flock-accent: #155aef; /* Solid classic blue globally */
  --flock-accent-soft: rgba(21, 90, 239, 0.16);
  --mantine-color-dimmed: #a1a1aa;
}

html {
  background: transparent !important;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: transparent !important;
  color: var(--flock-text-secondary);
  overflow: hidden;
}

#root {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--flock-bg-deepest);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--flock-border-base);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.28);
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(21, 90, 239, 0.15);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(21, 90, 239, 0.3);
}

/* ---- Cursor blink animation ---- */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ---- Fade in animation (opacity only, no layout shift) ---- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---- Pulse animation for active indicator dot ---- */
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.75); }
}

/* ---- Home input card focus ---- */
.home-input-card:focus-within {
  border-color: var(--flock-accent) !important;
  box-shadow: 0 0 0 3px rgba(21, 90, 239, 0.15), 0 8px 32px rgba(0,0,0,0.08) !important;
}


/* ---- Sidebar item hover ---- */
.ws-item:hover {
  background: var(--flock-bg-hover) !important;
}

/* ---- File tree item hover ---- */
.file-item:hover {
  background: var(--flock-bg-hover);
}
.file-item:hover .file-actions {
  opacity: 1 !important;
}

/* ---- Input bar focus glow ---- */
.input-bar-wrapper:focus-within {
  border-color: var(--flock-accent) !important;
  box-shadow: 0 0 0 3px rgba(21, 90, 239, 0.18);
}

/* ---- Tool approval inline buttons ---- */
.approval-btn {
  opacity: 0.85;
  transition: opacity 0.12s ease;
}
.approval-btn:hover {
  opacity: 1;
}

/* ---- Markdown body styles ---- */
.markdown-body {
  color: var(--flock-text-primary);
  word-break: break-word;
  max-width: 68ch;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  color: var(--flock-text-bright);
  font-weight: 600;
  margin: 0.75em 0 0.4em;
  line-height: 1.3;
}

.markdown-body h1 { font-size: 1.4em; }
.markdown-body h2 { font-size: 1.2em; }
.markdown-body h3 { font-size: 1.05em; }

.markdown-body p {
  margin: 0.4em 0;
}

.markdown-body p:first-child {
  margin-top: 0;
}

.markdown-body p:last-child {
  margin-bottom: 0;
}

.markdown-body code {
  font-family: 'JetBrains Mono', 'Cascadia Code', Consolas, monospace;
  font-size: 0.875em;
  background: var(--flock-bg-surface);
  border: 1px solid var(--flock-border-dim);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--flock-accent);
}

.markdown-body pre {
  background: var(--flock-bg-deepest);
  border: 1px solid var(--flock-border-subtle);
  border-radius: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  margin: 8px 0;
}

.markdown-body pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--flock-text-primary);
  font-size: 13px;
}

.markdown-body blockquote {
  background: var(--flock-accent-soft);
  border-radius: 6px;
  padding: 8px 12px;
  margin: 8px 0;
  color: var(--flock-text-dim);
  font-style: italic;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 1.4em;
  margin: 0.4em 0;
}

.markdown-body li {
  margin: 0.2em 0;
  line-height: 1.65;
}

.markdown-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 13px;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--flock-border-subtle);
  padding: 6px 10px;
  text-align: left;
}

.markdown-body th {
  background: var(--flock-accent-soft);
  font-weight: 600;
  color: var(--flock-text-primary);
}

.markdown-body tr:nth-child(even) td {
  background: rgba(21, 90, 239, 0.03);
}

.markdown-body a {
  color: var(--flock-accent);
  text-decoration: none;
}

.markdown-body a:hover {
  text-decoration: underline;
}

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--flock-border-subtle);
  margin: 12px 0;
}

.markdown-body strong {
  color: var(--flock-text-bright);
  font-weight: 600;
}

/* ---- Message animation ---- */
.message-enter {
  animation: fadeIn 0.2s ease-out;
}

/* ---- Surface card utility (tinted, no blur) ---- */
.surface-card {
  background: var(--flock-bg-raised);
  border: 1px solid var(--flock-border-subtle);
  border-radius: 12px;
}

/* ---- Hover background utility ---- */
.hover-bg-raised:hover {
  background: var(--flock-bg-hover);
}
/* ---- Card hover lift effect ---- */
.hover-card-lift {
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05) !important;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease !important;
}
.hover-card-lift:hover {
  transform: translateY(-2px) !important;
  border-color: var(--flock-accent) !important;
  box-shadow: 0 14px 36px rgba(21, 90, 239, 0.14) !important;
}
/* ---- Close button rotate effect ---- */
.hover-rotate-close:hover {
  transform: rotate(90deg);
  background: var(--flock-bg-hover);
}

/* ---- Active node glowing animations ---- */
.react-flow__node {
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
  border-radius: 12px !important;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
}

.react-flow__node.selected,
.react-flow__node.selected:hover,
.react-flow__node:focus,
.react-flow__node:focus-visible {
  box-shadow: none !important;
  outline: none !important;
  border: none !important;
}

.flock-active-node {
  border-color: var(--flock-accent, #228be6) !important;
  box-shadow: 0 0 16px rgba(34, 139, 230, 0.6) !important;
  animation: flock-pulse 1.8s infinite alternate ease-in-out !important;
}

/* ---- Spin animation for loading icons ---- */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ---- Workflow step expanded markdown ---- */
.workflow-step-markdown {
  font-size: 12px;
  color: var(--flock-text-secondary);
  line-height: 1.65;
  word-break: break-word;
}
.workflow-step-markdown p { margin: 0.25em 0; }
.workflow-step-markdown p:first-child { margin-top: 0; }
.workflow-step-markdown p:last-child { margin-bottom: 0; }
.workflow-step-markdown code {
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 11px;
  background: var(--flock-bg-deepest);
  border: 1px solid var(--flock-border-dim);
  border-radius: 3px;
  padding: 1px 4px;
  color: var(--flock-accent);
}
.workflow-step-markdown pre {
  background: var(--flock-bg-deepest);
  border: 1px solid var(--flock-border-subtle);
  border-radius: 6px;
  padding: 8px 10px;
  overflow-x: auto;
  margin: 4px 0;
}
.workflow-step-markdown pre code {
  background: transparent; border: none; padding: 0;
  color: var(--flock-text-primary); font-size: 11px;
}
.workflow-step-markdown ul, .workflow-step-markdown ol {
  padding-left: 1.2em; margin: 0.25em 0;
}
.workflow-step-markdown li { margin: 0.1em 0; }
.workflow-step-markdown strong { color: var(--flock-text-bright); font-weight: 600; }

@keyframes flock-pulse {
  0% {
    box-shadow: 0 0 8px rgba(34, 139, 230, 0.4);
  }
  100% {
    box-shadow: 0 0 20px rgba(34, 139, 230, 0.8), 0 0 4px var(--flock-accent);
  }
}

/* ---- Codex Glassmorphic Panels ---- */
.glass-panel-base {
  /* Remove backdrop-filter to prevent WebKit coordinate mismatch and click blockage on macOS scrollable panels */
}
[data-theme="light"] .glass-panel-base {
  background: var(--flock-bg-base) !important;
}
[data-theme="dark"] .glass-panel-base {
  background: var(--flock-bg-base) !important;
}

.glass-panel-surface {
  /* Remove backdrop-filter to prevent WebKit coordinate mismatch and click blockage on macOS scrollable panels */
}
[data-theme="light"] .glass-panel-surface {
  background: var(--flock-bg-surface) !important;
}
[data-theme="dark"] .glass-panel-surface {
  background: var(--flock-bg-surface) !important;
}
