:root {
    --bg-dark: #050505;
    --bg-slate: #0b0c10;
    --panel-bg: rgba(20, 22, 28, 0.7);
    --border-glass: rgba(255, 255, 255, 0.08);
    --accent-primary: #0ea5e9;
    --text-light: #f8fafc;
    --text-muted: #94a3b8;
    --font-main: 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-dark);
    color: var(--text-light);
    height: 100vh;
    overflow: hidden;
    display: flex;
}

.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-slate);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-close {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-light);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
}

.sidebar-header {
    margin-bottom: 2rem;
}

.app-logo {
    width: 32px;
    height: 32px;
}

.sidebar-menu {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.menu-item {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-light);
}

.menu-item.active {
    background: rgba(14, 165, 233, 0.1);
    color: var(--accent-primary);
    border-left: 3px solid var(--accent-primary);
}

.btn {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    font-family: var(--font-main);
    cursor: pointer;
    border: none;
    transition: all 0.3s;
    text-align: center;
}

.btn.primary {
    background: var(--accent-primary);
    color: white;
}

.btn.primary:hover {
    background: #0284c7;
}

.btn.secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-light);
    border: 1px solid var(--border-glass);
}

.btn.secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.full-width {
    width: 100%;
}

/* Workspace */
.workspace {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background-image: 
        radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-position: 0 0, 20px 20px;
    background-size: 40px 40px;
}

.toolbar {
    height: 60px;
    background: rgba(11, 12, 16, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    justify-content: space-between;
    z-index: 10;
    overflow-x: auto;
    gap: 1rem;
}

.mobile-only {
    display: none;
}

.tool-group {
    display: flex;
    gap: 0.5rem;
}

.tool-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: 100px;
    font-family: var(--font-main);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.tool-btn:hover {
    color: var(--text-light);
    background: rgba(255, 255, 255, 0.05);
}

.tool-btn.active {
    background: rgba(14, 165, 233, 0.15);
    border-color: rgba(14, 165, 233, 0.3);
    color: var(--accent-primary);
}

.clear-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

/* Canvas Area */
.canvas-wrapper {
    flex-grow: 1;
    position: relative;
    overflow: auto; 
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    padding: 4rem; /* Buffer for zooming */
    
    /* Custom Scrollbar Styles */
    scrollbar-width: thin;
    scrollbar-color: var(--accent-primary) transparent;
}

.canvas-wrapper::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.canvas-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.canvas-wrapper::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 10px;
}

.canvas-wrapper::-webkit-scrollbar-thumb:hover {
    background: #0284c7;
}

#workspace-inner {
    position: relative;
    box-shadow: 0 20px 50px rgba(0,0,0,0.6);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: 0 0;
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    background-color: transparent;
}

#textLayer {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1; /* Between canvases */
    pointer-events: none;
    outline: none;
    padding: 25px 2rem 0; 
    line-height: 40px;
    font-family: var(--font-main);
    font-size: 20px;
    color: #000000;
    white-space: pre-wrap;
    word-wrap: break-word;
}

#fgCanvas {
    z-index: 2;
    cursor: crosshair;
    touch-action: none;
}

.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 0;
    pointer-events: none;
    color: var(--text-muted);
}

.empty-state h3 {
    margin-bottom: 0.5rem;
    color: var(--text-light);
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 90;
}

.sidebar-overlay.active {
    display: block;
}

/* Responsive Queries */
@media (max-width: 768px) {
    .mobile-only {
        display: flex;
    }

    .btn-text {
        display: none;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 80%;
        max-width: 300px;
        transform: translateX(-100%);
        box-shadow: 20px 0 50px rgba(0,0,0,0.5);
        z-index: 1000; /* Ensure it is above everything */
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .sidebar-close {
        display: block;
    }

    .toolbar {
        padding: 0 1rem;
    }

    .tool-btn {
        padding: 0.5rem 0.75rem;
        font-size: 1.1rem; /* Make icons slightly larger */
    }

    .canvas-wrapper {
        padding: 1rem;
    }

    #zoom-level {
        display: none; /* Hide zoom % on mobile to save space */
    }
}
