.canvas-container {
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: #e0e0e0;
    /* Light grey for light mode */
}

.dark .canvas-container {
    background-color: #2a2a2a;
    /* Darker grey for dark mode */
}

.canvas {
    position: relative;
    min-width: 2000px;
    min-height: 2000px;
    background-image:
        linear-gradient(#d1d1d1 1px, transparent 1px),
        linear-gradient(90deg, #d1d1d1 1px, transparent 1px);
    background-size: 20px 20px;
    background-color: #f5f5f5;
    /* Light grey for light mode canvas */
}

.dark .canvas {
    background-image:
        linear-gradient(#303030 1px, transparent 1px),
        linear-gradient(90deg, #303030 1px, transparent 1px);
    background-color: #272727;
    /* Dark grey for dark mode canvas */
}

/* Style for the selected object highlight */
.selected-object-highlight {
    box-shadow: 0 0 0 3px rgba(75, 85, 99, 0.7) !important;
    /* Gray-600 outline */
}

.pixel-grid,
.sketch-pad,
.text-box,
.image-container {
    position: absolute;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
    background-color: #f5f5f5;
    /* Light grey for light mode */
    overflow: hidden;
    z-index: 10;
    /* Base z-index for windows */
}

.dark .pixel-grid,
.dark .sketch-pad,
.dark .text-box,
.dark .image-container {
    background-color: #444444;
    /* Dark grey for dark mode */
}

/* Image container styles */
.image-container img {
    pointer-events: auto;
    /* Allow interaction with the image */
    user-select: none;
    /* Prevent selection */
}

.image-content-container {
    cursor: move;
    /* Show move cursor on image content */
}

/* Drop indicator for canvas */
.canvas-drop-indicator {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(75, 85, 99, 0.2);
    /* Gray-600 background */
    border: 2px dashed #4b5563;
    /* Gray-600 border */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    font-size: 24px;
    color: #4b5563;
    /* Gray-600 text */
    pointer-events: none;
}

.pixel {
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    display: block;
}

.pixel:hover {
    filter: brightness(0.9);
}

.color-swatch {
    width: 25px;
    height: 30px;
    min-width: 20px;
    /* Ensure they maintain square shape */
    border-radius: 2px;
    cursor: pointer;
    transition: transform 0.1s;
}

.color-swatch:hover {
    transform: scale(1.1);
}

.color-swatch.active {
    box-shadow: 0 0 0 2px white, 0 0 0 3px #4b5563;
}

.draggable-handle {
    cursor: move;
}

.resize-handle {
    width: 10px;
    height: 10px;
    background: #4b5563;
    position: absolute;
    right: 0;
    bottom: 0;
    cursor: nwse-resize;
}

.pixel-grid .resize-handle,
.sketch-pad .resize-handle {
    display: none;
}

.project-item {
    transition: all 0.2s;
}

.project-item:hover {
    background-color: rgba(75, 85, 99, 0.1);
}

.project-item.active {
    background-color: rgba(75, 85, 99, 0.3);
    border-left: 3px solid #4b5563;
}

/* Drag and drop styling for projects */
.project-item.dragging {
    opacity: 0.5;
    background-color: rgba(75, 85, 99, 0.2);
    /* Gray-600 background */
    border: 1px dashed rgba(75, 85, 99, 0.7);
    /* Gray-600 dashed border */
    cursor: grabbing;
}

.project-item.drag-over {
    box-shadow: 0 -2px 0 rgba(75, 85, 99, 0.7);
    /* Gray-600 line above */
}

.project-item .drag-handle {
    cursor: grab;
    padding: 2px;
    border-radius: 3px;
}

.project-item .drag-handle:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

/* Grid settings panel completely hidden */
.grid-settings-panel {
    display: none !important;
}

.grid-settings-panel.open {
    display: none !important;
    transform: none;
}

/* Grid settings popup styling */
#grid-settings-popup {
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-width: 90vw;
}

.dark #grid-settings-popup {
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#grid-settings-popup h3 {
    font-size: 16px;
}

#grid-settings-popup label {
    margin-bottom: 4px;
    display: block;
}

#grid-settings-popup input[type="color"] {
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.dark #grid-settings-popup input[type="color"],
.dark #grid-settings-popup input[type="text"] {
    border-color: rgba(255, 255, 255, 0.1);
}

.context-menu {
    position: absolute;
    z-index: 1000;
    background: #f5f5f5;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    min-width: 150px;
    overflow: hidden;
}

.dark .context-menu {
    background: #444444;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.context-menu-item {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.context-menu-item:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.dark .context-menu-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: #f5f5f5;
    border-radius: 8px;
    padding: 20px;
    max-width: 500px;
    width: 90%;
}

.dark .modal-content {
    /* background: #444444; */
    background: #515760;
}

.settings-panel {
    display: none !important;
    /* Ensure it's never shown */
}

/* Remove transition from settings panel */
.settings-panel.open {
    display: none !important;
    transform: none;
}

/* Sketch pad canvases should be transparent */
.sketch-pad-canvas {
    background-color: transparent !important;
    cursor: crosshair;
}

.dark .sketch-pad-canvas {
    background-color: transparent !important;
}

.text-box {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.text-box .draggable-handle {
    flex-shrink: 0;
    /* Prevent header from shrinking */
}

.text-box-content-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    padding: 10px;
    box-sizing: border-box;
}

.text-box-content {
    width: 100%;
    height: 100%;
    padding: 4px;
    margin: 0;
    resize: none;
    border: none;
    outline: none;
    background-color: transparent;
    font-family: inherit;
    overflow: auto;
    box-sizing: border-box;
}

.tool-button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.tool-button:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.dark .tool-button:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Resizable panel styles */
.resizable-panel {
    position: relative;
    transition: width 0.1s ease;
    min-width: 120px;
    /* Prevent panels from becoming too narrow */
}

.resizer-panel {
    position: absolute;
    right: -2px;
    /* Position slightly outside to make it easier to grab */
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: transparent;
    cursor: col-resize;
    z-index: 20;
    /* Ensure it's above other content */
}

.resizer-panel:hover {
    background-color: rgba(75, 85, 99, 0.5);
    width: 4px;
}

.resizer-panel.active {
    background-color: rgba(75, 85, 99, 0.7);
    width: 4px;
}

.pixel-container {
    display: grid;
    width: 100%;
    height: 100%;
    border: none;
    margin: 0;
    padding: 0;
    gap: 0;
    line-height: 0;
}

.pixel-grid {
    padding: 0 !important;
    line-height: 0;
}

.pixel-grid .draggable-handle {
    line-height: normal;
}

/* Dark mode text and icon improvements */
.dark .project-item,
.dark h1,
.dark h2,
.dark h3,
.dark .tool-button,
.dark .fa,
.dark .fas {
    color: #e2e8f0;
}

.dark .project-item.active {
    background-color: rgba(255, 255, 255, 0.2);
    border-left-color: #1f93ff;
}

/* Logo styling with better dark mode contrast */
h1.text-primary {
    font-weight: bold;
}

.dark h1.text-primary {
    color: #ffffff !important;
}

/* Ensure projects sidebar has good contrast in dark mode */
.dark #projects-list .project-item i {
    color: #e2e8f0;
    /* Light color for icons */
    opacity: 0.9;
}

.dark #projects-list .project-item span {
    color: #e2e8f0;
    /* Light color for text */
    opacity: 0.9;
}

.dark #projects-list .project-item:hover i,
.dark #projects-list .project-item:hover span,
.dark #projects-list .project-item.active i,
.dark #projects-list .project-item.active span {
    opacity: 1;
    color: #ffffff;
}

/* Improve header contrast in dark mode */
.dark header h1 {
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Improve button contrast in dark mode */
.dark button.text-gray-800 {
    color: #e2e8f0 !important;
}

.dark button:hover {
    filter: brightness(1.1);
}

/* Improve tool buttons in dark mode */
.dark .tool-button {
    color: #e2e8f0;
    border: 1px solid transparent;
}

.dark .tool-button:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background-color: rgba(255, 255, 255, 0.1);
}

/* Ensure sidebar headings have good contrast */
.dark .w-64 h2,
.dark .w-64 h3,
.dark .w-48 h2 {
    color: #ffffff;
    opacity: 0.95;
}

/* Fix the app title in header */
header h1.text-xl {
    font-weight: bold;
}

.dark header h1.text-xl {
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Improve icon contrast in header buttons */
.dark header button i.fa,
.dark header button i.fas {
    color: #ffffff;
    opacity: 0.9;
}

.dark header button:hover i.fa,
.dark header button:hover i.fas {
    opacity: 1;
}

/* Grid buttons in dark mode */
.dark .grid-btn i {
    color: #ffffff !important;
}

/* Light text color in dark mode */
.dark .text-light-text {
    color: #f0f4f8 !important;
}

/* Settings popup styling */
#settings-popup {
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-width: 90vw;
}

.dark #settings-popup {
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#settings-popup h3 {
    font-size: 16px;
}

#settings-popup label {
    margin-bottom: 4px;
    display: block;
}

#settings-popup input[type="color"] {
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.dark #settings-popup input[type="color"] {
    border-color: rgba(255, 255, 255, 0.1);
}

/* Text box header slider styles - now applies to both text size and pencil size sliders */
.text-size-slider,
.pencil-size-slider {
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.3);
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
    padding: 0;
    margin: 0 4px;
    position: relative;
}

/* Wider hit area for the slider to make interaction easier */
.text-size-slider::before,
.pencil-size-slider::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 0;
    right: 0;
    bottom: -8px;
    z-index: -1;
}

.text-size-slider::-webkit-slider-thumb,
.pencil-size-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    margin-top: -4px;
    position: relative;
    z-index: 2;
}

.text-size-slider::-moz-range-thumb,
.pencil-size-slider::-moz-range-thumb {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.text-size-value,
.pencil-size-value {
    min-width: 30px;
    text-align: right;
    user-select: none;
}

.text-box .draggable-handle .fa-text-height {
    pointer-events: none;
    user-select: none;
}

/* Prevent text selection in UI elements */
.draggable-handle,
.tool-button,
.project-item,
header,
h1,
h2,
h3,
h4,
h5,
h6,
.color-swatch,
.text-size-value,
button span,
.grid-btn {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Make images resizable */
.image-container .resize-handle {
    display: block;
}

/* Override the image-container to allow resize */
.image-container {
    resize: both;
    padding-bottom: 10px;
    /* Space for the resize handle */
}

/* Make resizers more visible on hover */
.resizer-panel {
    transition: background-color 0.2s ease, opacity 0.2s ease;
    opacity: 0.3;
}

.resizable-panel:hover .resizer-panel {
    opacity: 0.7;
    background-color: rgba(75, 85, 99, 0.5);
    /* Gray-600 color */
}

.resizer-panel:hover,
.resizer-panel.active {
    opacity: 1;
    background-color: rgba(75, 85, 99, 0.8);
    /* Gray-600 color */
    box-shadow: 0 0 0 1px rgba(75, 85, 99, 0.5);
    /* Gray-600 shadow */
}

/* Style for the selected object highlight */
.selected-object-highlight {
    box-shadow: 0 0 0 3px rgba(0, 179, 255, 0.7) !important;
    /* Gray-600 outline, !important to override others */
    /* ensure it does not interfere with resize handles if possible */
}

.dark .image-container {
    background-color: #444444;
    /* Dark grey for dark mode */
}

.grid-btn {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 2px 4px;
    border-radius: 2px;
    transition: background-color 0.2s;
}

.grid-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.grid-btn.active-tool {
    background-color: rgba(75, 85, 99, 0.7) !important;
    /* Gray-600 highlight */
    color: white;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.3);
}

/* Color palette popup styling */
.color-palette-popup {
    position: absolute;
    z-index: 1000;
    background-color: #f5f5f5;
    border-radius: 6px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    padding: 8px;
    display: none;
}

.dark .color-palette-popup {
    background-color: #444444;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}

.color-palette-popup .popup-colors {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    max-width: 150px;
}

.color-palette-popup .color-swatch {
    width: 20px;
    height: 20px;
    min-width: 20px;
    border-radius: 2px;
    cursor: pointer;
    transition: transform 0.1s;
}

.color-palette-popup .color-swatch:hover {
    transform: scale(1.2);
}

/* Radial color wheel */
.radial-color-wheel {
    position: absolute;
    width: 0;
    height: 0;
    z-index: 2000;
    pointer-events: none;
    /* allow clicks to pass to swatches */
}

.radial-color-wheel .radial-swatch {
    position: absolute;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    pointer-events: auto;
    /* enable click */
    transition: transform 0.1s;
}

.radial-color-wheel .radial-swatch:hover {
    transform: scale(1.2);
}

.multi-color-btn {
    position: relative;
    overflow: hidden;
}

.multi-color-btn i {
    background: linear-gradient(135deg, #F93C31, #FFDC00, #4FCC30, #1E93FF, #E53AA3);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent !important;
    font-weight: bold;
}

/* Make resize handle visible for sketch pads */
.sketch-pad .resize-handle {
    display: block;
    cursor: nwse-resize;
    z-index: 20;
}

/* Update header text color to be white for better contrast with dark header background */
header {
    color: white;
}

header h1,
header span,
header button:not(.bg-primary):not(.bg-green-600):not(.bg-blue-600) {
    color: white !important;
}

header button:not(.bg-primary):not(.bg-green-600):not(.bg-blue-600) .fas {
    color: white !important;
}

/* Make resize handle visible for grids */
.pixel-grid .resize-handle {
    display: block;
    cursor: nwse-resize;
    z-index: 20;
}

/* Global drawing tools size and active highlight */
#global-pencil-tool,
#global-rect-tool,
#global-rect-border-tool,
#global-fill-tool {
    /* Larger padding for emphasis */
    padding: 8px 14px;
}

#global-pencil-tool i,
#global-rect-tool i,
#global-rect-border-tool i,
#global-fill-tool i {
    /* Larger icon size */
    font-size: 1.1rem;
}

/* Highlight the active global tool */
.tool-button.active-tool {
    background-color: rgba(75, 85, 99, 0.8) !important;
    color: white !important;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5);
}

.wheel-tool {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: background 0.2s;
    pointer-events: none;
    /* clicks handled by canvas wedges */
}

.wheel-tool:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* Icon inside outer wheel tool wedge */
.wheel-icon {
    font-size: 20px;
    color: #ffffff;
    pointer-events: none;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.6);
}

/* Thicker border for sketch pads */
.sketch-pad {
    /* inner shadow */
    box-shadow: inset 0 0 0 20px #e3cb44 !important;
}

/* Project Info Panel Vertical Resizing */
.vertical-resizable-panel {
    position: relative;
}

.vertical-resizable-panel .resizer-horizontal {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 6px;
    cursor: row-resize;
    background-color: transparent;
    z-index: 20;
    background-color: rgb(217, 217, 217);
}

.vertical-resizable-panel .resizer-horizontal:hover,
.vertical-resizable-panel .resizer-horizontal.active {
    background-color: rgba(0, 153, 255, 0.717);
}

/* Project Info Panel Textarea Styles */
#project-info-content textarea {
    background-color: #f5f5f5;
    color: #000000 !important;
    border-color: #cccccc;
}

.dark #project-info-content textarea {
    background-color: #97b6ba;
    color: #000000 !important;
    border-color: #666666;
    line-height: 1.1;
}

/* Darker placeholder text for project info textareas */
#project-info-content textarea::placeholder {
    color: #666666 !important;
    opacity: 1 !important;
    font-style: italic;
}

.dark #project-info-content textarea::placeholder {
    color: #636363 !important;
    opacity: 1 !important;
    font-style: italic;
}

/* Minimal thin dark-mode scrollbars */
html {
    /* Firefox */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.4) transparent;
}

.dark html {
    /* Firefox dark mode */
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

/* WebKit */
html::-webkit-scrollbar {
    width: 6px;
    height: 6px;
    background: transparent;
}

html::-webkit-scrollbar-track {
    background: transparent;
}

html::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.4);
    border-radius: 3px;
}

.dark html::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.3);
}

html::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.6);
}

/* Multi-select marquee selection box */
.selection-box {
    pointer-events: none;
    position: fixed;
    z-index: 10000;
    border: 1px dashed #4b5563;
    background-color: rgba(75, 85, 99, 0.1);
}

.grid-btn.game-play-btn:hover {
    background: rgba(0, 0, 0, .06);
}

.splash-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background-color: #111;
    /* optional: dark background */
}

.gridmaker-splash {
    position: relative;
    width: 100%;
    max-width: 1024px;
    aspect-ratio: 4 / 3;
    background-image: url('/img/gridmaker_splash.png');
    background-size: cover;
    background-position: center;
    border: 2px solid #333;
    box-shadow: 0 0 5px 2px rgba(125.0, 125.0, 125.0, 0.7);
    border-radius: 20px;
    margin: 0 auto;
    font-family: sans-serif;
}

.overlay-content {
    position: absolute;
    top: 0;
    left: 0;
    padding: 1rem;
    color: white;
    text-shadow: 1px 1px 3px #000;
    width: 100%;
    height: 100%;
}

.overlay-content h1 {
    font-size: 3rem;
    position: absolute;
    top: 5%;
    left: 5%;
}

.overlay-content h2 {
    font-size: 3rem;
}

.google-login-button {
    position: relative;
    top: 90%;
    left: 70%;
    display: inline-block;
    background-color: #4285F4;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    font-size: 1.2rem;
    text-decoration: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: background-color 0.3s;
}

.google-login-button:hover {
    background-color: #357ae8;
}

.workspace-item {
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
}

.workspace-item i {
    margin-right: 8px;
    color: #555;
}

.workspace-item:hover {
    background-color: #70707070;
}

.workspace-creator {
    display: flex;
    position: absolute;
    bottom: 0px;
    width: 100%;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    border-radius: 0 0 20px 20px;
    background: rgba(0, 0, 0, 0.5);
}

.workspace-creator input[type="text"] {
    flex: 1;
    padding: 0.5rem;
    font-size: 1rem;
    border-radius: 4px;
    color: black;
    border: none;
}

.workspace-creator button {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    background-color: #4285F4;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s;
}

.workspace-creator button:hover {
    background-color: #357ae8;
}