:root {
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --grid-color: rgba(255, 255, 255, 0.05);
    --toolbar-bg: rgba(30, 41, 59, 0.7);
    --toolbar-border: rgba(255, 255, 255, 0.1);
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --btn-hover: rgba(255, 255, 255, 0.1);
    --active-color: #60a5fa;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    overflow: hidden; /* Prevent native scrolling, handled by canvas */
    width: 100vw;
    height: 100vh;
}

#canvas-container {
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(to right, var(--grid-color) 1px, transparent 1px),
        linear-gradient(to bottom, var(--grid-color) 1px, transparent 1px);
    background-size: 50px 50px;
    background-position: center center;
    cursor: default;
}

/* Glassmorphism Toolbar */
.toolbar {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    padding: 6px;
    background: var(--toolbar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--toolbar-border);
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.tool-btn {
    background: transparent;
    border: none;
    color: var(--text-color);
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tool-btn svg {
    width: 18px;
    height: 18px;
}

.tool-btn:hover {
    background: var(--btn-hover);
}

.tool-btn.active {
    background: rgba(59, 130, 246, 0.2);
    color: var(--active-color);
}

.divider {
    width: 1px;
    background: var(--toolbar-border);
    margin: 0 4px;
}

/* Sub-Toolbar (Pen options) */
.sub-toolbar {
    bottom: 80px;
}

.sub-toolbar.hidden {
    display: none;
}

.color-picker, .width-picker {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 0 4px;
}

.color-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.2s;
}

.color-btn:hover {
    transform: scale(1.1);
}

.color-btn.active {
    border-color: #fff;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.width-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.width-btn:hover {
    background: var(--btn-hover);
}

.width-btn.active {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.width-dot {
    background-color: var(--text-color);
    border-radius: 50%;
}

/* Radial Menu */
.radial-menu {
    position: absolute;
    width: 0;
    height: 0;
    z-index: 100;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.radial-menu.hidden {
    display: none;
}

.radial-btn {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--toolbar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--toolbar-border);
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
}

.radial-btn:hover {
    background: var(--btn-hover);
    transform: translate(-50%, -50%) scale(1.15);
    color: var(--active-color);
}

.radial-center {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Hidden Text Area for editing canvas text */
#text-editor {
    position: absolute;
    top: 0;
    left: 0;
    margin: 0;
    padding: 0;
    border: none;
    outline: none;
    resize: none;
    background: transparent;
    overflow: hidden;
    color: #fff;
    font-family: Arial, sans-serif;
    transform-origin: left top;
    z-index: 5;
    /* Invisible until activated */
    display: none;
}

/* Sidebar Styles */
.sidebar {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 300px;
    max-height: calc(100vh - 40px);
    background: var(--toolbar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--toolbar-border);
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    z-index: 20;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: left center;
}

.sidebar.collapsed {
    transform: translateX(calc(-100% - 20px));
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--toolbar-border);
}

.sidebar-tabs {
    display: flex;
    gap: 8px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-content {
    padding: 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Sidebar Inputs */
.sidebar-input-container {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--toolbar-border);
    border-radius: 8px;
    padding: 8px;
    display: flex;
    flex-direction: column;
}

.sidebar-input {
    background: transparent;
    border: none;
    color: var(--text-color);
    font-family: inherit;
    font-size: 14px;
    resize: none;
    outline: none;
    min-height: 40px;
}

.sidebar-input:focus {
    color: #fff;
}

/* Toggle button when collapsed */
#toggle-sidebar.collapsed-btn {
    position: absolute;
    right: -50px;
    background: var(--toolbar-bg);
    border: 1px solid var(--toolbar-border);
}

/* Project Modal & Buttons */
.floating-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--toolbar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--toolbar-border);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    z-index: 20;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: #1e293b;
    border: 1px solid var(--toolbar-border);
    border-radius: 16px;
    width: 400px;
    max-width: 90vw;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--toolbar-border);
}

.modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.current-project {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.current-project label {
    font-size: 12px;
    text-transform: uppercase;
    color: #94a3b8;
    letter-spacing: 0.5px;
}

.modal-input {
    background: #0f172a;
    border: 1px solid var(--toolbar-border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 16px;
    color: #fff;
    width: 100%;
}

.primary-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    transition: background 0.2s;
    width: 100%;
}

.primary-btn:hover {
    background: var(--primary-hover);
}

.project-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.project-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.project-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.project-item.active {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

.project-item-name {
    font-weight: 500;
}

.project-item-date {
    font-size: 12px;
    color: #94a3b8;
}

.delete-btn {
    background: transparent;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
}

.delete-btn:hover {
    background: rgba(239, 68, 68, 0.2);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid var(--toolbar-border);
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    transition: background 0.2s;
    width: 100%;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #94a3b8;
}

.breadcrumb-item {
    cursor: pointer;
    transition: color 0.2s;
    display: flex;
    align-items: center;
}

.breadcrumb-item:hover {
    color: #fff;
}

.breadcrumb-item.active {
    color: #fff;
    font-weight: 500;
    cursor: default;
}

.breadcrumb-separator {
    color: #475569;
}

.folder-item {
    background: rgba(59, 130, 246, 0.05);
}

.folder-item:hover {
    background: rgba(59, 130, 246, 0.15);
}
