:root {
    --sidebar-width: 280px;
    --toolbar-height: 56px;
    --primary-color: #0d6efd;
    --grid-color: rgba(0, 0, 0, 0.05);
    --grid-major-color: rgba(0, 0, 0, 0.1);
}

body {
    overflow: hidden;
    /* App-like feel */
    font-family: 'Inter', sans-serif;
}

/* Sidebar adjustments */
aside {
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
    z-index: 5;
}

.draggable-variable {
    cursor: grab;
    border-radius: 6px;
    margin-bottom: 4px;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.draggable-variable:hover {
    background-color: #f8f9fa;
    border-color: #dee2e6;
    transform: translateX(2px);
}

.cursor-move {
    cursor: move;
}

.btn-delete-var {
    opacity: 0;
    transition: opacity 0.2s;
}

.draggable-variable:hover .btn-delete-var {
    opacity: 1;
}

/* Canvas Area */
#canvas-container {
    background-color: #e9ecef;
    background-image:
        linear-gradient(var(--grid-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
    background-size: 20px 20px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.05);
}

#workspace-wrapper {
    transition: transform 0.2s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

#label-canvas {
    position: relative;
    background-color: white;
    width: 100%;
    height: 100%;
    overflow: hidden;
    cursor: default;
}

/* The MM Grid Overlay */
.mm-grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 100;
    background-image:
        linear-gradient(var(--grid-major-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-major-color) 1px, transparent 1px),
        linear-gradient(var(--grid-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
    background-size:
        100px 100px,
        100px 100px,
        10px 10px,
        10px 10px;
    display: none;
}

.mm-grid.active {
    display: block;
}

/* Elements on the canvas */
.canvas-element {
    position: absolute;
    /* Default borders needed to see transparent shapes if selected */
    border: 1px dashed transparent;
    cursor: move;
    user-select: none;
    padding: 0;
    /* Removing padding to make sizing exact */
    overflow: visible;
    /* Allowing handles to show */
    box-sizing: border-box;
}

.canvas-element .content {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
}

.canvas-element:hover {
    border-color: #0d6efd40;
}

/* Selection State */
.canvas-element.selected {
    border: 1px solid #0d6efd;
    z-index: 1000 !important;
}

.canvas-element.locked {
    cursor: not-allowed;
    border-color: #dc3545 !important;
    opacity: 0.8;
}

/* Resize Handles */
.resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: white;
    border: 1px solid #0d6efd;
    border-radius: 50%;
    z-index: 1002;
    display: none;
}

.canvas-element.selected .resize-handle {
    display: block;
}

.canvas-element.locked .resize-handle {
    display: none !important;
}

/* Handle Positions */
.handle-nw {
    top: -6px;
    left: -6px;
    cursor: nw-resize;
}

.handle-ne {
    top: -6px;
    right: -6px;
    cursor: ne-resize;
}

.handle-sw {
    bottom: -6px;
    left: -6px;
    cursor: sw-resize;
}

.handle-se {
    bottom: -6px;
    right: -6px;
    cursor: se-resize;
}

.handle-n {
    top: -6px;
    left: 50%;
    margin-left: -5px;
    cursor: n-resize;
}

.handle-s {
    bottom: -6px;
    left: 50%;
    margin-left: -5px;
    cursor: s-resize;
}

.handle-e {
    top: 50%;
    right: -6px;
    margin-top: -5px;
    cursor: e-resize;
}

.handle-w {
    top: 50%;
    left: -6px;
    margin-top: -5px;
    cursor: w-resize;
}

/* Bottom Panel logic */
#bottom-panel .btn-light {
    background-color: #f8f9fa;
    border-color: #dee2e6;
}

#bottom-panel .btn-light:hover {
    background-color: #e9ecef;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

/* Binding Visuals */
.bound-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px dashed #0d6efd;
    font-size: 14px;
    font-weight: bold;
    color: #0d6efd;
    z-index: 50;
    pointer-events: none;
    text-align: center;
    overflow: hidden;
    padding: 2px;
}

.bound-fragment {
    border-bottom: 2px dashed #0d6efd;
    color: #0d6efd;
    background-color: rgba(13, 110, 253, 0.1);
    font-weight: bold;
}

/* Rulers */
#ruler-h {
    position: absolute;
    top: -20px;
    left: 0;
    width: 100%;
    height: 20px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #ccc;
    z-index: 100;
    pointer-events: none;
    overflow: hidden;
}

#ruler-v {
    position: absolute;
    top: 0;
    left: -20px;
    width: 20px;
    height: 100%;
    background-color: #f8f9fa;
    border-right: 1px solid #ccc;
    z-index: 100;
    pointer-events: none;
    overflow: hidden;
}

#ruler-corner {
    position: absolute;
    top: -20px;
    left: -20px;
    width: 20px;
    height: 20px;
    background-color: #f8f9fa;
    border-right: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
    z-index: 101;
    color: #666;
    font-size: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ruler-tick {
    position: absolute;
    background-color: #999;
}

.ruler-label {
    position: absolute;
    font-size: 8px;
    color: #333;
    pointer-events: none;
}

/* Horizontal Ticks */
#ruler-h .ruler-tick {
    top: auto;
    bottom: 0;
    width: 1px;
}

#ruler-h .ruler-label {
    top: 0;
    transform: translateX(-50%);
}

/* Vertical Ticks */
#ruler-v .ruler-tick {
    left: auto;
    right: 0;
    height: 1px;
}

#ruler-v .ruler-label {
    left: 0;
    width: 100%;
    text-align: center;
    transform: translateY(-50%) rotate(-90deg);
}

/* Rotation Handle */
.handle-rotate {
    position: absolute;
    top: -25px;
    left: 50%;
    width: 1px;
    height: 20px;
    background-color: #0d6efd;
    margin-left: -0.5px;
    z-index: 1002;
    cursor: grab;
    display: none;
}

.handle-rotate::after {
    content: '';
    position: absolute;
    top: -5px;
    left: -4px;
    width: 10px;
    height: 10px;
    background-color: white;
    border: 1px solid #0d6efd;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.canvas-element.selected .handle-rotate {
    display: block;
}

.canvas-element.locked .handle-rotate {
    display: none !important;
}

/* Bootstrap Tags Input Fixes */
.bootstrap-tagsinput {
    width: 100%;
    line-height: 28px;
    padding: 6px 12px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    box-shadow: none;
    display: block;
}

.bootstrap-tagsinput .tag {
    margin-right: 2px;
    color: white;
    background-color: #0d6efd;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    display: inline-block;
}

.bootstrap-tagsinput input {
    border: none;
    box-shadow: none;
    outline: none;
    background-color: transparent;
    padding: 0 6px;
    margin: 0;
    width: auto;
    max-width: inherit;
    min-width: 80px;
}

/* Gentle pulse animation for the Examples button */
@keyframes gentle-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(255, 193, 7, 0);
    }

    50% {
        box-shadow: 0 0 8px 3px rgba(255, 193, 7, 0.45);
    }
}

.btn-gentle-pulse {
    animation: gentle-pulse 2.5s ease-in-out infinite;
}

@keyframes gentle-pulse-success {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(25, 135, 84, 0);
        transform: scale(1);
    }

    50% {
        box-shadow: 0 0 12px 6px rgba(25, 235, 120, 0.55), 0 0 20px 10px rgba(255, 255, 255, 0.15);
        transform: scale(1.05);
    }
}

.btn-gentle-pulse-success {
    animation: gentle-pulse-success 2.5s ease-in-out infinite;
}

/* Toolbar btn-outline-light: hover = gray icon on white, active = black icon on white */
.action-buttons .btn-outline-light:hover {
    background-color: #ffffff !important;
    color: #6c757d !important;
    border-color: #ffffff !important;
}

.action-buttons .btn-outline-light.active,
.action-buttons .btn-outline-light:active,
.action-buttons .btn-outline-light.active:hover {
    background-color: #ffffff !important;
    color: #000000 !important;
    border-color: #ffffff !important;
}