:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: rgba(59, 130, 246, 0.15);
    --bg-dark: #090d16;
    --card-bg: rgba(17, 24, 39, 0.75);
    --toolbar-bg: rgba(9, 13, 22, 0.95);
    --border: rgba(255, 255, 255, 0.1);
    --border-hover: rgba(255, 255, 255, 0.25);
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --danger: #ef4444;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Prevent scrolling since it's a full-screen canvas app */
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1.5rem;
    background: var(--toolbar-bg);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    z-index: 100;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #fff;
    font-weight: 700;
    font-size: 1.25rem;
}

.logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.back-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--primary);
}

.lang-select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
}

.lang-select option {
    background: #111827;
    color: #fff;
}

/* Main Workspace */
.workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Toolbar Panel */
.toolbar-panel {
    width: 260px;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 1.5rem;
    overflow-y: auto;
    z-index: 10;
}

[dir="rtl"] .toolbar-panel {
    border-right: 1px solid var(--border);
    border-left: none;
}
[dir="ltr"] .toolbar-panel {
    border-left: 1px solid var(--border);
    border-right: none;
}


.tool-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tool-section-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.tool-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.tool-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.75rem 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.tool-btn.active {
    background: var(--primary-light);
    border-color: var(--primary);
    color: #fff;
}

.tool-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border-hover);
}

.tool-icon {
    font-size: 1.2rem;
}

/* Properties */
.prop-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.prop-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.prop-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: #fff;
    padding: 0.5rem;
    outline: none;
}

.prop-input[type="color"] {
    padding: 0;
    height: 38px;
    cursor: pointer;
}
.prop-input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}
.prop-input[type="color"]::-webkit-color-swatch {
    border-radius: 4px;
    border: none;
}

.prop-input[type="range"] {
    padding: 0;
    height: 6px;
    border: none;
    background: var(--border);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    margin-top: 10px;
    margin-bottom: 10px;
}

.prop-input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
}

/* Action Buttons */
.action-btn {
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}

/* Canvas Area */
.canvas-container-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #1f2937; /* Dark gray behind the canvas */
    background-image: linear-gradient(45deg, #111827 25%, transparent 25%, transparent 75%, #111827 75%, #111827), 
                      linear-gradient(45deg, #111827 25%, transparent 25%, transparent 75%, #111827 75%, #111827);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
    overflow: auto;
    padding: 2rem;
}

.canvas-shadow-wrapper {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    background-color: #ffffff; /* Default canvas color */
    border-radius: 4px;
    /* Fabric JS canvas container will go here */
}

/* File input hidden */
#imageUploadInput {
    display: none;
}

@media (max-width: 768px) {
    body {
        overflow: auto;
    }
    .workspace {
        flex-direction: column-reverse;
        height: calc(100dvh - 60px);
    }
    .toolbar-panel {
        width: 100% !important;
        max-height: 180px;
        flex-direction: row;
        flex-wrap: wrap;
        overflow-x: auto;
        overflow-y: auto;
        padding: 0.65rem;
        gap: 0.75rem;
        border-top: 1px solid var(--border);
        border-right: none !important;
        border-left: none !important;
    }
    .tool-section {
        flex-direction: row;
        align-items: center;
        gap: 0.4rem;
    }
    .tool-section-title {
        display: none;
    }
    .tool-grid {
        display: flex;
        flex-wrap: nowrap;
        gap: 0.35rem;
    }
    .tool-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
        flex-shrink: 0;
    }
    .canvas-container-wrapper {
        padding: 0.5rem;
        flex: 1;
        width: 100vw;
    }
}
