/* Greb Flow - Main Stylesheet */

/* Import JetBrains Mono font */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* Base styles */
body {
    margin: 0;
    padding: 0;
    font-family: 'JetBrains Mono', monospace;
    background-color: #A0A0A0;
    color: #ffffff;
}

/* Fade in animation for save notification */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Used by the compiled freeze-frame display while the frame is being extracted. */
@keyframes freeze-frame-spin {
    to { transform: rotate(360deg); }
}

@keyframes greb-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* Image-to-video display carousel. Each thumb hides its delete button
   until the thumb is selected or hovered, so an inactive row reads as a
   clean storyboard strip rather than a wall of red close-icons. */
.greb-storyboard-thumb .greb-storyboard-thumb__delete {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease;
}

.greb-storyboard-thumb:hover .greb-storyboard-thumb__delete,
.greb-storyboard-thumb.is-selected .greb-storyboard-thumb__delete {
    opacity: 1;
    pointer-events: auto;
}

/* App container */
#app {
    width: 100vw;
    height: 100vh;
    background-color: #A0A0A0;
    font-family: 'JetBrains Mono', monospace;
}

/* React Flow background override */
.react-flow__background {
    background-color: #A0A0A0 !important;
}

/* Lighter grid lines */
.react-flow__background pattern line {
    stroke: rgba(0, 0, 0, 0.08) !important;
}

/* All edges: consistent black, thick stroke — as a default only: no
   !important, so an edge's own style (dashed, transparent, another colour —
   see switch-edge-type! / edge-transparent!) is what shows. The extra
   .react-flow class keeps this above React Flow's own grey default. */
.react-flow .react-flow__edge-path {
    stroke: #000000;
    stroke-width: 3;
    opacity: 1;
}

/* React Flow node wrapper styling */
.react-flow__node {
    /* Remove all default styling from wrapper */
    background: none !important;
    border: none !important;
    padding: 0 !important;
}

.react-flow__node.selected {
    /* Don't override our custom node outlines */
}

/* Hide React Flow's default selection visuals (our custom nodes handle it) */
.react-flow__nodesselection-rect {
    display: none !important;
}

/* Shift+L link: draw the new edge from its source out to its target.
   pathLength=1 is set on the path in JS (app.api.node-ops.linking), so these
   dash units are a fraction of the path and one keyframe fits any length. */
@keyframes greb-edge-grow {
    from { stroke-dashoffset: 1; }
    to   { stroke-dashoffset: 0; }
}

.react-flow__edge-path.greb-edge-grow {
    stroke-dasharray: 1;
    animation: greb-edge-grow 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* Highlight selected edges - white, same thickness */
.react-flow__edge.selected path,
.react-flow__edge.selected .react-flow__edge-path {
    stroke: #FFFFFF !important;
    stroke-width: 3 !important;
}

/* Edge z-index: above shadow, below ports */
.react-flow__edge {
    z-index: 5 !important;
    opacity: 0.9 !important;
    display: flex !important;
    flex-wrap: wrap !important;
    padding-top: 0px !important;
    box-sizing: border-box !important;
    border-radius: 0px !important;
    border-top-left-radius: 0px !important;
    border-top-right-radius: 0px !important;
    border-bottom-right-radius: 0px !important;
    border-bottom-left-radius: 0px !important;
}

/* React Flow edge label renderer */
.react-flow__edgelabel-renderer {
    opacity: 0 !important;
}


/* React Flow edges SVG */
.react-flow__edges {
    opacity: 0.9 !important;
}

/* SVG elements within React Flow */
.react-flow svg {
    opacity: 1 !important;
}

/* Path elements within React Flow — except edge lines, whose opacity is the
   edge's own (transparent edges; see app.components.edge-style-panel) */
.react-flow path:not(.react-flow__edge-path) {
    opacity: 1 !important;
}

/* G elements within React Flow */
.react-flow g {
    opacity: 1 !important;
}

.react-flow__handle:not(.icon-handle) {
    z-index: 10 !important;
    width: 12px !important;
    height: 12px !important;
    border: 3px solid #000 !important;
    background: #fff !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

/* La salida de un backdrop (app.components.group-node): grande y amarilla. La
   regla de arriba deja todos los handles en 12px blancos y aquí no se veía. */
.react-flow__handle.backdrop-salida:not(.icon-handle) {
    width: 30px !important;
    height: 30px !important;
    background: #F5DF4D !important;
    border: 4px solid #000 !important;
    border-radius: 50% !important;
    right: -17px !important;
    box-shadow: 3px 3px 0 #000 !important;
}

/* Fix edge connection gap - position handles at the visual edge of the node */
/* For nodes with border-radius (display mode), the rendered content typically has padding (24px) */
/* So handles should be positioned to account for that visual padding */
.react-flow__node[style*="border-radius"] .react-flow__handle-left:not(.icon-handle),
.react-flow__node[data-has-display="true"] .react-flow__handle-left:not(.icon-handle) {
    left: -6px !important;  /* Align handle center to the node edge */
    top: 50% !important;
    transform: translateY(-50%) !important;
}

.react-flow__node[style*="border-radius"] .react-flow__handle-right:not(.icon-handle),
.react-flow__node[data-has-display="true"] .react-flow__handle-right:not(.icon-handle) {
    right: -6px !important;  /* Align handle center to the node edge */
    top: 50% !important;
    transform: translateY(-50%) !important;
}

.react-flow__node[style*="border-radius"] .react-flow__handle-top,
.react-flow__node[data-has-display="true"] .react-flow__handle-top {
    top: 21px !important;  /* 24px content padding - 3px (half handle) = 21px */
    left: 50% !important;
    transform: translateX(-50%) !important;
}

.react-flow__node[style*="border-radius"] .react-flow__handle-bottom,
.react-flow__node[data-has-display="true"] .react-flow__handle-bottom {
    bottom: 21px !important;  /* 24px content padding - 3px (half handle) = 21px */
    left: 50% !important;
    transform: translateX(-50%) !important;
}

/* Default positioning for nodes without border-radius (with padding) */
.react-flow__handle-left {
    left: -6px !important;  /* Align handle center to the node edge */
    top: 50% !important;
    transform: translateY(-50%) !important;
}

.react-flow__handle-right {
    right: -6px !important;  /* Align handle center to the node edge */
    top: 50% !important;
    transform: translateY(-50%) !important;
}

/* Greb nodes auto-size to their label, so the right handle MUST stay
   anchored to the node's right edge via `right: -6px` (set by the
   default `.react-flow__handle-right` rule above). The previous
   override here pinned `left: 151px` — fine when every greb node was
   ~150px wide, but wrong now that long-named nodes (e.g.
   `aleida_borlas`, `conv_chivu`) are wider. With the override in place
   handles drifted ~50px inside the visible right edge. Don't reintroduce
   it: if you need per-node tweaks, do them in the node's inline style
   so the position stays a function of the actual node width. */

.react-flow__handle-top {
    top: 5px !important;  /* 8px padding - 3px (half handle) = 5px */
    left: 50% !important;
    transform: translateX(-50%) !important;
}

.react-flow__handle-bottom {
    bottom: 5px !important;  /* 8px padding - 3px (half handle) = 5px */
    left: 50% !important;
    transform: translateX(-50%) !important;
}

/* Group nodes should be behind edges */
.resizable-group-node {
    z-index: -1 !important;
}

/* More specific selector for React Flow group nodes */
.react-flow__node .resizable-group-node {
    z-index: -1 !important;
}

/* Even more specific - target the React Flow node wrapper containing group nodes */
.react-flow__node.reactflow-node {
    z-index: -1 !important;
}

/* Ensure selected nodes don't override edge z-index */
.react-flow__node.selected {
    z-index: auto !important;
}

/* Regular nodes that are selected should NOT go above edges */
.react-flow__node.selected:not(.react-flow__node-group) {
    z-index: 1 !important;  /* Below edges (z-index: 5) */
}

/* Ensure group nodes stay behind edges even when selected */
.react-flow__node.selected .resizable-group-node {
    z-index: -1 !important;
}

.react-flow__node-group.selected {
    z-index: -1 !important;
}

/* Thicker connection line during drag preview */
.react-flow__connection-line {
    stroke-width: 4 !important;
    stroke: #000000 !important;
}

/* Alternative: target the connection path specifically */
.react-flow__connection-path {
    stroke-width: 4 !important;
    stroke: #000000 !important;
}

/* Allow React Flow interactions while hiding visual effects */
.react-flow__node:hover,
.react-flow__node-default:hover,
.react-flow__node.selected:hover {
    /* Remove hover visual effects but keep interaction */
}

/* Custom node styling that overrides React Flow defaults */
.greb-custom-node {
    background-color: #FF0000 !important;
    color: #FFFFFF !important;
    padding: 20px !important;
    border-radius: 10px !important;
    border: 3px solid #000000 !important;
    width: 150px !important;
    height: 60px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    font-family: 'JetBrains Mono', monospace !important;
    font-weight: 600 !important;
}

/* Default node styling */
.greb-default-node {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
}

/* Hide React Flow's default selection border/outline that appears around the node wrapper */
.react-flow__node.selected::before,
.react-flow__node.selected::after {
    display: none !important;
}

/* Remove React Flow's default focus outline */
.react-flow__node:focus,
.react-flow__node.selected:focus {
    outline: none !important;
}

/* Remove React Flow's selection box and rectangle */
.react-flow__nodesselection {
    display: none !important;
}

.react-flow__nodesselection-rect {
    display: none !important;
}

/* Let React Flow handle node positioning and interaction naturally */

/* Hide web nodes when display mode is enabled (overlay shows them instead) */
.react-flow__node-web[style*="opacity: 0"],
.react-flow__node-web[data-has-display="true"] {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    font-size: 0 !important;
    line-height: 0 !important;
    color: transparent !important;
    text-shadow: none !important;
}

/* Hide nodes when code mode is enabled (overlay shows them instead) */
/* Only hide if explicitly set to true, never if false */
.react-flow__node[data-has-code="true"] {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    font-size: 0 !important;
    line-height: 0 !important;
    color: transparent !important;
    text-shadow: none !important;
}

/* Hide nodes with opacity 0 when code mode is true (not false) */
.react-flow__node[style*="opacity: 0"][data-has-code="true"] {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    font-size: 0 !important;
    line-height: 0 !important;
    color: transparent !important;
    text-shadow: none !important;
}

/* Leaflet Map Cursor Fix */
.leaflet-container {
    cursor: default !important;
}

.leaflet-container.leaflet-grab {
    cursor: grab !important;
}

.leaflet-container.leaflet-grabbing {
    cursor: grabbing !important;
}

/* Ensure cursor resets after drag */
.leaflet-container.leaflet-grab *:not(.leaflet-control):not(.leaflet-control *) {
    cursor: grab !important;
}

.leaflet-container.leaflet-grabbing *:not(.leaflet-control):not(.leaflet-control *) {
    cursor: grabbing !important;
}

/* Reset cursor on map pane when not dragging */
.leaflet-pane,
.leaflet-map-pane {
    cursor: default !important;
}

.leaflet-container.leaflet-grab .leaflet-pane,
.leaflet-container.leaflet-grab .leaflet-map-pane {
    cursor: grab !important;
}

.leaflet-container.leaflet-grabbing .leaflet-pane,
.leaflet-container.leaflet-grabbing .leaflet-map-pane {
    cursor: grabbing !important;
}

/* Leaflet Controls - GREB Brutalism Style */
.leaflet-control {
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    font-family: 'JetBrains Mono', monospace !important;
    cursor: default !important;
}

.leaflet-bar {
    background: rgba(245, 223, 77, 1) !important;
    border: 3px solid #000 !important;
    border-radius: 6px !important;
    box-shadow: -3px 3px 0px #000 !important;
    overflow: hidden !important;
}

.leaflet-bar a,
.leaflet-bar a:hover {
    background-color: rgba(245, 223, 77, 1) !important;
    border: none !important;
    border-bottom: 2px solid #000 !important;
    border-radius: 0 !important;
    color: #000 !important;
    font-family: 'JetBrains Mono', monospace !important;
    font-weight: 800 !important;
    font-size: 18px !important;
    width: 32px !important;
    height: 32px !important;
    line-height: 30px !important;
    text-align: center !important;
    text-decoration: none !important;
    box-shadow: none !important;
    transition: background-color 0.1s !important;
}

.leaflet-bar a:last-child {
    border-bottom: none !important;
}

.leaflet-bar a:hover {
    background-color: rgba(255, 235, 100, 1) !important;
}

.leaflet-bar a:active {
    background-color: rgba(220, 200, 50, 1) !important;
}

.leaflet-bar a.leaflet-disabled {
    background-color: rgba(200, 200, 200, 0.5) !important;
    color: #666 !important;
    cursor: not-allowed !important;
}

.leaflet-control-layers {
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    font-family: 'JetBrains Mono', monospace !important;
    padding: 0 !important;
}

.leaflet-control-layers-toggle {
    background-color: rgba(245, 223, 77, 1) !important;
    background-image: url('/assets/icons/svg/map.svg') !important;
    background-size: 20px 20px !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    border: 3px solid #000 !important;
    border-radius: 6px !important;
    width: 36px !important;
    height: 36px !important;
    box-shadow: -3px 3px 0px #000 !important;
}

.leaflet-control-layers-expanded {
    background: rgba(245, 223, 77, 1) !important;
    border: 3px solid #000 !important;
    border-radius: 6px !important;
    box-shadow: -3px 3px 0px #000 !important;
    padding: 8px 12px !important;
    font-family: 'JetBrains Mono', monospace !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    color: #000 !important;
}

.leaflet-control-layers-base label,
.leaflet-control-layers-overlays label {
    color: #000 !important;
    font-family: 'JetBrains Mono', monospace !important;
    font-weight: 600 !important;
    font-size: 12px !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 4px 0 !important;
}

.leaflet-control-layers-base label:hover,
.leaflet-control-layers-overlays label:hover {
    background-color: rgba(255, 235, 100, 0.3) !important;
}

.leaflet-control-layers-base input[type="radio"],
.leaflet-control-layers-base input[type="checkbox"],
.leaflet-control-layers-overlays input[type="radio"],
.leaflet-control-layers-overlays input[type="checkbox"] {
    width: 16px !important;
    height: 16px !important;
    border: 2px solid #000 !important;
    border-radius: 3px !important;
    cursor: pointer !important;
    accent-color: #000 !important;
}

/* GREB-styled Leaflet popups — strip default chrome */
.greb-popup .leaflet-popup-content-wrapper {
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
}
.greb-popup .leaflet-popup-content {
    margin: 0 !important;
    line-height: 1.4 !important;
}
.greb-popup .leaflet-popup-tip {
    background: #1e1e1e !important;
    border: none !important;
    box-shadow: none !important;
}
.greb-popup .leaflet-popup-close-button {
    display: none !important;
}

/* Custom marker icon — no default white box */
.greb-marker-icon {
    background: none !important;
    border: none !important;
}

/* Selected charta marker (divIcon) — highlight ring, synced with the entities panel */
.greb-marker-selected {
    z-index: 1000 !important;
}
.greb-marker-selected > div {
    border-color: #fff !important;
    box-shadow: 0 0 0 3px #fff, 0 0 10px 3px rgba(0, 0, 0, 0.5) !important;
    transform: scale(1.18);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

/* Hide all text and content inside hidden web nodes */
.react-flow__node-web[data-has-display="true"],
.react-flow__node-web[data-has-display="true"] *,
.react-flow__node-web[style*="opacity: 0"],
.react-flow__node-web[style*="opacity: 0"] *,
.react-flow__node-web[style*="visibility: hidden"],
.react-flow__node-web[style*="visibility: hidden"] * {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    color: transparent !important;
    background: transparent !important;
    text-shadow: none !important;
    font-size: 0 !important;
    line-height: 0 !important;
}

/* Hide all text and content inside nodes with code mode enabled */
.react-flow__node[data-has-code="true"],
.react-flow__node[data-has-code="true"] *,
.react-flow__node[style*="opacity: 0"][data-has-code="true"],
.react-flow__node[style*="opacity: 0"][data-has-code="true"] *,
.react-flow__node[style*="visibility: hidden"][data-has-code="true"],
.react-flow__node[style*="visibility: hidden"][data-has-code="true"] * {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    color: transparent !important;
    background: transparent !important;
    text-shadow: none !important;
    font-size: 0 !important;
    line-height: 0 !important;
}

/* CRITICAL: Ensure nodes with code=false are ALWAYS visible - MUST come after all hiding rules */
/* This overrides any hiding styles that might have been applied */
.react-flow__node[data-has-code="false"] {
    opacity: 1 !important;
    visibility: visible !important;
    display: flex !important;
}

.react-flow__node[data-has-code="false"] * {
    opacity: 1 !important;
    visibility: visible !important;
    display: revert !important;
    font-size: revert !important;
    line-height: revert !important;
    color: revert !important;
    background: revert !important;
    border: revert !important;
    box-shadow: revert !important;
    text-shadow: revert !important;
}

/* Hide React Flow handles inside hidden web nodes */
.react-flow__node-web[data-has-display="true"] .react-flow__handle,
.react-flow__node-web[style*="opacity: 0"] .react-flow__handle,
.react-flow__node-web[style*="visibility: hidden"] .react-flow__handle {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Hide React Flow handles inside nodes with code mode enabled (except icon handles) */
.react-flow__node[data-has-code="true"] .react-flow__handle:not(.icon-handle),
.react-flow__node[style*="opacity: 0"][data-has-code="true"] .react-flow__handle:not(.icon-handle),
.react-flow__node[style*="visibility: hidden"][data-has-code="true"] .react-flow__handle:not(.icon-handle) {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Icon-mode handles: override React Flow defaults so edges connect to the icon circles */
.react-flow__handle.icon-handle {
    width: 26px !important;
    height: 26px !important;
    top: var(--icon-handle-top) !important;
    transform: none !important;
    border: none !important;
    border-radius: 50% !important;
    pointer-events: auto !important;
    cursor: crosshair !important;
    transition: transform 0.15s ease, box-shadow 0.15s ease !important;
    z-index: 10 !important;
    position: absolute !important;
}

.react-flow__handle.icon-handle > * {
    pointer-events: none !important;
}

.react-flow__handle.icon-handle:hover {
    transform: scale(1.35) !important;
    box-shadow: 0 0 8px rgba(0,0,0,0.4) !important;
    z-index: 100 !important;
}

/* Place icon handles fully outside the node with a 2px gap so they aren't
   clipped by the border/fill and don't visually double-up with the edge.
   -28px = -(handle width 26) - 2px gap. */
.react-flow__handle.icon-handle-left {
    left: -28px !important;
}

.react-flow__handle.icon-handle-right {
    right: -28px !important;
    left: auto !important;
}

/* Ensure handles are visible when code mode is off */
.react-flow__node[data-has-code="false"] .react-flow__handle {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Hide any text nodes or content that might slip through */
.react-flow__node-web[data-has-display="true"] span,
.react-flow__node-web[data-has-display="true"] div,
.react-flow__node-web[data-has-display="true"] p,
.react-flow__node-web[data-has-display="true"] pre,
.react-flow__node-web[style*="opacity: 0"] span,
.react-flow__node-web[style*="opacity: 0"] div,
.react-flow__node-web[style*="opacity: 0"] p,
.react-flow__node-web[style*="opacity: 0"] pre {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    font-size: 0 !important;
    line-height: 0 !important;
    color: transparent !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* Hide any text nodes or content in hidden code nodes */
.react-flow__node-code[data-has-display="true"] span,
.react-flow__node-code[data-has-display="true"] div,
.react-flow__node-code[data-has-display="true"] p,
.react-flow__node-code[data-has-display="true"] pre,
.react-flow__node-code[style*="opacity: 0"] span,
.react-flow__node-code[style*="opacity: 0"] div,
.react-flow__node-code[style*="opacity: 0"] p,
.react-flow__node-code[style*="opacity: 0"] pre {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    font-size: 0 !important;
    line-height: 0 !important;
    color: transparent !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* Specifically hide pre tags with data content */
.react-flow__node-web[data-has-display="true"] pre,
.react-flow__node-web[style*="opacity: 0"] pre {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    font-size: 0 !important;
    line-height: 0 !important;
    color: transparent !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    white-space: nowrap !important;
}

/* Specifically hide pre tags in hidden code nodes */
.react-flow__node-code[data-has-display="true"] pre,
.react-flow__node-code[style*="opacity: 0"] pre {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    font-size: 0 !important;
    line-height: 0 !important;
    color: transparent !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    white-space: nowrap !important;
}

/* React Flow controls positioning */
.react-flow__controls {
    bottom: 10px !important;
    top: auto !important;
    left: 10px !important;
    background: #F9DB57 !important;
    border-radius: 7.53px !important;
    outline: 4px black solid !important;
    box-shadow: -4.108029365539551px 6.162043571472168px 0px black !important;
    padding: 4px !important;
}

/* Style individual control buttons */
.react-flow__controls button {
    background: transparent !important;
    border: none !important;
    color: #000000 !important;
    font-weight: 600 !important;
    width: 24px !important;
    height: 24px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-family: 'JetBrains Mono', monospace !important;
}

.react-flow__controls button:hover {
    background: rgba(0, 0, 0, 0.1) !important;
    border-radius: 3px !important;
}

.react-flow__controls button:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}

/* React Flow minimap positioning */
.react-flow__minimap {
    bottom: 10px !important;
    left: 10px !important; /* Moved to bottom-left corner */
    right: auto !important;
    border-radius: 7.53px !important;
    outline: 2px black solid !important;
    box-shadow: -2px 3px 0px black !important;
}

/* Ollama chat send button styling - ensure mint green background */
.ollama-chat-send-button {
    background-color: rgba(189, 244, 216, 1) !important;
    border-radius: 8px !important;
    color: #fff !important;
    font-weight: 900 !important;
    font-size: 16px !important;
    width: 50px !important;
    height: 50px !important;
}

/* Make send button icon white */
.ollama-chat-send-button img {
    filter: invert(1) !important;
    padding: 0 !important;
    border: 4px solid #000 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 4px 4px 0px #000 !important;
    transition: none !important;
}

/* Greb icon styling */
.greb-icon {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 1001;
    cursor: pointer;
    width: 80px;
    height: 80px;
    transition: transform 0.2s ease;
}

.greb-icon:hover {
    transform: scale(1.1);
}

.greb-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

/* Custom node styles */
.greb-node {
    padding: 12px;
    border-radius: 8px;
    min-width: 120px;
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.greb-node--default {
    border: 2px solid #555;
    background: #1a1a1a;
    color: #ffffff;
}

.greb-node--pizza {
    border: 2px solid #ff6b35;
    background: #1a1a1a;
    color: #ffffff;
    min-width: 140px;
}

.greb-node__emoji {
    font-size: 20px;
}

.greb-node__label {
    font-weight: 600;
    color: #ff6b35;
    margin-top: 4px;
}

/* Graph indicator */
.greb-graph-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(26, 26, 26, 0.95);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    font-family: 'JetBrains Mono', monospace;
    z-index: 1000;
    border: 1px solid #555;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Grid and background customization */
.greb-canvas {
    width: 100%;
    height: 100vh;
}

/* Utility classes */
.greb-text-mono {
    font-family: 'JetBrains Mono', monospace;
}

.greb-bg-dark {
    background-color: #2a2a2a;
}

.greb-text-light {
    color: #ffffff;
}

.greb-border-subtle {
    border: 1px solid #555;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .react-flow__controls {
        bottom: 5px !important;
        left: 5px !important;
        top: auto !important;
    }
    
    .greb-graph-indicator {
        top: 5px;
        right: 5px;
        font-size: 12px;
        padding: 6px 10px;
    }
    
    .greb-node {
        padding: 10px;
        min-width: 100px;
    }
}

/* Dark theme scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a1a;
}

::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #777;
}

/* Omnibar suggestion scrollbar — black thumb on the yellow palette,
   fully rounded pill so it visually echoes the omnibar's rounded shell. */
.omnibar-suggestions-scroll {
    /* Firefox */
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.55) transparent;
}
.omnibar-suggestions-scroll::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
.omnibar-suggestions-scroll::-webkit-scrollbar-track {
    background: transparent;
    margin: 4px 0;
}
.omnibar-suggestions-scroll::-webkit-scrollbar-thumb {
    background: rgba(24, 25, 63, 0.55);
    border-radius: 9999px;
    border: 2px solid transparent;
    background-clip: padding-box;
    min-height: 28px;
}
.omnibar-suggestions-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(24, 25, 63, 0.85);
    background-clip: padding-box;
}
.omnibar-suggestions-scroll::-webkit-scrollbar-thumb:active {
    background: #18193f;
    background-clip: padding-box;
}

/* Markdown content styles for chat display */
.markdown-content {
    font-size: 14px;
    line-height: 1.7;
    word-break: break-word;
}

.markdown-content > *:first-child {
    margin-top: 0 !important;
}

.markdown-content > *:last-child {
    margin-bottom: 0 !important;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    font-weight: 700;
    margin-top: 1em;
    margin-bottom: 0.5em;
    line-height: 1.2;
}

.markdown-content h1 { font-size: 1.5em; }
.markdown-content h2 { font-size: 1.3em; }
.markdown-content h3 { font-size: 1.1em; }

.markdown-content p {
    margin: 0.25em 0;
}

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

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

.markdown-content strong,
.markdown-content b {
    font-weight: 700 !important;
    font-style: normal;
}

.markdown-content p strong,
.markdown-content p b {
    font-weight: 700 !important;
}

.markdown-content em,
.markdown-content i {
    font-style: italic;
}

.markdown-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9em;
}

.markdown-content pre {
    background: rgba(0, 0, 0, 0.1);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.5em 0;
}

.markdown-content pre code {
    background: transparent;
    padding: 0;
}

.markdown-content ul,
.markdown-content ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.markdown-content li {
    margin: 0.25em 0;
}

.markdown-content blockquote {
    border-left: 3px solid rgba(0, 0, 0, 0.2);
    padding-left: 1em;
    margin: 0.5em 0;
    font-style: italic;
}

.markdown-content a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: rgba(0, 0, 0, 0.3);
}

.markdown-content hr {
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.2);
    margin: 1em 0;
}

/* Enable text selection on display content (exclude form elements) */
[data-cursor-element-id]:not(textarea):not(input):not(button) {
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    cursor: text !important;
}

/* Ensure display overlay content is selectable (exclude form elements) */
div[style*="pointer-events: auto"] {
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
}

div[style*="pointer-events: auto"] *:not(textarea):not(input):not(button) {
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
}

/* Ensure textareas and inputs work properly in display nodes */
.display-node-container textarea, 
.display-node-container input, 
.display-node-container button,
.display-node-container a {
    pointer-events: auto !important;
    user-select: auto !important;
    -webkit-user-select: auto !important;
}

textarea, input[type="text"], input[type="search"] {
    user-select: auto !important;
    -webkit-user-select: auto !important;
    -moz-user-select: auto !important;
    -ms-user-select: auto !important;
    cursor: text !important;
    pointer-events: auto !important;
}

/* Ollama chat send button baseline styling */
.ollama-chat-send-button {
    width: 50px !important;
    height: 50px !important;
    padding: 0 !important;
    background: rgba(189, 244, 216, 1) !important;
    color: #000 !important;
    border: 4px solid #000 !important;
    border-radius: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-weight: 900 !important;
    font-size: 16px !important;
    box-shadow: 4px 4px 0px #000 !important;
    cursor: pointer !important;
}

/* ── Greb Markdown / RichText prose styles ──────────────────────────────── */
.greb-markdown, .greb-richtext {
  /* Links */
  a { color: #6b8cff; text-decoration: underline; }
  a:hover { color: #9bb0ff; }

  /* Bold */
  strong, b { font-weight: 700; }

  /* Italic */
  em, i { font-style: italic; }

  /* Headings */
  h1,h2,h3,h4 { font-weight: 700; line-height: 1.3; margin: 0.6em 0 0.3em; }
  h1 { font-size: 1.4em; }
  h2 { font-size: 1.2em; }
  h3 { font-size: 1.05em; }

  /* Paragraphs */
  p { margin: 0 0 0.7em; }
  p:last-child { margin-bottom: 0; }

  /* Block-quote */
  blockquote {
    margin: 0.5em 0;
    padding: 0.4em 0.8em;
    border-left: 3px solid rgba(160,130,255,0.5);
    font-style: italic;
    opacity: 0.85;
  }

  /* Inline code */
  code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.88em;
    background: rgba(255,255,255,0.1);
    padding: 1px 4px;
    border-radius: 3px;
  }
}

/* Drop-cap: first letter of the first paragraph, opt-in via --drop-cap:1 */
.greb-markdown[style*="--drop-cap: 1"] p:first-of-type::first-letter,
.greb-richtext[style*="--drop-cap: 1"] p:first-of-type::first-letter {
  float: left;
  font-size: 3.2em;
  line-height: 0.82;
  margin: 0.06em 0.07em 0 0;
  font-weight: 700;
  color: #a08cff;
}

/* ── Driver.js Tutorial — Greb Aesthetic ─────────────────────────────────── */

.driver-popover {
    font-family: 'JetBrains Mono', monospace !important;
    background: #F9DB57 !important;
    border: 3px solid #000 !important;
    border-radius: 6px !important;
    box-shadow: -4px 4px 0px rgba(0,0,0,0.5) !important;
    color: #000 !important;
    padding: 20px !important;
    max-width: 380px !important;
}

.driver-popover .driver-popover-title {
    font-family: 'JetBrains Mono', monospace !important;
    font-weight: 700 !important;
    font-size: 16px !important;
    color: #000 !important;
}

.driver-popover .driver-popover-description {
    font-family: 'JetBrains Mono', monospace !important;
    font-size: 13px !important;
    color: #1a1a1a !important;
    line-height: 1.5 !important;
}

.driver-popover .driver-popover-close-btn {
    color: #000 !important;
    font-size: 20px !important;
}

.driver-popover .driver-popover-close-btn:hover {
    color: #555 !important;
}

.driver-popover .driver-popover-navigation-btns button {
    font-family: 'JetBrains Mono', monospace !important;
    background: #000 !important;
    color: #F9DB57 !important;
    border: 2px solid #000 !important;
    border-radius: 4px !important;
    box-shadow: -2px 2px 0px rgba(0,0,0,0.3) !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    padding: 6px 14px !important;
    cursor: pointer !important;
    text-shadow: none !important;
}

.driver-popover .driver-popover-navigation-btns button:hover {
    background: #222 !important;
}

.driver-popover .driver-popover-navigation-btns button:disabled {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
}

.driver-popover .driver-popover-progress-text {
    font-family: 'JetBrains Mono', monospace !important;
    font-size: 11px !important;
    color: #333 !important;
}

.driver-popover-arrow-side-bottom .driver-popover-arrow,
.driver-popover-arrow-side-top .driver-popover-arrow,
.driver-popover-arrow-side-left .driver-popover-arrow,
.driver-popover-arrow-side-right .driver-popover-arrow {
    border-color: #F9DB57 !important;
}

/* ── Lesson Picker ────────────────────────────────────────────────────────── */

.greb-lesson-picker-popover {
    max-width: 440px !important;
}

.greb-lesson-picker {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.greb-lesson-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: #fff;
    border: 2px solid #000;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s;
    box-shadow: 3px 3px 0 #000;
}

.greb-lesson-item:hover {
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 #000;
    background: #FFFDE7;
}

.greb-lesson-item:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 #000;
}

.greb-lesson-icon {
    font-size: 24px;
    flex-shrink: 0;
    width: 36px;
    text-align: center;
}

.greb-lesson-info {
    flex: 1;
    min-width: 0;
}

.greb-lesson-title {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 13px;
    color: #000;
}

.greb-lesson-desc {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: #555;
    margin-top: 2px;
}

.greb-lesson-done {
    color: #2E7D32;
    font-weight: 700;
    font-size: 14px;
}

.greb-lesson-paused {
    font-size: 10px;
    color: #E65100;
    font-weight: 600;
    background: #FFF3E0;
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 4px;
}

/* ── Next Lesson Prompt ───────────────────────────────────────────────────── */

.greb-next-lesson {
    margin-top: 8px;
}

.greb-next-lesson-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: #555;
    margin-bottom: 8px;
}

.greb-next-lesson-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: #fff;
    border: 2px solid #000;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s;
    box-shadow: 3px 3px 0 #000;
}

.greb-next-lesson-card:hover {
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 #000;
    background: #FFFDE7;
}

.greb-next-lesson-card:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 #000;
}

.greb-next-lesson-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.greb-next-lesson-card strong {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: #000;
}

/* ── Scene-node circle treatment (kind="scene") ────────────────────
   The scene-node is the hub between 3d-objects / lights / cameras /
   HDRI / GLB and the greb-3d viewer. Render it as a circle so it
   reads as a conceptually different class of node. */
.react-flow__node[data-kind="scene"] > div:first-child,
.react-flow__node > div[data-kind="scene"] {
  border-radius: 50% !important;
  aspect-ratio: 1 / 1;
  width: 90px !important;
  height: 90px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}
.react-flow__node[data-kind="scene"] {
  width: 90px !important;
  height: 90px !important;
}

/* Entity wiki — markdown rendering (greb-wiki-md). Reads like docs.greb.app:
   an elegant Newsreader serif with a drop cap on the opening paragraph. */
.greb-wiki-md{font-family:'Newsreader',Georgia,'Times New Roman',serif;color:#2a2620;font-size:14px;line-height:1.62;-webkit-font-smoothing:antialiased}
.greb-wiki-md h1,.greb-wiki-md h2,.greb-wiki-md h3{font-family:'Newsreader',Georgia,serif;margin:.85em 0 .25em;font-weight:600;line-height:1.18;letter-spacing:-.01em}
.greb-wiki-md h1{font-size:21px}.greb-wiki-md h2{font-size:15px;color:var(--wiki-accent,#8a6d00);font-weight:700}.greb-wiki-md h3{font-size:13px}
.greb-wiki-md p{margin:.5em 0;line-height:1.62}
/* Drop cap on the opening paragraph — tinted with the profile's accent (party color) */
.greb-wiki-md>p:first-of-type::first-letter{float:left;font-family:'Newsreader',Georgia,serif;font-weight:600;font-size:3.1em;line-height:.78;padding:.02em .09em 0 0;color:var(--wiki-accent,#8a6d00)}
.greb-wiki-md ul,.greb-wiki-md ol{margin:.3em 0 .3em 1.2em}
.greb-wiki-md li{margin:.15em 0}
.greb-wiki-md code{background:#eee;padding:1px 4px;border-radius:3px;font-size:.9em}
.greb-wiki-md pre{background:#f3f3f3;padding:8px;border-radius:6px;overflow:auto}
.greb-wiki-md img{max-width:100%;border-radius:6px;margin:6px 0}
.greb-wiki-md a{color:#1E6FD9;text-decoration:underline}
.greb-wiki-md blockquote{margin:.4em 0;padding-left:10px;border-left:3px solid #ccc;color:#555}

/* Fondo oscuro para tiles raster de OpenStreetMap.
   CARTO dejó de servir dark_all sin API key (los tiles vuelven con la marca de
   agua «API KEY REQUIRED»), así que el oscuro sale de invertir los tiles
   abiertos de OSM en vez de depender de un proveedor con clave.
   Ver src/app/charta/basemaps.cljs. */
.leaflet-tile-pane .greb-tiles-dark {
    filter: invert(1) hue-rotate(180deg) brightness(0.92) contrast(0.86) saturate(0.6);
}

/* Omnirepl editing text animation */
@keyframes omnirepl-pulse {
    0% { background-color: rgba(255, 255, 0, 0.3); color: #000 !important; }
    50% { background-color: rgba(255, 255, 0, 0.7); color: #000 !important; }
    100% { background-color: rgba(255, 255, 0, 0.3); color: #000 !important; }
}

.omnirepl-editing-text {
    animation: omnirepl-pulse 1.5s infinite ease-in-out;
    border-radius: 2px;
}

/* A graph that flows top to bottom — (flujo tb), app.flujo: inputs along the
   node's top edge, outputs along its bottom, spread by --port-x
   (node.view.handles/port-x!). Stronger than every left/right rule above. */
.react-flow__node [data-flujo="tb"] .react-flow__handle.react-flow__handle-top {
    top: -6px !important;
    bottom: auto !important;
    left: var(--port-x, 50%) !important;
    right: auto !important;
    transform: translateX(-50%) !important;
}
.react-flow__node [data-flujo="tb"] .react-flow__handle.react-flow__handle-bottom {
    bottom: -6px !important;
    top: auto !important;
    left: var(--port-x, 50%) !important;
    right: auto !important;
    transform: translateX(-50%) !important;
}
.react-flow__node [data-flujo="tb"] .react-flow__handle.icon-handle.react-flow__handle-top {
    top: -28px !important;
    left: calc(var(--port-x, 50%) - 13px) !important;
    transform: none !important;
}
.react-flow__node [data-flujo="tb"] .react-flow__handle.icon-handle.react-flow__handle-bottom {
    bottom: -28px !important;
    top: auto !important;
    left: calc(var(--port-x, 50%) - 13px) !important;
    transform: none !important;
}
.react-flow__node [data-flujo="tb"] .react-flow__handle.icon-handle.react-flow__handle-top:hover,
.react-flow__node [data-flujo="tb"] .react-flow__handle.icon-handle.react-flow__handle-bottom:hover {
    transform: scale(1.35) !important;
}
