:root {
    /* Color System */
    --primary-color: #6366f1; /* Indigo */
    --primary-hover: #4f46e5;
    --bg-color: #f8fafc; /* Slate 50 */
    --surface-color: #ffffff;
    --sidebar-bg: #ffffff;
    --border-color: #e2e8f0; /* Slate 200 */
    --text-primary: #1e293b; /* Slate 800 */
    --text-secondary: #64748b; /* Slate 500 */
    --canvas-bg: #e2e8f0;
    
    /* Layout */
    --header-height: 60px;
    --sidebar-width: 320px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden; /* Prevent body scroll, layout handles scrolling */
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Top Navigation Bar */
.top-bar {
    height: var(--header-height);
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 100;
}

.logo-area h1 {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: 0.05em;
    background: none;
    -webkit-text-fill-color: initial;
    animation: none;
    display: flex;
    align-items: center;
    gap: 0;
}

.file-name-container {
    flex: 1;
    display: flex;
    justify-content: center;
}

.filename-input-group {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: 6px;
    transition: all 0.2s;
    background: transparent;
}

.filename-input-group:hover {
    background: var(--bg-color);
}

.filename-input-group:focus-within {
    background: var(--surface-color);
    border-color: var(--primary-color);
}

#wrapName {
    text-align: right;
    border: none;
    background: transparent;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    padding: 0;
    width: 140px;
    outline: none;
}

.extension {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-left: 2px;
    user-select: none;
}

.header-actions .btn-primary {
    background: var(--text-primary); /* Black/Dark styling for Tesla vibe */
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: transform 0.1s, opacity 0.2s;
}

.header-actions .btn-primary:hover:not(:disabled) {
    opacity: 0.9;
    transform: translateY(-1px);
}

.header-actions .btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Main Workspace */
.main-workspace {
    display: flex;
    flex: 1;
    height: calc(100vh - var(--header-height));
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.section-label {
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
}

/* Select Styling */
.select-wrapper {
    position: relative;
}

select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-color);
    font-size: 0.95rem;
    color: var(--text-primary);
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
}

select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Tools Grid */
.tools-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.hidden-file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 10;
}

.tool-button {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem 0.5rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    height: 100px;
    color: var(--text-primary);
}

.tool-button:hover:not(:disabled) {
    border-color: var(--primary-color);
    background: var(--bg-color);
}

.tool-button:active:not(:disabled) {
    transform: scale(0.98);
}

.tool-button.dragover {
    border-color: var(--primary-color);
    background: #eef2ff; /* Indigo 50 */
    border-style: dashed;
}

.tool-button:disabled,
.tool-button[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--bg-color);
    pointer-events: none;
    color: var(--text-primary);
    border-color: var(--border-color);
}

.icon-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.tool-button:hover .icon-circle {
    background: #e0e7ff;
    color: var(--primary-color);
}

.tool-button span {
    font-size: 0.85rem;
    font-weight: 500;
}

/* Style Controls */
.style-controls {
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.style-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.font-select {
    background-color: var(--surface-color);
}

.style-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.icon-btn:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.icon-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Color Palette */
.color-palette {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.1s;
}

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

.color-swatch.active {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px var(--surface-color), 0 0 0 4px var(--primary-color);
}

.rainbow-swatch {
    background: linear-gradient(135deg, #ff0000, #00ff00, #0000ff);
}

.hidden-color-input {
    width: 0;
    height: 0;
    opacity: 0;
    position: absolute;
    pointer-events: none;
}

/* Layers List */
.layers-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.image-item {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.image-item:hover {
    border-color: var(--primary-color);
}

.image-item.selected {
    border-color: var(--primary-color);
    background: #eef2ff;
}

.image-item img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    background: #fff;
    border: 1px solid var(--border-color);
}

.image-actions {
    margin-left: auto;
}

.remove-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
}

.remove-btn:hover {
    background: #fee2e2;
    color: #ef4444;
}

/* Canvas Stage */
.canvas-stage {
    flex: 1;
    background: var(--canvas-bg);
    /* Dotted pattern background */
    background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
    background-size: 20px 20px;
    
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 2rem;
    overflow: hidden;
}

.canvas-wrapper {
    position: relative;
    background: transparent;
    /* Ensure canvas is centered */
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

canvas {
    max-width: 100%;
    max-height: 90vh; /* Allow it to be taller */
    /* Removed background: white to let dots show through transparent areas */
    /* background: white; */ 
    /* Removed shadow for cleaner look on dots */
    /* box-shadow: var(--shadow-lg); */
}

.instructions {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    text-align: center;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 500;
}

/* Vehicle Preview (Bottom Left of Canvas Stage) */
/* Removed absolute vehicle preview, now in sidebar */


/* Status Bar */
.status-bar {
    margin-top: 1rem;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(4px);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    box-shadow: var(--shadow-sm);
    z-index: 5;
}

.note {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Text Editor Overlay */
.text-editor-overlay {
    position: absolute;
    background: rgba(255, 255, 255, 0.8);
    border: 1px dashed #667eea;
    padding: 0;
    margin: 0;
    outline: none;
    resize: none;
    overflow: hidden;
    z-index: 1000;
    white-space: pre;
    display: none;
    /* Font styles will be set by JS */
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        height: auto;
        overflow-y: auto;
    }

    .main-workspace {
        flex-direction: column;
        height: auto;
    }

    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        order: 2; /* Move sidebar below canvas on mobile */
    }
    
    .canvas-stage {
        order: 1;
        min-height: 50vh;
        padding: 1rem;
    }

    .top-bar {
        padding: 0 1rem;
    }
    
    #wrapName {
        width: 150px;
    }
}
