:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-dark: #f8fafc;
    --bg-panel: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-light: #64748b;
    --header-height: 60px;
    --sidebar-width: 320px;
    --properties-width: 280px;
}

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    color: var(--text);
    background-color: var(--bg-dark);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Top Nav */
.top-nav {
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    justify-content: space-between;
    flex-shrink: 0;
}

.brand {
    font-weight: 600;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-links {
    display: flex;
    gap: 1rem;
}

.nav-btn {
    border: none;
    background: none;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
}

.nav-btn.active,
.nav-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
}

/* Main Main */
#app-content {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.view {
    display: none;
    height: 100%;
    width: 100%;
}

.view.active {
    display: block;
}

/* Editor Layout */
.editor-layout {
    display: flex;
    height: 100%;
}

/* Sidebar Left */
.sidebar-left {
    width: var(--sidebar-width);
    background: white;
    border-right: 1px solid var(--border);
    display: flex;
}

.sidebar-tabs {
    width: 50px;
    background: #f1f5f9;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 1rem;
    gap: 0.5rem;
}

.tab-btn {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.sidebar-panels {
    flex: 1;
    overflow-y: auto;
    background: white;
}

.panel {
    display: none;
    padding: 1rem;
}

.panel.active {
    display: block;
}

.panel h3 {
    margin-top: 0;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
}

/* Grid Lists for Images */
.grid-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-top: 1rem;
}

.asset-item {
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    cursor: grab;
    background: #eee;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.asset-item img,
.asset-item canvas {
    max-width: 100%;
    max-height: 100%;
}

.asset-item:hover {
    border-color: var(--primary);
}

.delete-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(255, 255, 255, 0.8);
    border: none;
    color: red;
    cursor: pointer;
    display: none;
}

.asset-item:hover .delete-btn {
    display: block;
}

/* Canvas Area */
.canvas-area {
    flex: 1;
    background: #e2e8f0;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.toolbar {
    height: 50px;
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 1rem;
}

.canvas-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 2rem;
}

#label-canvas {
    background: white;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    position: relative;
    background-size: cover;
    background-position: center;
}

/* Canvas Elements */
.canvas-element {
    position: absolute;
    cursor: grab;
    border: 1px dashed transparent;
    user-select: none;
    box-sizing: border-box;
}

.canvas-element:hover {
    border-color: var(--primary);
}

.canvas-element.selected {
    border: 1px solid var(--primary);
    z-index: 9999 !important;
    /* Always show selected on top for editing, or handle strictly? */
}

/* Resize Handles (Simplified for now) */
.resize-handle {
    width: 8px;
    height: 8px;
    background: var(--primary);
    position: absolute;
    bottom: -4px;
    right: -4px;
    cursor: se-resize;
    display: none;
}

.canvas-element.selected .resize-handle {
    display: block;
}

/* Right Sidebar */
.sidebar-right {
    width: var(--properties-width);
    background: white;
    border-left: 1px solid var(--border);
    padding: 1rem;
    overflow-y: auto;
}

/* Utils */
.btn-sm {
    padding: 4px 8px;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    cursor: pointer;
    background: white;
    border-radius: 4px;
}

.btn-sm:hover {
    background: #f1f5f9;
}

button.primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
}

button.primary:hover {
    background: var(--primary-hover);
}

button.ghost {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    margin-bottom: 0.2rem;
    color: var(--text-light);
}

.form-group input {
    width: 100%;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    box-sizing: border-box;
}

/* Layer List */
.layer-item {
    display: flex;
    justify-content: space-between;
    padding: 8px;
    border-bottom: 1px solid #eee;
    background: white;
    cursor: pointer;
}

.layer-item.selected {
    background: #eef2ff;
    border-left: 3px solid var(--primary);
}

.layer-controls button {
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
}

/* Table Lists (Formats, Archive) */
.container {
    padding: 2rem;
    max-width: 1000px;
    margin: 0 auto;
}

.form-inline {
    display: flex;
    gap: 10px;
    margin-bottom: 2rem;
}

.table-list table {
    width: 100%;
    border-collapse: collapse;
}

.table-list th {
    text-align: left;
    border-bottom: 2px solid var(--border);
    padding: 10px;
}

.table-list td {
    border-bottom: 1px solid var(--border);
    padding: 10px;
}