/* --- SLED-BOX DESIGN SYSTEM --- */
:root {
    --bg-deep: #0f0f0f;
    --bg-sidebar: #1a1a1a;
    --accent: #FF4400;
    --text: #e0e0e0;
    --text-dim: #888;
    --border: #2a2a2a;
    --star: #FFD700;
    --warning: #ffcc00;
    --danger: #ff4444;
    --btn-active: #333;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; 
    background: var(--bg-deep); 
    color: var(--text); 
    height: 100vh; 
    display: flex; 
    overflow: hidden; 
}

/* --- SIDEBARS --- */
#workspace-sidebar { 
    width: 60px; 
    background: var(--bg-deep); 
    border-right: 1px solid var(--border); 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    padding: 20px 0; 
    gap: 15px; 
}

#snippet-sidebar { 
    width: 280px; 
    background: var(--bg-sidebar); 
    border-right: 1px solid var(--border); 
    display: flex; 
    flex-direction: column; 
}

.ws-icon { 
    width: 36px; height: 36px; border-radius: 8px; 
    display: flex; align-items: center; justify-content: center; 
    cursor: pointer; font-weight: bold; font-size: 14px; transition: 0.2s; 
    filter: grayscale(0.8); border: 1px solid transparent; 
    color: white; background: #222; position: relative; overflow: hidden;
}
.ws-icon.active { filter: grayscale(0); border-color: white; box-shadow: 0 0 10px rgba(255,68,0,0.3); }
.ws-icon.all-view { background: linear-gradient(45deg, #333, #111); font-size: 18px; }

.sidebar-header { 
    padding: 20px; font-size: 0.7rem; text-transform: uppercase; 
    color: var(--text-dim); display: flex; justify-content: space-between; 
    align-items: center; letter-spacing: 1px; 
}

.search-container { padding: 10px 15px; border-bottom: 1px solid var(--border); }
#snippet-search { 
    width: 100%; background: #222; border: 1px solid var(--border); 
    color: var(--text); padding: 8px; border-radius: 4px; 
    font-size: 11px; outline: none; 
}

/* --- SNIPPET LIST ITEMS --- */
#snippet-list { overflow-y: auto; flex-grow: 1; }
.snippet-item { 
    padding: 15px 20px; border-bottom: 1px solid var(--border); 
    cursor: pointer; position: relative; display: flex; 
    justify-content: space-between; align-items: flex-start; 
}
.snippet-item:hover { background: #222; }
.snippet-item.active { background: #2a2a2a; border-left: 3px solid var(--accent); }
.snippet-item h4 { font-size: 13px; margin-bottom: 4px; max-width: 170px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.snippet-item p { font-size: 10px; color: var(--text-dim); }

.snippet-actions { display: flex; gap: 12px; align-items: center; padding-left: 10px; }
.star-icon { font-size: 16px; color: #333; transition: 0.2s; cursor: pointer; }
.star-icon.active { color: var(--star) !important; }
.trash-icon { cursor: pointer; font-size: 14px; opacity: 0.3; transition: opacity 0.2s; }
.trash-icon:hover { opacity: 1; color: var(--danger); }
.stale-badge { font-size: 9px; color: var(--warning); border: 1px solid var(--warning); padding: 1px 4px; border-radius: 3px; margin-top: 5px; font-weight: bold; }

/* --- EDITOR & HEADER --- */
#editor-container { flex-grow: 1; display: flex; flex-direction: column; background: var(--bg-deep); }
#editor-header { padding: 12px 30px; border-bottom: 1px solid var(--border); display: flex; gap: 12px; align-items: center; }
#editor-title { background: transparent; border: none; color: white; font-size: 1rem; flex-grow: 1; outline: none; font-weight: 500; }

#workspace-selector { 
    display: block !important; background: #222; color: var(--text); border: 1px solid var(--border); 
    padding: 6px 10px; border-radius: 4px; font-size: 11px; outline: none; cursor: pointer; 
}

#main-textarea { 
    flex-grow: 1; background: transparent; border: none; color: #d4d4d4; 
    padding: 30px; font-family: 'SF Mono', 'Fira Code', monospace; 
    font-size: 14px; line-height: 1.6; resize: none; outline: none; 
}

.toolbar-group { display: flex; gap: 8px; align-items: center; }
.toolbar-btn { background: #222; color: #999; border: 1px solid var(--border); padding: 5px 12px; border-radius: 4px; cursor: pointer; font-size: 11px; }
.btn-save:not(:disabled) { background: var(--btn-active); color: white; opacity: 1; border-color: #444; }

/* --- SYSTEM MODAL & TABS --- */
.modal-overlay { 
    position: fixed; z-index: 5000; left: 0; top: 0; width: 100%; height: 100%; 
    background: rgba(0,0,0,0.85); display: flex; align-items: center; justify-content: center; backdrop-filter: blur(8px); 
}
.modal-content.system-settings { 
    background: #111; border: 1px solid #333; width: 90%; max-width: 600px; 
    max-height: 85vh; border-radius: 12px; padding: 25px; overflow-y: auto; 
}

.modal-tabs { display: flex; gap: 15px; border-bottom: 1px solid var(--border); margin-bottom: 20px; padding-bottom: 10px; align-items: center; }
.tab-btn { background: none; border: none; color: var(--text-dim); cursor: pointer; font-weight: bold; font-size: 13px; padding: 5px 0; }
.tab-btn.active { color: var(--accent); border-bottom: 2px solid var(--accent); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.close-modal { background: none; border: none; color: white; font-size: 18px; cursor: pointer; opacity: 0.5; margin-left: auto; }

/* --- WORKSPACE MANAGEMENT UI --- */
.ws-manage-item { 
    display: flex; align-items: center; gap: 15px; padding: 12px; 
    background: rgba(255,255,255,0.03); margin-bottom: 8px; border-radius: 6px; border: 1px solid transparent;
}
.ws-mini-preview { width: 32px; height: 32px; border-radius: 4px; display: flex; align-items: center; justify-content: center; overflow: hidden; font-size: 14px; flex-shrink: 0; }
.ws-mini-preview img { width: 100%; height: 100%; object-fit: cover; }

.ws-editor-form { margin-top: 25px; padding-top: 20px; border-top: 1px solid var(--border); }
.ws-form-row { display: grid; grid-template-columns: auto 60px 1fr; gap: 15px; margin: 15px 0; }
.input-col { display: flex; flex-direction: column; gap: 5px; }
.input-col label { font-size: 10px; text-transform: uppercase; color: var(--text-dim); letter-spacing: 1px; }
.ws-editor-form input[type="text"], .ws-editor-form input[type="color"] {
    background: #222; border: 1px solid var(--border); color: white; padding: 8px; border-radius: 4px; outline: none;
}
.primary-btn { background: var(--accent); color: white; border: none; padding: 12px; border-radius: 6px; font-weight: bold; cursor: pointer; width: 100%; }

/* --- CONTEXT MENU --- */
#context-menu { 
    position: fixed; background: #222; border: 1px solid var(--border); border-radius: 6px; 
    width: 180px; display: none; z-index: 9999; padding: 5px 0; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.5); 
}
.menu-item { padding: 8px 15px; font-size: 12px; cursor: pointer; color: #ccc; transition: 0.1s; }
.menu-item:hover { background: var(--accent); color: white; }
.menu-item.danger:hover { background: var(--danger); }
.menu-sep { height: 1px; background: var(--border); margin: 5px 0; }

/* --- ASSET TRAY & UTILITIES --- */
#asset-tray {
    display: flex;
    gap: 15px;
    padding: 15px;
    background: #0a0a0a;
    border-top: 1px solid #1a1a1a;
    overflow-x: auto;
    min-height: 140px;
}

.asset-card {
    min-width: 120px;
    max-width: 120px;
    background: #111;
    border-radius: 4px;
    overflow: hidden;
    font-size: 10px;
}

.asset-preview {
    height: 80px;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.asset-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.asset-info { padding: 6px 10px; border-top: 1px solid #222; }
.asset-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #888; font-size: 9px; font-family: monospace; margin-bottom: 4px; }

.device-item { display: flex; justify-content: space-between; align-items: center; background: #0a0a0a; border: 1px solid #222; padding: 12px; border-radius: 8px; font-size: 11px; color: #aaa; margin-bottom: 8px; }
#toast { position: fixed; bottom: 25px; right: 25px; background: #222; color: var(--accent); border: 1px solid var(--accent); padding: 12px 24px; border-radius: 6px; font-size: 12px; font-weight: bold; display: none; z-index: 9999; }

.sidebar-footer { margin-top: auto; padding: 20px; border-top: 1px solid var(--border); }
.logout-link { font-size: 10px; color: #444; cursor: pointer; text-transform: uppercase; letter-spacing: 1px; }
.logout-link:hover { color: var(--danger); }

.modal-row {
    background: #000;
    margin-bottom: 2px;
    transition: background 0.2s;
}
.modal-row:hover {
    background: #0a0a0a;
}
.modal-row span {
    font-size: 13px;
    color: var(--text-dim);
}
.modal-row button {
    background: #222;
    border: none;
    color: #fff;
    padding: 6px 12px;
    border-radius: 3px;
    cursor: pointer;
    margin-left: 5px;
    font-size: 11px;
}
.modal-row button.danger:hover {
    background: var(--danger);
}